dolphin/Data/User/Shaders/nightvision2.txt

51 lines
1.7 KiB
Plaintext
Raw Normal View History

2008-10-05 12:30:45 +00:00
uniform samplerRECT samp0 : register(s0);
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
{
//variables
int internalresolution = 1278;
float4 c0 = texRECT(samp0, uv0).rgba;
//blur
float4 blurtotal = float4(0, 0, 0, 0);
float blursize = 1.5;
blurtotal += texRECT(samp0, uv0 + float2(-blursize, -blursize));
blurtotal += texRECT(samp0, uv0 + float2(-blursize, blursize));
blurtotal += texRECT(samp0, uv0 + float2( blursize, -blursize));
blurtotal += texRECT(samp0, uv0 + float2( blursize, blursize));
blurtotal += texRECT(samp0, uv0 + float2(-blursize, 0));
blurtotal += texRECT(samp0, uv0 + float2( blursize, 0));
blurtotal += texRECT(samp0, uv0 + float2( 0, -blursize));
blurtotal += texRECT(samp0, uv0 + float2( 0, blursize));
blurtotal *= 0.125;
c0 = blurtotal;
//greyscale
float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
// brighten
grey = grey * 0.5 + 0.7;
// darken edges
float x = uv0[0];
float y = uv0[1];
if (x > internalresolution/2) x = internalresolution-x;
if (y > internalresolution/2) y = internalresolution-y;
if (x > internalresolution/2*0.95) x = internalresolution/2*0.95;
if (y > internalresolution/2*0.95) y = internalresolution/2*0.95;
x = -x+641;
y = -y+641;
/*****inline square root routines*****/
// bit of a performance bottleneck.
// neccessary to make the darkened area rounded
// instead of rhombus-shaped.
float sqrt=x/10;
while((sqrt*sqrt) < x) sqrt+=0.1;
x = sqrt;
sqrt=y/10;
while((sqrt*sqrt) < y) sqrt+=0.1;
y = sqrt;
/*****end of inline square root routines*****/
x *= 2;
y *= 2;
grey -= x/200;
grey -= y/200;
// output
ocol0 = float4(0, grey, 0, 1.0);
}