Jump to content

Linear depth shadow maps


Josh
 Share

Recommended Posts

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.

image.thumb.png.d1f5fb19e0d538927501f7183e129f2e.png

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.

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...