• ### Popular Now

• 15
• 15
• 11
• 9
• 10

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

## Recommended Posts

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
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]

##### Share on other sites
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.

##### Share on other sites
Quote:
 Original post by MJPThis 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: