Fragment shader - Occlusion Culling
I have a short question about occlusion culling, done with the fragment shader.
What do you think about the following algorithm:
Take the previous rendered depth buffer from the scene
Pass it to the forward rendering shader
All shaders, except the fragment shader, are default pass through shaders
The fragment shader calculates the screen space coordinate from the current rendered fragment
The fragment shader compares the value from the previous rendered depth buffer with the current rendered fragments depth
The fragment shader skips the fragment, if the fragments depth is higher then the previous depth value (Skip it with keyword "discard")
I know that the fragment shader is the last step before rasterization, and now, i don't know, if it would gain enough performance for implementation.
With this method, the rasterization for the rendered fragment would be skipped.