Sign in to follow this  

Depth buffer access from Pixel Shader DirectX

This topic is 2851 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've been working on shadow maps and I want to improve it so that textures with alpha channel would cast partial shadow (for example texture with leaves of tree). The problem is that Pixel Shader (which is rendering depth map for shadow mapping) cannot modify depth value of pixel it's processing. It can only return a calculated value (which get to the depth texture) but cannot decide whether this value will be written to the texture or not. I'm using DirectX 9.

Share this post


Link to post
Share on other sites
You can write depth from at least PS2.0. However, you cannot read the depth from the currently bound depth/stencil target - you need to use an intermediate texture to hold previously rendered depth if you need to read depth values altogether in ps.

The intent of your sentences "It can only return a calculated value (which get to the depth texture)" and "cannot decide whether this value will be written to the texture or not" is unclear to me. Please clarify :)

Share this post


Link to post
Share on other sites
I have got texture in which depth values of pixels (from light's view) are stored. These values are computed by pixel shader ( Depth = Pos.z / Pos.w ). If alpha value of pixel's color is 0, then it should not cast any shadow, so Pixel Shader should not write any value to the texture. The problem is that Pixel Shader have to return something. I tried to write a value of maximum depth (1.0f) but when there is some value in the texture, then this current value will be overwritten by 1.0f value. It causes that some objects don't cast shadow.

Sorry for my english.

Share this post


Link to post
Share on other sites

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