As most users of Media Player Classic will know, the program has the option to run DirectX pixel shaders over the video being played back.
Most of the shaders which come with the program are just for things like colour correction and image sharpening, although there are a few which perform interesting effects.
Now, Escapists, what shaders have you written?
Remember to put your source code inside the code tags when posting.
Me? I've been doing some work into creating non-photorealistic effects and aspects of old technology, including analogue TV, film, and old-school computer displays.
I'll start with three of my simpler shaders. I don't want to hog all the glory.
----
Simple 3-bit-per-channel quantisation (aka posterisation):
----
----
Quantise the brightness only:
----
----
An attempt to mimic old NTSC colour, taking into account the fact that more bandwidth goes to I (orange-cyan) than Q (green-purple):
----
----
This last one borrows the rgb2yuv and yuv2rgb functions from one of the shaders which comes with Media Player Classic. All three can be compiled for Shader Model 2.
Most of the shaders which come with the program are just for things like colour correction and image sharpening, although there are a few which perform interesting effects.
Now, Escapists, what shaders have you written?
Remember to put your source code inside the code tags when posting.
Me? I've been doing some work into creating non-photorealistic effects and aspects of old technology, including analogue TV, film, and old-school computer displays.
I'll start with three of my simpler shaders. I don't want to hog all the glory.
----
Simple 3-bit-per-channel quantisation (aka posterisation):
----
Code:
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float4 c0 = tex2D(s0, tex);
float levels = 8;
return floor(c0*levels)/levels;
}
Quantise the brightness only:
----
Code:
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float levels = 8;
float3 c0 = tex2D(s0, tex).rgb;
float c1 = length(c0);
c0 = normalize(c0);
c1 /= sqrt(3);
c1 = floor(c1*levels)/levels;
c1 *= sqrt(3);
return float4(c0*c1,1);
}
An attempt to mimic old NTSC colour, taking into account the fact that more bandwidth goes to I (orange-cyan) than Q (green-purple):
----
Code:
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
float4 rgb2yuv(float4 rgb)
{
float4x4 coeffs=
{
0.299, 0.587, 0.114, 0.000,
-0.147,-0.289, 0.436, 0.000,
0.615,-0.515,-0.100, 0.000,
0.000, 0.000, 0.000, 0.000
};
return mul(coeffs,rgb);
}
float4 yuv2rgb(float4 yuv)
{
float4x4 coeffs=
{
1.000, 0.000, 1.140, 0.000,
1.000,-0.395,-0.581, 0.000,
1.000, 2.032, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000
};
return mul(coeffs,yuv);
}
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float4 c0 = tex2D(s0, tex);
float4 c1 = rgb2yuv(c0);
float i = c1[2]*cos(radians(33)) - c1[1]*sin(radians(33));
float q = c1[2]*sin(radians(33)) + c1[1]*cos(radians(33));
i *= 1.3;
q *= 0.6;
c1[1] = q*cos(radians(33)) - i*sin(radians(33));
c1[2] = q*sin(radians(33)) + i* cos(radians(33));
return yuv2rgb(c1);
}
This last one borrows the rgb2yuv and yuv2rgb functions from one of the shaders which comes with Media Player Classic. All three can be compiled for Shader Model 2.