diff options
author | v0lt <v0lt@rambler.ru> | 2013-03-16 15:25:24 +0400 |
---|---|---|
committer | v0lt <v0lt@rambler.ru> | 2013-03-16 15:27:44 +0400 |
commit | da59b57a76da243275345bc5e6045382e13102e8 (patch) | |
tree | e5e95a32969e73b1b29d3cfa69af586be5a7c9bc /distrib | |
parent | 4f5ed9d0b4351d7452b9e880d82e03c167e6c8b7 (diff) |
Move code of shaders from registry and ini to separate files in folder.
Diffstat (limited to 'distrib')
23 files changed, 791 insertions, 0 deletions
diff --git a/distrib/Shaders/0-255 to 16-235.psh b/distrib/Shaders/0-255 to 16-235.psh new file mode 100644 index 000000000..44c5b6f6c --- /dev/null +++ b/distrib/Shaders/0-255 to 16-235.psh @@ -0,0 +1,13 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); + +#define const_1 ( 16.0 / 255.0) +#define const_2 (219.0 / 255.0) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + // original pixel + float4 c0 = tex2D(s0, tex); + + return (c0 * const_2) + const_1; +} diff --git a/distrib/Shaders/16-235 to 0-255 [SD].psh b/distrib/Shaders/16-235 to 0-255 [SD].psh new file mode 100644 index 000000000..a67e9b296 --- /dev/null +++ b/distrib/Shaders/16-235 to 0-255 [SD].psh @@ -0,0 +1,22 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) + +#define const_1 ( 16.0 / 255.0) +#define const_2 (255.0 / 219.0) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + // original pixel + float4 c0 = tex2D(s0, tex); + + // ATI driver only looks at the height + if (height >= 720) { + return c0; + } else { + return ((c0 - const_1) * const_2); + } +} diff --git a/distrib/Shaders/16-235 to 0-255 [SD][HD].psh b/distrib/Shaders/16-235 to 0-255 [SD][HD].psh new file mode 100644 index 000000000..034a8bc61 --- /dev/null +++ b/distrib/Shaders/16-235 to 0-255 [SD][HD].psh @@ -0,0 +1,13 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); + +#define const_1 ( 16.0 / 255.0) +#define const_2 (255.0 / 219.0) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + // original pixel + float4 c0 = tex2D(s0, tex); + + return ((c0 - const_1) * const_2); +} diff --git a/distrib/Shaders/BT.601 to BT.709.psh b/distrib/Shaders/BT.601 to BT.709.psh new file mode 100644 index 000000000..f41ae166a --- /dev/null +++ b/distrib/Shaders/BT.601 to BT.709.psh @@ -0,0 +1,19 @@ +// $ShaderVersion: ps_2_0 + +// (C) 2011 Jan-Willem Krans (janwillem32 <at> hotmail.com) released under GPL v2; see COPYING.txt + +// Correct video colorspace BT.601 [SD] to BT.709 [HD] for HD video input +// Use this shader only if BT.709 [HD] encoded video is incorrectly matrixed to full range RGB with the BT.601 [SD] colorspace. + +sampler s0; +float2 c0; + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float4 si = tex2D(s0, tex); // original pixel + if (c0.x < 1120 && c0.y < 630) { + return si; // this shader does not alter SD video + } + float3 s1 = si.rgb; + s1 = s1.rrr * float3(0.299, -0.1495 / 0.886, 0.5) + s1.ggg * float3(0.587, -0.2935 / 0.886, -0.2935 / 0.701) + s1.bbb * float3(0.114, 0.5, -0.057 / 0.701); // RGB to Y'CbCr, BT.601 [SD] colorspace + return (s1.rrr + float3(0, -0.1674679 / 0.894, 1.8556) * s1.ggg + float3(1.5748, -0.4185031 / 0.894, 0) * s1.bbb).rgbb; // Y'CbCr to RGB output, BT.709 [HD] colorspace +} diff --git a/distrib/Shaders/LCD angle correction.psh b/distrib/Shaders/LCD angle correction.psh new file mode 100644 index 000000000..77803b91c --- /dev/null +++ b/distrib/Shaders/LCD angle correction.psh @@ -0,0 +1,49 @@ +// $ShaderVersion: ps_2_0 + +// (C) 2011 Jan-Willem Krans (janwillem32 <at> hotmail.com) released under GPL v2; see COPYING.txt + +// Brightness, contrast and gamma controls for RGB, linearly scaled from top to bottom. +// This shader can be run as a screen space pixel shader. It requires compiling with ps_2_0, +// but higher is better see http://en.wikipedia.org/wiki/Pixel_shader to look up what PS version +// your video card supports. +// This shader is meant to work with linear RGB input and output. Regular R'G'B' with +// a video gamma encoding will have to be converted with the linear gamma shaders to work properly. + +// Fractions, either decimal or not, are allowed +// RedBrightness, GreenBrightness and BlueBrightness, interval [-10, 10], default 0 +#define RedBrightnessTop 0 +#define GreenBrightnessTop 0 +#define BlueBrightnessTop 0 +#define RedBrightnessBottom 0 +#define GreenBrightnessBottom 0 +#define BlueBrightnessBottom 0 + +// RedContrast, GreenContrast and BlueContrast, interval [0, 10], default 1 +#define RedContrastTop 1 +#define GreenContrastTop 1 +#define BlueContrastTop 1 +#define RedContrastBottom 1 +#define GreenContrastBottom 1 +#define BlueContrastBottom 1 + +// RedGamma, GreenGamma and BlueGamma, interval (0, 10], default 1 +#define RedGammaTop 0.8 +#define GreenGammaTop 0.8 +#define BlueGammaTop 0.8 +#define RedGammaBottom 1 +#define GreenGammaBottom 1 +#define BlueGammaBottom 1 + +sampler s0; + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float3 s1 = tex2D(s0, tex).rgb; + // original pixel + float texyi = 1.0 - tex.y; + s1 = s1 * (texyi * float3(RedContrastTop, GreenContrastTop, BlueContrastTop) + tex.y * float3(RedContrastBottom, GreenContrastBottom, BlueContrastBottom)) + texyi * float3(RedBrightnessTop, GreenBrightnessTop, BlueBrightnessTop) + tex.y * float3(RedBrightnessBottom, GreenBrightnessBottom, BlueBrightnessBottom); + // process contrast and brightness on the original pixel + // preserve the sign bits of RGB values + float3 sb = sign(s1); + return (sb*pow(abs(s1), texyi * float3(RedGammaTop, GreenGammaTop, BlueGammaTop) + tex.y * float3(RedGammaBottom, GreenGammaBottom, BlueGammaBottom))).rgbb; + // process gamma correction and output +} diff --git a/distrib/Shaders/YV12 Chroma Upsampling.psh b/distrib/Shaders/YV12 Chroma Upsampling.psh new file mode 100644 index 000000000..14bbecc3f --- /dev/null +++ b/distrib/Shaders/YV12 Chroma Upsampling.psh @@ -0,0 +1,76 @@ +// $ShaderVersion: ps_2_0 + +/* +YV12 chroma upsampling fixer +by Kurt Bernhard 'Leak' Pruenner + +Use with YV12 output if the half-resolution chroma +gets upsampled in hardware by doubling the values +instead of interpolating between them. + +(i.e. if you're getting blocky red edges on dark +backgrounds...) +*/ + +sampler s0 : register(s0); +float4 p0 : register(c0); +float4 p1 : register(c1); + +#define width (p0[0]) +#define height (p0[1]) + +float4 getPixel(float2 tex, float dx, float dy) +{ + tex.x += dx; + tex.y += dy; + + return tex2D(s0, tex); +} + +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 { + float dx = 1 / width; + float dy = 1 / height; + + float4 yuv00 = rgb2yuv(getPixel(tex, -dx, -dy)); + float4 yuv01 = rgb2yuv(getPixel(tex, -dx, 0)); + float4 yuv02 = rgb2yuv(getPixel(tex, -dx, dy)); + float4 yuv10 = rgb2yuv(getPixel(tex, 0, -dy)); + float4 yuv11 = rgb2yuv(getPixel(tex, 0, 0)); + float4 yuv12 = rgb2yuv(getPixel(tex, 0, dy)); + float4 yuv20 = rgb2yuv(getPixel(tex, dx, -dy)); + float4 yuv21 = rgb2yuv(getPixel(tex, dx, 0)); + float4 yuv22 = rgb2yuv(getPixel(tex, dx, dy)); + + float4 yuv = + (yuv00 * 1 + yuv01 * 2 + yuv02 * 1 + + yuv10 * 2 + yuv11 * 4 + yuv12 * 2 + + yuv20 * 1 + yuv21 * 2 + yuv22 * 1) / 16; + + yuv.r = yuv11.r; + + return yuv2rgb(yuv); +} diff --git a/distrib/Shaders/contour.psh b/distrib/Shaders/contour.psh new file mode 100644 index 000000000..4742897fa --- /dev/null +++ b/distrib/Shaders/contour.psh @@ -0,0 +1,27 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float dx = 4 / width; + float dy = 4 / height; + + float4 c2 = tex2D(s0, tex + float2( 0, -dy)); + float4 c4 = tex2D(s0, tex + float2(-dx, 0)); + float4 c5 = tex2D(s0, tex + float2( 0, 0)); + float4 c6 = tex2D(s0, tex + float2( dx, 0)); + float4 c8 = tex2D(s0, tex + float2( 0, dy)); + + float4 c0 = (-c2 - c4 + c5 * 4 - c6 - c8); + if (length(c0) < 1.0) { + c0 = float4(0, 0, 0, 0); + } else { + c0 = float4(1, 1, 1, 0); + } + + return c0; +} diff --git a/distrib/Shaders/deinterlace (blend).psh b/distrib/Shaders/deinterlace (blend).psh new file mode 100644 index 000000000..280f305dc --- /dev/null +++ b/distrib/Shaders/deinterlace (blend).psh @@ -0,0 +1,18 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float4 c0 = tex2D(s0, tex); + + float2 h = float2(0, 1 / height); + float4 c1 = tex2D(s0, tex - h); + float4 c2 = tex2D(s0, tex + h); + c0 = (c0 * 2 + c1 + c2) / 4; + + return c0; +} diff --git a/distrib/Shaders/denoise.psh b/distrib/Shaders/denoise.psh new file mode 100644 index 000000000..ff4ceff12 --- /dev/null +++ b/distrib/Shaders/denoise.psh @@ -0,0 +1,36 @@ +// $ShaderVersion: ps_3_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) +#define val0 (1.0) +#define val1 (0.125) +#define effect_width (0.1) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float dx = 0.0f; + float dy = 0.0f; + float fTap = effect_width; + + float4 cAccum = tex2D(s0, tex) * val0; + + for (int iDx = 0; iDx < 16; ++iDx) { + dx = fTap / width; + dy = fTap / height; + + cAccum += tex2D(s0, tex + float2(-dx, -dy)) * val1; + cAccum += tex2D(s0, tex + float2( 0, -dy)) * val1; + cAccum += tex2D(s0, tex + float2(-dx, 0)) * val1; + cAccum += tex2D(s0, tex + float2( dx, 0)) * val1; + cAccum += tex2D(s0, tex + float2( 0, dy)) * val1; + cAccum += tex2D(s0, tex + float2( dx, dy)) * val1; + cAccum += tex2D(s0, tex + float2(-dx, +dy)) * val1; + cAccum += tex2D(s0, tex + float2(+dx, -dy)) * val1; + + fTap += 0.1f; + } + + return (cAccum / 16.0f); +} diff --git a/distrib/Shaders/edge sharpen.psh b/distrib/Shaders/edge sharpen.psh new file mode 100644 index 000000000..3e4eb2782 --- /dev/null +++ b/distrib/Shaders/edge sharpen.psh @@ -0,0 +1,54 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) + +#define NbPixel 1 +#define Edge_threshold 0.2 +#define Sharpen_val0 2.0 +#define Sharpen_val1 0.125 + +float4 main(float2 tex : TEXCOORD0) : COLOR { + // size of NbPixel pixels + float dx = NbPixel / width; + float dy = NbPixel / height; + float4 Res = 0; + + // Edge detection using Prewitt operator + // Get neighbor points + // [ 1, 2, 3 ] + // [ 4, 0, 5 ] + // [ 6, 7, 8 ] + float4 c0 = tex2D(s0, tex); + float4 c1 = tex2D(s0, tex + float2(-dx, -dy)); + float4 c2 = tex2D(s0, tex + float2( 0, -dy)); + float4 c3 = tex2D(s0, tex + float2( dx, -dy)); + float4 c4 = tex2D(s0, tex + float2(-dx, 0)); + float4 c5 = tex2D(s0, tex + float2( dx, 0)); + float4 c6 = tex2D(s0, tex + float2(-dx, dy)); + float4 c7 = tex2D(s0, tex + float2( 0, dy)); + float4 c8 = tex2D(s0, tex + float2( dx, dy)); + + // Computation of the 3 derived vectors (hor, vert, diag1, diag2) + float4 delta1 = (c6 + c4 + c1 - c3 - c5 - c8); + float4 delta2 = (c4 + c1 + c2 - c5 - c8 - c7); + float4 delta3 = (c1 + c2 + c3 - c8 - c7 - c6); + float4 delta4 = (c2 + c3 + c5 - c7 - c6 - c4); + + // Computation of the Prewitt operator + float value = length(abs(delta1) + abs(delta2) + abs(delta3) + abs(delta4)) / 6; + + // If we have an edge (vector length > Edge_threshold) => apply sharpen filter + if (value > Edge_threshold) { + Res = c0 * Sharpen_val0 - (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8) * Sharpen_val1; + // Display edges in red... + //Res = float4( 1.0, 0.0, 0.0, 0.0 ); + + return Res; + } else { + return c0; + } +} diff --git a/distrib/Shaders/emboss.psh b/distrib/Shaders/emboss.psh new file mode 100644 index 000000000..972cafea0 --- /dev/null +++ b/distrib/Shaders/emboss.psh @@ -0,0 +1,24 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float dx = 1 / width; + float dy = 1 / height; + + float4 c1 = tex2D(s0, tex + float2(-dx, -dy)); + float4 c2 = tex2D(s0, tex + float2( 0, -dy)); + float4 c4 = tex2D(s0, tex + float2(-dx, 0)); + float4 c6 = tex2D(s0, tex + float2( dx, 0)); + float4 c8 = tex2D(s0, tex + float2( 0, dy)); + float4 c9 = tex2D(s0, tex + float2( dx, dy)); + + float4 c0 = (-c1 - c2 - c4 + c6 + c8 + c9); + c0 = (c0.r + c0.g + c0.b) / 3 + 0.5; + + return c0; +} diff --git a/distrib/Shaders/grayscale.psh b/distrib/Shaders/grayscale.psh new file mode 100644 index 000000000..0e9be474e --- /dev/null +++ b/distrib/Shaders/grayscale.psh @@ -0,0 +1,9 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float c0 = dot(tex2D(s0, tex), float4(0.299, 0.587, 0.114, 0)); + + return c0; +} diff --git a/distrib/Shaders/invert.psh b/distrib/Shaders/invert.psh new file mode 100644 index 000000000..f6a7b8a13 --- /dev/null +++ b/distrib/Shaders/invert.psh @@ -0,0 +1,9 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float4 c0 = float4(1, 1, 1, 1) - tex2D(s0, tex); + + return c0; +} diff --git a/distrib/Shaders/letterbox.psh b/distrib/Shaders/letterbox.psh new file mode 100644 index 000000000..38a370f79 --- /dev/null +++ b/distrib/Shaders/letterbox.psh @@ -0,0 +1,20 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float4 c0 = 0; + + float2 ar = float2(16, 9); + float h = (1 - width / height * ar.y / ar.x) / 2; + + if (tex.y >= h && tex.y <= 1 - h) { + c0 = tex2D(s0, tex); + } + + return c0; +} diff --git a/distrib/Shaders/nightvision.psh b/distrib/Shaders/nightvision.psh new file mode 100644 index 000000000..8a2061b17 --- /dev/null +++ b/distrib/Shaders/nightvision.psh @@ -0,0 +1,8 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float c = dot(tex2D(s0, tex), float4(0.2, 0.6, 0.1, 0.1)); + return float4(0, c, 0, 0); +} diff --git a/distrib/Shaders/procamp.psh b/distrib/Shaders/procamp.psh new file mode 100644 index 000000000..c78de4c7e --- /dev/null +++ b/distrib/Shaders/procamp.psh @@ -0,0 +1,59 @@ +// $ShaderVersion: ps_2_0 + +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) + +static float4x4 r2y = { + 0.299, 0.587, 0.114, 0.000, + -0.147, -0.289, 0.437, 0.000, + 0.615, -0.515, -0.100, 0.000, + 0.000, 0.000, 0.000, 0.000 +}; + +static float4x4 y2r = { + 1.000, 0.000, 1.140, 0.000, + 1.000, -0.394, -0.581, 0.000, + 1.000, 2.028, 0.000, 0.000, + 0.000, 0.000, 0.000, 0.000 +}; + +#define ymin ( 16.0 / 255) +#define ymax (235.0 / 255) + +// Brightness: -1.0 to 1.0, default 0.0 +// Contrast: 0.0 to 10.0, default 1.0 +// Hue: -180.0 to +180.0, default 0.0 +// Saturation: 0.0 to 10.0, default 1.0 + +#define Brightness 0.0 +#define Contrast 1.0 +#define Hue 0.0 +#define Saturation 1.0 + +// tv -> pc scale +// #define Brightness (-ymin) +// #define Contrast (1.0 / (ymax - ymin)) + +static float2x2 HueMatrix = { + cos(Hue * PI / 180), sin(Hue * PI / 180), + -sin(Hue * PI / 180), cos(Hue * PI / 180) +}; + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float4 c0 = tex2D(s0, tex); + c0 = mul(r2y, c0); + c0.r = Contrast * (c0.r - ymin) + ymin + Brightness; + c0.gb = mul(HueMatrix, c0.gb) * Saturation; + c0 = mul(y2r, c0); + return c0; +} diff --git a/distrib/Shaders/sharpen complex 2.psh b/distrib/Shaders/sharpen complex 2.psh new file mode 100644 index 000000000..3293469e0 --- /dev/null +++ b/distrib/Shaders/sharpen complex 2.psh @@ -0,0 +1,92 @@ +// $ShaderVersion: ps_2_a + +/* Sharpen complex v2 (requires ps >= 2a) */ + +sampler s0 : register(s0); +float4 p0 : register(c0); +float4 p1 : register(c1); + +#define width (p0[0]) +#define height (p0[1]) + +// pixel "width" +#define px (p1[0]) +#define py (p1[1]) + +/* Parameters */ + +// for the blur filter +#define mean 0.6 +#define dx (mean * px) +#define dy (mean * py) + +#define CoefBlur 2 +#define CoefOrig (1 + CoefBlur) + +// for the sharpen filter +#define SharpenEdge 0.2 +#define Sharpen_val0 2 +#define Sharpen_val1 ((Sharpen_val0 - 1) / 8.0) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + // get original pixel + float4 orig = tex2D(s0, tex); + + // compute blurred image (gaussian filter) + float4 c1 = tex2D(s0, tex + float2(-dx, -dy)); + float4 c2 = tex2D(s0, tex + float2( 0, -dy)); + float4 c3 = tex2D(s0, tex + float2( dx, -dy)); + float4 c4 = tex2D(s0, tex + float2(-dx, 0)); + float4 c5 = tex2D(s0, tex + float2( dx, 0)); + float4 c6 = tex2D(s0, tex + float2(-dx, dy)); + float4 c7 = tex2D(s0, tex + float2( 0, dy)); + float4 c8 = tex2D(s0, tex + float2( dx, dy)); + + // gaussian filter + // [ 1, 2, 1 ] + // [ 2, 4, 2 ] + // [ 1, 2, 1 ] + // to normalize the values, we need to divide by the coeff sum + // 1 / (1+2+1+2+4+2+1+2+1) = 1 / 16 = 0.0625 + float4 flou = (c1 + c3 + c6 + c8 + 2 * (c2 + c4 + c5 + c7) + 4 * orig) * 0.0625; + + // substract blurred image from original image + float4 corrected = CoefOrig * orig - CoefBlur * flou; + + // edge detection + // Get neighbor points + // [ c1, c2, c3 ] + // [ c4, orig, c5 ] + // [ c6, c7, c8 ] + c1 = tex2D(s0, tex + float2(-px, -py)); + c2 = tex2D(s0, tex + float2( 0, -py)); + c3 = tex2D(s0, tex + float2( px, -py)); + c4 = tex2D(s0, tex + float2(-px, 0)); + c5 = tex2D(s0, tex + float2( px, 0)); + c6 = tex2D(s0, tex + float2(-px, py)); + c7 = tex2D(s0, tex + float2( 0, py)); + c8 = tex2D(s0, tex + float2( px, py)); + + // using Sobel filter + // horizontal gradient + // [ -1, 0, 1 ] + // [ -2, 0, 2 ] + // [ -1, 0, 1 ] + float delta1 = (c3 + 2 * c5 + c8) - (c1 + 2 * c4 + c6); + + // vertical gradient + // [ -1, - 2, -1 ] + // [ 0, 0, 0 ] + // [ 1, 2, 1 ] + float delta2 = (c6 + 2 * c7 + c8) - (c1 + 2 * c2 + c3); + + // computation + if (sqrt(mul(delta1, delta1) + mul(delta2, delta2)) > SharpenEdge) { + // if we have an edge, use sharpen + //return float4(1,0,0,0); + return orig * Sharpen_val0 - (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8) * Sharpen_val1; + } else { + // else return corrected image + return corrected; + } +} diff --git a/distrib/Shaders/sharpen complex.psh b/distrib/Shaders/sharpen complex.psh new file mode 100644 index 000000000..80d946564 --- /dev/null +++ b/distrib/Shaders/sharpen complex.psh @@ -0,0 +1,71 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p1 : register(c1); + +#define dx (p1[0]) +#define dy (p1[1]) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + // Pixels definition: original, blurred, corrected, final + float4 orig; + float4 blurred; + float4 corrected; + float4 final; + + // Get neighbor points + // [ 1, 2, 3 ] + // [ 4, orig, 5 ] + // [ 6, 7, 8 ] + + orig = tex2D(s0, tex); + float4 c1 = tex2D(s0, tex + float2(-dx, -dy)); + float4 c2 = tex2D(s0, tex + float2( 0, -dy)); + float4 c3 = tex2D(s0, tex + float2( dx, -dy)); + float4 c4 = tex2D(s0, tex + float2(-dx, 0)); + float4 c5 = tex2D(s0, tex + float2( dx, 0)); + float4 c6 = tex2D(s0, tex + float2(-dx, dy)); + float4 c7 = tex2D(s0, tex + float2( 0, dy)); + float4 c8 = tex2D(s0, tex + float2( dx, dy)); + + // Computation of the blurred image (gaussian filter) + // to normalize the values, we need to divide by the coeff sum + // 1/(1+2+1+2+4+2+1+2+1) = 1/16 = 0.0625 + blurred = (c1 + c3 + c6 + c8 + 2 * (c2 + c4 + c5 + c7) + 4 * orig) * 0.0625; + + // substract blurred image from original image + corrected = 2 * orig - blurred; + + // edge detection + float delta1; + float delta2; + float value; + + // using Sobel filter + // horizontal gradient + // [ -1, 0, 1 ] + // [ -2, 0, 2 ] + // [ -1, 0, 1 ] + delta1 = (c3 + 2 * c5 + c8) - (c1 + 2 * c4 + c6); + + // vertical gradient + // [ -1, -2, -1 ] + // [ 0, 0, 0 ] + // [ 1, 2, 1 ] + delta2 = (c6 + 2 * c7 + c8) - (c1 + 2 * c2 + c3); + + // computation + value = sqrt(mul(delta1, delta1) + mul(delta2, delta2)); + + if (value > 0.3) { + // if we have an edge, use sharpen + #define Sharpen_val0 2.0 + #define Sharpen_val1 0.125 + final = orig * 2 - (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8) * 0.125; + //final = float4(1, 0, 0, 0); + return final; + } + + // else return corrected image + return corrected; +} diff --git a/distrib/Shaders/sharpen.psh b/distrib/Shaders/sharpen.psh new file mode 100644 index 000000000..903b1c663 --- /dev/null +++ b/distrib/Shaders/sharpen.psh @@ -0,0 +1,31 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); +float4 p1 : register(c1); + +#define width (p0[0]) +#define height (p0[1]) + +#define val0 (2.0) +#define val1 (-0.125) +#define effect_width (1.6) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float dx = effect_width / width; + float dy = effect_width / height; + + float4 c1 = tex2D(s0, tex + float2(-dx, -dy)) * val1; + float4 c2 = tex2D(s0, tex + float2( 0, -dy)) * val1; + float4 c3 = tex2D(s0, tex + float2(-dx, 0)) * val1; + float4 c4 = tex2D(s0, tex + float2( dx, 0)) * val1; + float4 c5 = tex2D(s0, tex + float2( 0, dy)) * val1; + float4 c6 = tex2D(s0, tex + float2( dx, dy)) * val1; + float4 c7 = tex2D(s0, tex + float2(-dx, +dy)) * val1; + float4 c8 = tex2D(s0, tex + float2(+dx, -dy)) * val1; + float4 c9 = tex2D(s0, tex) * val0; + + float4 c0 = (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9); + + return c0; +} diff --git a/distrib/Shaders/sphere.psh b/distrib/Shaders/sphere.psh new file mode 100644 index 000000000..23521661b --- /dev/null +++ b/distrib/Shaders/sphere.psh @@ -0,0 +1,53 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define clock (p0[3]) +#define PI acos(-1) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + // - this is a very simple raytracer, one sphere only + // - no reflection or refraction, yet (my ati 9800 has a 64 + 32 instruction limit...) + + float3 pl = float3(3, -3, -4); // light pos + float4 cl = 0.4; // light color + + float3 pc = float3(0, 0, -1); // cam pos + float3 ps = float3(0, 0, 0.5); // sphere pos + float r = 0.65; // sphere radius + + float3 pd = normalize(float3(tex.x - 0.5, tex.y - 0.5, 0) - pc); + + float A = 1; + float B = 2 * dot(pd, pc - ps); + float C = dot(pc - ps, pc - ps) - r * r; + float D = B * B - 4 * A * C; + + float4 c0 = 0; + + if (D >= 0) { + // t2 is the smaller, obviously... + // float t1 = (-B + sqrt(D)) / (2 * A); + // float t2 = (-B - sqrt(D)) / (2 * A); + // float t = min(t1, t2); + + float t = (-B - sqrt(D)) / (2 * A); + + // intersection data + float3 p = pc + pd * t; + float3 n = normalize(p - ps); + float3 l = normalize(pl - p); + + // mapping the image onto the sphere + tex = acos(-n) / PI; + + // rotate it + tex.x = frac(tex.x + frac(clock / 10)); + + // diffuse + specular + c0 = tex2D(s0, tex) * dot(n, l) + cl * pow(max(dot(l, reflect(pd, n)), 0), 50); + } + + return c0; +} diff --git a/distrib/Shaders/spotlight.psh b/distrib/Shaders/spotlight.psh new file mode 100644 index 000000000..9b8bf0c5b --- /dev/null +++ b/distrib/Shaders/spotlight.psh @@ -0,0 +1,19 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) +#define clock (p0[3]) + +#define PI acos(-1) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float4 c0 = tex2D(s0, tex); + float3 lightsrc = float3(sin(clock * PI / 1.5) / 2 + 0.5, cos(clock * PI) / 2 + 0.5, 1); + float3 light = normalize(lightsrc - float3(tex.x, tex.y, 0)); + c0 *= pow(dot(light, float3(0, 0, 1)), 50); + + return c0; +} diff --git a/distrib/Shaders/wave.psh b/distrib/Shaders/wave.psh new file mode 100644 index 000000000..83a555442 --- /dev/null +++ b/distrib/Shaders/wave.psh @@ -0,0 +1,21 @@ +// $ShaderVersion: ps_2_0 + +sampler s0 : register(s0); +float4 p0 : register(c0); + +#define width (p0[0]) +#define height (p0[1]) +#define clock (p0[3]) + +float4 main(float2 tex : TEXCOORD0) : COLOR { + float4 c0 = 0; + + tex.x += sin(tex.x + clock / 0.3) / 20; + tex.y += sin(tex.x + clock / 0.3) / 20; + + if (tex.x >= 0 && tex.x <= 1 && tex.y >= 0 && tex.y <= 1) { + c0 = tex2D(s0, tex); + } + + return c0; +} diff --git a/distrib/mpc-hc_setup.iss b/distrib/mpc-hc_setup.iss index 4e3388171..593401423 100644 --- a/distrib/mpc-hc_setup.iss +++ b/distrib/mpc-hc_setup.iss @@ -253,6 +253,48 @@ Source: ..\COPYING.txt; DestDir: {app}; Components: mai Source: ..\docs\Authors.txt; DestDir: {app}; Components: main; Flags: ignoreversion
Source: ..\docs\Changelog.txt; DestDir: {app}; Components: main; Flags: ignoreversion
Source: ..\docs\Readme.txt; DestDir: {app}; Components: main; Flags: ignoreversion
+Source: "Shaders\16-235 to 0-255 [SD].psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\16-235 to 0-255 [SD][HD].psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\BT.601 to BT.709.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\contour.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\deinterlace (blend).psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\denoise.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\edge sharpen.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\emboss.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\grayscale.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\invert.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\LCD angle correction.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\letterbox.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\nightvision.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\procamp.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\sharpen.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\sharpen complex.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\sharpen complex 2.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\sphere.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\spotlight.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\wave.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\YV12 Chroma Upsampling.psh"; DestDir: "{userappdata}\Media Player Classic\Shaders"; Components: main; Flags: ignoreversion; Check: NOT IniUsed()
+Source: "Shaders\16-235 to 0-255 [SD].psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\16-235 to 0-255 [SD][HD].psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\BT.601 to BT.709.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\contour.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\deinterlace (blend).psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\denoise.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\edge sharpen.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\emboss.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\grayscale.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\invert.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\LCD angle correction.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\letterbox.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\nightvision.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\procamp.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\sharpen.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\sharpen complex.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\sharpen complex 2.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\sphere.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\spotlight.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\wave.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
+Source: "Shaders\YV12 Chroma Upsampling.psh"; DestDir: "{app}\Shaders"; Components: main; Flags: ignoreversion; Check: IniUsed()
[Icons]
@@ -384,6 +426,10 @@ begin Result := (sPrevPath <> '');
end;
+function IniUsed(): Boolean;
+begin
+ Result := FileExists(ExpandConstant('{app}\{#mpchc_ini}'));
+end;
// Check if MPC-HC's settings exist
function SettingsExistCheck(): Boolean;
@@ -415,6 +461,8 @@ begin //DelTree('{app}\Matrix*.bin', False, True, False);
DeleteFile(ExpandConstant('{app}\{#mpchc_ini}'));
DeleteFile(ExpandConstant('{userappdata}\Media Player Classic\default.mpcpl'));
+ DelTree(ExpandConstant('{userappdata}\Media Player Classic\Shaders\*.psh'), False, True, False);
+ RemoveDir(ExpandConstant('{userappdata}\Media Player Classic\Shaders'));
RemoveDir(ExpandConstant('{userappdata}\Media Player Classic'));
RegDeleteKeyIncludingSubkeys(HKCU, 'Software\Gabest\Filters');
RegDeleteKeyIncludingSubkeys(HKCU, 'Software\Gabest\Media Player Classic');
|