Jump to content
  • Advertisement
Sign in to follow this  
ehsan_the_tiamat

problem with creating shadow map

This topic is 4356 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 my code :
struct VS_OUTPUT_DEPTH_MAP
{
    float4 position  : POSITION;
    float  depth     : TEXCOORD0;
};
VS_OUTPUT_DEPTH_MAP depthMap_VS( float4 inPosition : POSITION )
{
    VS_OUTPUT_DEPTH_MAP output = (VS_OUTPUT_DEPTH_MAP)0;
    output.position = mul( inPosition, lightViewProjection );
    output.depth = output.position.z;

    return output;
}

float4 depthMap_PS( VS_OUTPUT_DEPTH_MAP In ) : COLOR0
{
    float depth = In.depth;
    return float4(depth, depth, depth, 1.0f);
}


the problem is in the shadow map i generate, all geometries are white except the back buffer. and it means every pixel in that geometry has equal Z??!!! how is that possible???? (for example a sphere which is all white) here is how i created my shadow map texture :
	hr = D3DXCreateTexture(g_pd3dDevice,
		512,
		512,
		1,
		D3DUSAGE_RENDERTARGET,
		D3DFMT_R32F,
		D3DPOOL_DEFAULT,
		&g_pDynamicDepthMap);


THX in advance [Edited by - ehsan_the_tiamat on September 15, 2006 2:06:50 PM]

Share this post


Link to post
Share on other sites
Advertisement
Everything is green because all depth values are greater than 1.0. When rendering float textures directly to the screen, values greater than 1.0 are clamped.

If you want to visualize the depth, you'll need to divide the output.position.z by some scale value (usually the distance between your near and far planes).

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!