Jump to content
  • Advertisement
Sign in to follow this  
Modestas Andrijauskas

Shadow mapping problems

This topic is 1334 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! Yesterday and today I was thinking where is the problem with lighting and shadows, but today when I disabled lighting I noticed that the problem is with shadow mapping. I've never had this problem before, but here's how it looks:

 

ss02_51_08.png

 

As you can see cube casts good shadow, but it has some self shadowing problems itself, and you can clearly see the same problem with terrain. Why this problem occurs?

Share this post


Link to post
Share on other sites
Advertisement

shadpow map bias whenever you put a shadow fragment in the fragment shader you bias it with a small value that removes self shadowing, i believe that your problem your bias val is not big enough to cover floating point inaccuracies

Share this post


Link to post
Share on other sites

As WiredCat said, applying small bias to shadow map should help a little, but it looks like, you've got no diffuse light.

Adding light should help, becouse you should have low light in places where you can see bias(back faces of meshes from view point of light).

Share this post


Link to post
Share on other sites

additionally you wil have to fix light projection matrix , you could even use two different for terrain and box since they have differnet sizes)

 

(you must find proper z near z far value for both objects) and use that in sahder because with one shadowmap simply box is too small to be properly shaded (flaoting point precision problem)

Share this post


Link to post
Share on other sites

additionally you wil have to fix light projection matrix , you could even use two different for terrain and box since they have differnet sizes)

 

(you must find proper z near z far value for both objects) and use that in sahder because with one shadowmap simply box is too small to be properly shaded (flaoting point precision problem)

I was changing z near and far, but couldn't find proper. 

 

The shadow map should be generated using back-faces.


L. Spiro

I know, and I'm always generating shadow map with back-faces only.

 

I've been reading about cascaded shadow maps and here is a quote from nvidia pdf about cascaded shadow maps:

CSM are usually used for shadows cast by the sun over a large terrain. 

 

So I think I should implement CSM in my game, but couldn't find good tutorial about it. I think I need to make the thing that was explained by MJP in this topic: http://www.gamedev.net/topic/505893-orthographic-projection-for-shadow-mapping/#entry4299499 2nd post, and to make cascaded shadow maps just increase camera z position to create more orthographic projections for further distances, am I correct?

Share this post


Link to post
Share on other sites
1) the most important thing you can do is to make sure the shadowmap projection min/max Z is clamped within the viewable frustum. This hugely increases the useful shadowmap z precision, allowing you to eliminate shadow acne with smaller bias values, which in turn reduces peter panning. (You also need to turn on depth clamping during render)

Any shadow casters closer to the light than the viewable volume are just clamped to minz, since the place the shadow starts isnt visible anyhow. For CPU frustum culling during shadowmap rendering, however, you need to extend only the light frustum used for culling towards the light to catch all shadow casters.

2) you can adjust the bias value based on the surface normal vs light dir incident angle. Steeper angles need higher bias values, while surfaces perpendicular to the light need little bias.

3) if your meshes are wellformed, you can write only backfaces to the shadowmap, avoiding bias problems for any "thick" areas of objects.

4) never consult the shadowmap for surfaces which you calculate are backface to the light.. Since you already know they are in shadow geometrically.

You can see implementations for all these techniques, as well as parallel split shadow maps, in my free educational 3d engine, simplescene.

https://github.com/jeske/SimpleScene

Share this post


Link to post
Share on other sites

I've actually found my problem, but can't remember in what website it was described. The problem is that orthogonal (or not, can't remember) faces should not be lit by light, but they are. There was another problem with lighting, source vector was wrong and after fixing it, now it looks like this: http://s10.postimg.org/7kot0nleh/ss11_01_21.png

 

As you can see there is only like 1-3 triangles that are having problem with shadowing, and for me it looks like they are orthogonal to the directional light. I've found my problem described in stackoverflow http://stackoverflow.com/questions/13371893/shadow-mapping-artifacts-on-thin-wall-orthogonal-to-light In the answer is said to make sure that face is facing the light and do it by checking if dot of normal is greater than epsilon, so I think it's same as checking if face is orthogonal to light. But how I would do that? I can't check if dot of normal is greater than epsilon, because dot function takes 2 parameters and not 1, what should be second parameter?

Edited by Modestas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!