Skip to main content
GameDev.net gamedev.net
🔒 Locked

Shadow Map problem

Started by lpm_jacky Jan 20, 2011 at 6:11 PM 7 replies 2.8k views
Original Post
lpm_jacky
lpm_jacky
Hi all,
I have a problem in traditional shadow map rendering. The only difference that I did is I use shader to perform shadow mapping. However, the rendering result is not good.
Does anyone know what's happen? And how to solve it?
Jacky

[attachment=1104:shadowmapproblem.png]
Murdocki
Murdocki
you probably need to add a tiny bias to your depth-comparisation check. float precision makes your distance calculation almost represent the same numbers in both the shadow map and while using it but it isn't precise enough to catch this error.

watch out with making your bias too big tho, if you feel like you need to you might want to use front face culling.
lpm_jacky
lpm_jacky
I am wondering the precision of depth map generated in light space. It seems to me that the precision is far below single precision.
I am currently using NVidia GTX470 and I don't know whether this card needs to enable something explicitly in order to use single precision calculation (I know its non-sense).
Does anyone have another ideas since I have tried to use a number of bias values to improve the rendering quality, but doesn't help so much.
Geometrian
Geometrian
precision makes your distance calculation almost represent the same numbers in both the shadow map and while using it but it isn't precise enough to catch this error.
Precision is absolutely a part of this. However, more importantly is the quantization of the shadowmap. When a depthmap is rendered, the texels' depths correspond to the depth of the scene at the center of the texel. Because the texture does not have infinite resolution, if the shadowmap image plane is at all at an angle to the receiving geometry, there will be problems.

You are correct; you do fix this with an offset and/or by culling front-facing geometry in the shadowmap pass. In OpenGL, I believe the command you're looking for is glPolygonOffset(...). Note that you'll need to enable GL_POLYGON_OFFSET too. If you're using a shader, add a small epsilon to your depthmap sample.

-G
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]
lpm_jacky
lpm_jacky
Thanks. I got your points and the rendering results are better. By the way, it would have problem when the object is an planner object with small grazing angle. To relieve this problem, N dot L could be used.
Jacky
lpm_jacky
lpm_jacky
Candy, yeah!
[attachment=1113:shadowmapproblemsolved.png]
Murdocki
Murdocki
yay eyecandy \o/ looking good
lpm_jacky
lpm_jacky
By the way, any approaches that can improve the quality of shadow map when the lighting is at small grazing angle of a surface element?
Or any approaches which could relieve the precision problem of depth map for shadow mapping?
Murdocki
Murdocki
I dont really get what you mean by improving quality of shadowmap when lighting is a small grazing angle but asuming you're talking about
the peter-panning problem, for me this was almost fixed (for everything but terrain) using the forementioned front face culling as this allows
you to make the depth bias really small.

About the precision problem you should take a look at optimal shadowmap distribution. In short this changes the light's frustum
to fit really tight around the camera's frustum. This makes sure you're not wasting any precision on parts of your scene that cant
be seen anyway. (be aware of occluders between light and camera frustum though, you dont want to drop those shadows). You could
also increase the bits-per-fragment of your depthbuffer but yeah that can only be done up to some point ofcourse. For a more
fundamental change you could take a look at cascaded shadow maps or parallel split shadow maps. While these dont really
increase the precision of your depthmap they're making the precision less of a problem because less precision is needed
for smaller sections of the scene.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.