I am trying to clamp decals to walls such that they do not overhang edges by testing if decal fragment depths are within a certain tolerance of the existing depth buffer value.
Is there a way to do this without a shader?
I tried using a shader, but it doesn't seem to read the depth properly. The decals just disappear if they are a certain distance away.
Here is the pertinent line in the shader:
Code :if(gl_FragCoord.z < texture2D(gDepthSampler, gl_FragCoord.xy / vec2(windowWidth, windowHeight)).r - 0.01) discard;
Thank you for any help you can offer.