I am trying to create my own soft blending for particles. My idea is to compare the eye space depth value of a particle fragment to the eye space depth value of the pixel in the render buffer that is at the same location where the particle fragment is project to.
So I do the following:
- render all other stuff (geometry, objects)
- read the depth buffer
- render particles, using the depth buffer in a fragment shader to compare the particle fragment’s depth with the depth of the pixel that has already be stored in the render buffer
Now to have the particle fragment’s eye space position I simply need to to do “float4 particleVertex = gl_ModelViewMatrix * gl_Vertex” in the vertex shader and pass particleVertex as a varying to the fragment shader - right or wrong?
How do I retrieve the eye space depth value of a pixel from its Z value from the depth buffer please?
Or do I have to do the comparisons via world space?