Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // set by the vertex shader
- varying vec2 tex_coord;
- uniform sampler2DRect colorTexture;
- uniform sampler2DRect depthTexture;
- uniform sampler2DRect normalTexture;
- uniform float near;
- uniform float far;
- uniform int width;
- uniform int height;
- vec2 top;
- vec2 bottom;
- vec2 left;
- vec2 right;
- const float offset = 0.05;
- void main(void)
- {
- top = vec2(tex_coord.x, tex_coord.y - 1);
- bottom = vec2(tex_coord.x, tex_coord.y + 1);
- left = vec2(tex_coord.x - 1, tex_coord.y);
- right = vec2(tex_coord.x + 1, tex_coord.y);
- float topD = texture2DRect(depthTexture, top);
- float bottomD = texture2DRect(depthTexture, bottom);
- float leftD = texture2DRect(depthTexture, left);
- float rightD = texture2DRect(depthTexture, right);
- //converting the values obtained from the depth buffer
- float topZ = (near*far)/far-topD*(far-near);
- float bottomZ = (near*far)/far-bottomD*(far-near);
- float leftZ = (near*far)/far-leftD*(far-near);
- float rightZ = (near*far)/far-rightD*(far-near);
- float magnitude = abs(rightZ - leftZ) + abs(bottomZ - topZ);
- if(magnitude > offset)
- {
- // make it black
- gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
- }
- else
- {
- // leave it as is.
- gl_FragColor = texture2DRect(colorTexture,tex_coord);
- }
- // render a color based on the texture coordinate
- //gl_FragCoord = gl_FragCoord;
- }
Add Comment
Please, Sign In to add comment