Sign in to follow this  

problem with creating shadow map

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

This topic is 4105 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.

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