uniform sampler2D bgl_RenderedTexture;
uniform sampler2D bgl_DepthTexture;
vec2 texcoord = vec2(gl_TexCoord[0]).st;
uniform vec2 bgl_TextureCoordinateOffset[9];
vec4 prewitt(sampler2D image, vec2 coords)
{
vec4 samp[9];
vec4 border;
vec4 texcol = texture(image, texcoord);
for (int i = 0; i < 9; i++)
{
samp[i] = texture(image, gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
}
vec4 horizEdge = samp[2] + samp[5] + samp[8] - (samp[0] + samp[3] + samp[6]);
vec4 vertEdge = samp[0] + samp[1] + samp[2] - (samp[6] + samp[7] + samp[8]);
border.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb));
float br = smoothstep(.005, .01, border.r);
float bg = smoothstep(.005, .01, border.g);
float bb = smoothstep(.005, .01, border.b);
texcol.rgb = vec3(mix(1., .0, max(max(br,bg),bb)));
return texcol;
}
void main(void)
{
gl_FragColor = prewitt(bgl_DepthTexture, texcoord);
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}