summaryrefslogtreecommitdiff
path: root/Data/Sys/Shaders
diff options
context:
space:
mode:
authormyownfriend <obiwankenobi23@live.com>2014-05-20 23:54:11 -0400
committermyownfriend <obiwankenobi23@live.com>2014-05-20 23:54:11 -0400
commit4c1ef9ba807cde2d55573b58ce99b140d7d23f6c (patch)
tree78a362794d4b6b81d770e20148ebfb28d4b35159 /Data/Sys/Shaders
parent548d872843c7c9a8da67ab8e2217117be2287e50 (diff)
Update nightvision2scanlines.glsl
Diffstat (limited to 'Data/Sys/Shaders')
-rw-r--r--Data/Sys/Shaders/nightvision2scanlines.glsl117
1 files changed, 66 insertions, 51 deletions
diff --git a/Data/Sys/Shaders/nightvision2scanlines.glsl b/Data/Sys/Shaders/nightvision2scanlines.glsl
index 8904e5f20f..1cfcd20693 100644
--- a/Data/Sys/Shaders/nightvision2scanlines.glsl
+++ b/Data/Sys/Shaders/nightvision2scanlines.glsl
@@ -7,55 +7,70 @@ uniform vec4 resolution;
void main()
{
- //variables
- float internalresolution = 1278.0;
- float4 c0 = texture(samp9, uv0).rgba;
- //blur
- float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
- float blursize = 1.5;
- 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);
- blurtotal *= 0.125;
- c0 = blurtotal;
- //greyscale
- float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
- // brighten and apply horizontal scanlines
- // This would have been much simpler if I could get the stupid modulo (%) to work
- // If anyone who is more well versed in Cg knows how to do this it'd be slightly more efficient
- // float lineIntensity = ((uv0[1] % 9) - 4) / 40;
- float vPos = uv0.y*resolution.y / 9.0;
- float lineIntensity = (((vPos - floor(vPos)) * 9.0) - 4.0) / 40.0;
- grey = grey * 0.5 + 0.7 + lineIntensity;
- // darken edges
- 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;
- /*****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;
- while((sqrt*sqrt) < x) sqrt+=0.1;
- x = sqrt;
- sqrt = y / 10.0;
- 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;
- // output
- ocol0 = float4(0.0, grey, 0.0, 1.0);
+ //variables
+ float internalresolution = 1278.0;
+ float4 c0 = texture(samp9, uv0).rgba;
+
+ //blur
+ float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
+ float blursize = 1.5;
+ 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);
+ blurtotal *= 0.125;
+ c0 = blurtotal;
+
+ //greyscale
+ float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
+
+ // brighten and apply horizontal scanlines
+ // This would have been much simpler if I could get the stupid modulo (%) to work
+ // If anyone who is more well versed in Cg knows how to do this it'd be slightly more efficient
+ // float lineIntensity = ((uv0[1] % 9) - 4) / 40;
+ float vPos = uv0.y*resolution.y / 9.0;
+ float lineIntensity = (((vPos - floor(vPos)) * 9.0) - 4.0) / 40.0;
+ grey = grey * 0.5 + 0.7 + lineIntensity;
+
+ // darken edges
+ 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;
+
+ //****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;
+ while((sqrt*sqrt) < x) sqrt+=0.1;
+ x = sqrt;
+ sqrt = y / 10.0;
+ while((sqrt*sqrt) < y) sqrt+=0.1;
+ y = sqrt;
+
+ x *= 2.0;
+ y *= 2.0;
+ grey -= x / 200.0;
+ grey -= y / 200.0;
+
+ // output
+ ocol0 = float4(0.0, grey, 0.0, 1.0);
}