Sign in to follow this  
csisy

shadow map problem

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this