Jump to content
  • Advertisement
Sign in to follow this  
csisy

shadow map problem

This topic is 3162 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

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!