Shadow Map Jiggling/Shimmering

Started by
15 comments, last by skyemaidstone 6 years, 5 months ago

Thanks. So just to confirm before I read that, what I'm describing is a depth map precision problem caused by my huge coordinates?

Advertisement

You allocate 32 bit/texel, waste 8 bit/texel on some stencil you are not using. Use a 32 float depth texture without a stencil and reverse your depth (swap far and near, use a greater instead of less test) to have a better distribution. ;)

🧙

Thanks again but what i'm asking is if the problem i was experiencing could be caused by using huge coordinates (and therefore causing a lack of depth precision). I have solution, i'm just trying to make sure understand it.

Thanks for the link. I will have a read of that in depth later tonight :)

1 hour ago, skyemaidstone said:

the centre of my map was 50000,0,50000 and the bounds were at 1024000. My near/far clip were at 5, 200000

This may be very bad, yes.

Assuming we have 6 digits of floating point precision, the next possible number from 50000 is 50000.1

If you have a ratio of 1 unit == 1 meter, then you have not enough precision to for small details at the scale of centimeters, but you would have had enough if you center your world to the zero point.

Even if you have a ratio of 1 unit = 100 meters, you still waste precision. Assuming your world's bounding box corners the zero point, you waste one bit (because the sign is unused). If the world bounding box is far away from zero however, you do it very wrong: The larger the distance, the bore bits get wasted for nothing.

So you should have your origin close at (0,0,0) in any case. I'm no floating point expert, but it is said the best precision is between -1 and 1, so you should also use a scale that makes sense here, e.g. 1unit = 1meter for FPS or 1unit = 100meter for large open world. (for very large open world like space game you may need even need to translate the whole world so the player is at the center to avoid  precision issues).

... not sure how this affects your graphics issues, but you can try out various scales and center offsets.

 

 

 

Thanks Joe. I think that explains my problem (and solution) perfectly.

Sorry a couple more questions.

How is reversing the depth generally done? Can i literally just set my cameras far/near in reverse (for the projection matrix) when rendering everything (including models to shadow map)? Do i need to do something different with storing the depth in the buffer? I'm just writing out z/w for everything right now (except linear for mist particles)

This topic is closed to new replies.

Advertisement