Josh Posted March 14 Share Posted March 14 The biggest difficulty with getting consistent shadow map offsets is the fact that depth textures are stored in non-linear space. This is good for camera depth testing but terrible for shadows. You can see in this image the area near the light source has higher precision than the area further away from the camera. If the precision was equal for all distances it would be much easier to set or calculate an offset that would prevent the "shadow acne" artifact. My idea is to modify the gl_FragPosition.z value in the output of the vertex shader, in order to reverse the linear-to-depth transformation before it is stored in the shadow map, which will equal a linear value that can then be compared to a linear position in the shadow sampling step in the lighting shaders. I am having no luck getting this to work so far. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted March 15 Share Posted March 15 If i remember correctly you need to modify gl_FragDepth in the fragment shader. If gl_FragDepth is not set in fragment, then the fixed function depth method will be used. Ref: https://registry.khronos.org/OpenGL-Refpages/gl4/html/gl_FragDepth.xhtml Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.