dolphin/Data/Sys/Shaders/nightvision2.glsl

57 lines
1.9 KiB
Text
Raw Normal View History

2013-03-07 19:51:57 +01:00
uniform sampler2D samp9;
2011-01-31 01:08:06 +01:00
2013-03-07 19:51:57 +01:00
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
2011-01-31 01:08:06 +01:00
{
//variables
float internalresolution = 1278.0;
2013-03-07 19:51:57 +01:00
float4 c0 = texture(samp9, uv0).rgba;
2011-01-31 01:08:06 +01:00
//blur
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
2011-01-31 01:08:06 +01:00
float blursize = 1.5;
2013-03-07 19:51:57 +01:00
blurtotal += texture(samp9, uv0 + float2(-blursize, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2(-blursize, blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2(-blursize, 0.0)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, 0.0)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( 0.0, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( 0.0, blursize)*resolution.zw);
2011-01-31 01:08:06 +01:00
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
2013-03-07 19:51:57 +01:00
float x = uv0.x * resolution.x;
float y = uv0.y * resolution.y;
if (x > internalresolution/2.0) x = internalresolution-x;
if (y > internalresolution/2.0) y = internalresolution-y;
if (x > internalresolution/2.0*0.95) x = internalresolution/2.0*0.95;
if (y > internalresolution/2.0*0.95) y = internalresolution/2.0*0.95;
x = -x+641.0;
y = -y+641.0;
2011-01-31 01:08:06 +01:00
/*****inline square root routines*****/
// bit of a performance bottleneck.
// neccessary to make the darkened area rounded
// instead of rhombus-shaped.
float sqrt = x / 10.0;
2011-01-31 01:08:06 +01:00
while((sqrt*sqrt) < x) sqrt+=0.1;
x = sqrt;
sqrt = y / 10.0;
2011-01-31 01:08:06 +01:00
while((sqrt*sqrt) < y) sqrt+=0.1;
y = sqrt;
/*****end of inline square root routines*****/
x *= 2.0;
y *= 2.0;
grey -= x / 200.0;
grey -= y / 200.0;
2011-01-31 01:08:06 +01:00
// output
ocol0 = float4(0.0, grey, 0.0, 1.0);
}