Graphics Reference
In-Depth Information
void main( )
{
ivec2 ires = textureSize( uImageUnit, 0 );
float ResS = float( ires.s );
float ResT = float( ires.t );
vec3 irgb = texture( uImageUnit, vST ).rgb;
vec3 brgb = texture( uBeforeUnit, vST ).rgb;
vec3 argb = texture( uAfterUnit, vST ).rgb;
vec3 rgb = texture( uImageUnit, vST ).rgb;
vec2 stp0 = vec2(1./uResS, 0. );
vec2 st0p = vec2(0. , 1./uResT);
vec2 stpp = vec2(1./uResS, 1./uResT);
vec2 stpm = vec2(1./uResS, -1./uResT);
const vec3 W = vec3( 0.2125, 0.7154, 0.0721 );
float i00 = dot( texture( uImageUnit, vST).rgb, W );
float im1m1= dot( texture( uImageUnit, vST-stpp ).rgb, W );
float ip1p1= dot( texture( uImageUnit, vST+stpp ).rgb, W );
float im1p1= dot( texture( uImageUnit, vST-stpm ).rgb, W );
float ip1m1= dot( texture( uImageUnit, vST+stpm ).rgb, W );
float im10 = dot( texture( uImageUnit, vST-stp0 ).rgb, W );
float ip10 = dot( texture( uImageUnit, vST+stp0 ).rgb, W );
float i0m1 = dot( texture( uImageUnit, vST-st0p ).rgb, W );
float i0p1 = dot( texture( uImageUnit, vST+st0p ).rgb, W );
// next two lines apply the H and V Sobel filters at the pixel
float h= -1.*im1p1-2.*i0p1-1.*ip1p1+1.*im1m1+2.*i0m1+1.*ip1m1;
float v= -1.*im1m1-2.*im10-1.*im1p1+1.*ip1m1+2.*ip10+1.*ip1p1;
float mag = length( vec2( h, v ) ); // how much change
// is there?
if( mag > uMagTol )
{ // if too much, use black
fFragColor = vec4( 0., 0., 0., 1. );
}
else
{ // else quantize the color
rgb.rgb *= uQuantize;
rgb.rgb += vec3( .5, .5, .5 ); // round
ivec3 intrgb = ivec3( rgb.rgb ); // truncate
rgb.rgb = vec3( intrgb ) / Quantize;
fFragColor = vec4( rgb, 1. );
}
}
Search WWH ::




Custom Search