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); }