Update nightvision2scanlines.glsl
This commit is contained in:
parent
548d872843
commit
4c1ef9ba80
|
@ -7,55 +7,70 @@ uniform vec4 resolution;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
//variables
|
//variables
|
||||||
float internalresolution = 1278.0;
|
float internalresolution = 1278.0;
|
||||||
float4 c0 = texture(samp9, uv0).rgba;
|
float4 c0 = texture(samp9, uv0).rgba;
|
||||||
//blur
|
|
||||||
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
|
//blur
|
||||||
float blursize = 1.5;
|
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
|
||||||
blurtotal += texture(samp9, uv0 + float2(-blursize, -blursize)*resolution.zw);
|
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, 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, 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( 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;
|
blurtotal += texture(samp9, uv0 + float2( 0.0, blursize)*resolution.zw);
|
||||||
c0 = blurtotal;
|
blurtotal *= 0.125;
|
||||||
//greyscale
|
c0 = blurtotal;
|
||||||
float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
|
|
||||||
// brighten and apply horizontal scanlines
|
//greyscale
|
||||||
// This would have been much simpler if I could get the stupid modulo (%) to work
|
float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
|
||||||
// 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;
|
// brighten and apply horizontal scanlines
|
||||||
float vPos = uv0.y*resolution.y / 9.0;
|
// This would have been much simpler if I could get the stupid modulo (%) to work
|
||||||
float lineIntensity = (((vPos - floor(vPos)) * 9.0) - 4.0) / 40.0;
|
// If anyone who is more well versed in Cg knows how to do this it'd be slightly more efficient
|
||||||
grey = grey * 0.5 + 0.7 + lineIntensity;
|
// float lineIntensity = ((uv0[1] % 9) - 4) / 40;
|
||||||
// darken edges
|
float vPos = uv0.y*resolution.y / 9.0;
|
||||||
float x = uv0.x * resolution.x;
|
float lineIntensity = (((vPos - floor(vPos)) * 9.0) - 4.0) / 40.0;
|
||||||
float y = uv0.y * resolution.y;
|
grey = grey * 0.5 + 0.7 + lineIntensity;
|
||||||
if (x > internalresolution/2.0) x = internalresolution-x;
|
|
||||||
if (y > internalresolution/2.0) y = internalresolution-y;
|
// darken edges
|
||||||
if (x > internalresolution/2.0*0.95) x = internalresolution/2.0*0.95;
|
float x = uv0.x * resolution.x;
|
||||||
if (y > internalresolution/2.0*0.95) y = internalresolution/2.0*0.95;
|
float y = uv0.y * resolution.y;
|
||||||
x = -x + 641.0;
|
|
||||||
y = -y + 641.0;
|
if (x > internalresolution/2.0)
|
||||||
/*****inline square root routines*****/
|
x = internalresolution-x;
|
||||||
// bit of a performance bottleneck.
|
|
||||||
// neccessary to make the darkened area rounded
|
if (y > internalresolution/2.0)
|
||||||
// instead of rhombus-shaped.
|
y = internalresolution-y;
|
||||||
float sqrt = x / 10.0;
|
|
||||||
while((sqrt*sqrt) < x) sqrt+=0.1;
|
if (x > internalresolution/2.0*0.95)
|
||||||
x = sqrt;
|
x = internalresolution/2.0*0.95;
|
||||||
sqrt = y / 10.0;
|
|
||||||
while((sqrt*sqrt) < y) sqrt+=0.1;
|
if (y > internalresolution/2.0*0.95)
|
||||||
y = sqrt;
|
y = internalresolution/2.0*0.95;
|
||||||
/*****end of inline square root routines*****/
|
|
||||||
x *= 2.0;
|
x = -x + 641.0;
|
||||||
y *= 2.0;
|
y = -y + 641.0;
|
||||||
grey -= x / 200.0;
|
|
||||||
grey -= y / 200.0;
|
//****inline square root routines*****/
|
||||||
// output
|
// bit of a performance bottleneck.
|
||||||
ocol0 = float4(0.0, grey, 0.0, 1.0);
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue