Jump to content
  • Advertisement
Sign in to follow this  
sunrisefe

depth value to texture

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

If there are 4 kind of objects in Z direction, object1.z < object2.z < object3.z < object4.z, and object1 object2 are semi-transparent while object 3 and object4 are un-transparent. Is there any method to write the z value of visible objects to one texture (which is as render target), e.g. texture.r = object1.z texture.g = object2.z texture.b = object3.z ?

Share this post


Link to post
Share on other sites
Advertisement
The only information that's available is the current Z-value for each pixel, and if you're running in a pixel shader, the Z-value for the pixel being written. The depth buffer doesn't have any concept of objects, just a per-pixel depth value.

What exactly are you trying to do? We might be able to help you accomplish it in another way.

Share this post


Link to post
Share on other sites
Thank you very much.
What I want to do is that: when we use shadow map,it only possible to render shadow of untransparent objects. So I wonder how to render the shadow of the scene with both semi-transparent objects and untransparent objects. I want to write the z of every pixel that we can see finally to shadow texture, in order to render the semi-transparent shadow and black shadow.

Share this post


Link to post
Share on other sites
You could easily use D3DRS_COLORWRITEENABLEn to mask off the channels you don't want to write to. Handling multiple overlapping transparent objects won't be so easy though, as you can't easily read the render target to work out which channel is already written. You could do the overlap calculations on the CPU though.

You may also need to use a special pixel shader that avoids writing out the depth for pixels that are fully transparent.

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!