Closed definability closed 7 years ago
gl_FragDepth
gl_FragDepth hacking depending on gl_FrontFacing doesn't work, because depth test looks at gl_FragDepth
and places it to appropriate layer (the highest to the viewport).
Separate texture can be used to store each pixel gl_FrontFacing
state during shadow map creation procedure and read during final scene rendering.
Connect opposite parts of the back side of the model to hide backface of the face with them.
Solution: as long as shadow map camera position is the light vector, which is multiplied by fragment normal vector, if it sees back side of a fragment, this means that cosine of angle between normal and light vector is negative so dot product is.
When the dot product of normal and light vector of a vertex is negative, the vertex is shaded as long as only one light source exists.
When light source looks on back face of Face model, shadows are processed improperly because there's no difference between back and front pixels distance from the light source.
Maybe it's reasonable to attach a plane or hemisphere to back side of the model.