For a long time I was occuring issue with lights which use light volume to reduce fragment shaders run (point, spot).
First I use stencil pass to mark pixels which should be processed by fragment shader by drawing a sphere. Then in light pass I render the same sphere again.
Everything works ok until light volume cuts with far plane. Back faces of that volume aren't rendered so stencil buffer contain 0 value.
Because of that final image has big black circle instead of lightened area. I searched how to overcome that issue and I realized that one of the solution to this problem is to enable GL_DEPTH_CLAMP which ignores near and far plane. I enabled it for both passes. The problem dissapeared.
My question are:
- Is that correct solution used by people and does it decrease performance?
- Why all tutorials doesn't mention about that issue? I'm curious if I have something wrong in my implementation.
I am aware that there are other methods such as screen-aligned quads or tile based deferred rendering but I want to understand this method as well.