2013-03-07 11:51:57 -07:00
|
|
|
void main()
|
2010-06-22 22:53:43 -06:00
|
|
|
{
|
2014-05-20 21:54:11 -06:00
|
|
|
//variables
|
|
|
|
float internalresolution = 1278.0;
|
2014-07-29 11:08:57 -06:00
|
|
|
float4 c0 = Sample();
|
2014-05-20 21:54:11 -06:00
|
|
|
|
|
|
|
//blur
|
|
|
|
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
|
|
|
|
float blursize = 1.5;
|
2014-07-29 11:08:57 -06:00
|
|
|
blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, -blursize)*GetInvResolution());
|
|
|
|
blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, blursize)*GetInvResolution());
|
|
|
|
blurtotal += SampleLocation(GetCoordinates() + float2( blursize, -blursize)*GetInvResolution());
|
|
|
|
blurtotal += SampleLocation(GetCoordinates() + float2( blursize, blursize)*GetInvResolution());
|
|
|
|
blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, 0.0)*GetInvResolution());
|
|
|
|
blurtotal += SampleLocation(GetCoordinates() + float2( blursize, 0.0)*GetInvResolution());
|
|
|
|
blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, -blursize)*GetInvResolution());
|
|
|
|
blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, blursize)*GetInvResolution());
|
2014-05-20 21:54:11 -06:00
|
|
|
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
|
2014-07-29 11:08:57 -06:00
|
|
|
// float lineIntensity = ((GetCoordinates()[1] % 9) - 4) / 40;
|
|
|
|
float vPos = GetCoordinates().y*GetResolution().y / 9.0;
|
2014-05-20 21:54:11 -06:00
|
|
|
float lineIntensity = (((vPos - floor(vPos)) * 9.0) - 4.0) / 40.0;
|
|
|
|
grey = grey * 0.5 + 0.7 + lineIntensity;
|
|
|
|
|
|
|
|
// darken edges
|
2014-07-29 11:08:57 -06:00
|
|
|
float x = GetCoordinates().x * GetResolution().x;
|
|
|
|
float y = GetCoordinates().y * GetResolution().y;
|
2014-05-20 21:54:11 -06:00
|
|
|
|
|
|
|
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;
|
2014-05-20 22:11:11 -06:00
|
|
|
while ((sqrt*sqrt) < x)
|
|
|
|
sqrt+=0.1;
|
2014-05-20 21:54:11 -06:00
|
|
|
x = sqrt;
|
|
|
|
sqrt = y / 10.0;
|
2014-05-20 22:11:11 -06:00
|
|
|
while ((sqrt*sqrt) < y)
|
|
|
|
sqrt+=0.1;
|
2014-05-20 21:54:11 -06:00
|
|
|
y = sqrt;
|
|
|
|
|
|
|
|
x *= 2.0;
|
|
|
|
y *= 2.0;
|
|
|
|
grey -= x / 200.0;
|
|
|
|
grey -= y / 200.0;
|
|
|
|
|
|
|
|
// output
|
2014-07-29 11:08:57 -06:00
|
|
|
SetOutput(float4(0.0, grey, 0.0, 1.0));
|
2014-05-05 14:59:49 -06:00
|
|
|
}
|