shadow map problem

Started by
1 comment, last by csisy 14 years, 1 month ago
Hi, I tried to use the "soft shadow map" sample in my xna app, but I've got a problem. My scene is "stripped". Here is an image: http://yscik.com/jf/datas/users/2044-shadowtest.jpg Here is a code: (should i copy here the hlsl code too?)

//load content
int shadowMapSize = 512;
m_depthTarget = new RenderTarget2D(GraphicsDevice, shadowMapSize, shadowMapSize, 1, SurfaceFormat.Single); //where Single type is a 32(float)bit on red channel

//Render depth pass
GraphicsDevice.SetRenderTarget(0, m_depthTarget);

//here need I clear buffer? color?

m_depth.Begin();
m_depth.CurrentTechnique.Passes[0].Begin();

m_depth.Parameters["worldViewProj"].SetValue(m_lightView * m_lightProjection);

m_depth.CommitChanges();

m_depth.CurrentTechnique.Passes[0].End();
m_depth.End();

DrawModel(m_plane, m_depth); //draw model (mesh, effect)
DrawModel(m_barrel, m_depth);

GraphicsDevice.SetRenderTarget(0, null);

[Edited by - csisy on February 25, 2010 6:47:28 AM]
sorry for my bad english
Advertisement
This is a general problem with shadowmaps, and is usually fixed by biasing. In your shader that renders the shadow map, try adding a small amount (start with around 0.0001 or so) to the depth value until the problem goes away.

Also if you need to post code here, you can use the "code" or "source" tags. See the FAQ.
Quote:Original post by MJP
This is a general problem with shadowmaps, and is usually fixed by biasing. In your shader that renders the shadow map, try adding a small amount (start with around 0.0001 or so) to the depth value until the problem goes away.

Also if you need to post code here, you can use the "code" or "source" tags. See the FAQ.


Yes, I added (first) a small amount (0.0001f), but when I captured the linked image, the bias was 0.1f.

If I changed the bias to 20.0f (!), this is the (bad) solution:
sorry for my bad english

This topic is closed to new replies.

Advertisement