Jump to content
  • Advertisement
Sign in to follow this  
LordDS

Two values in depth buffert?

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

I am writing a pixel shader (Direct X) and I wonder if there is any way to store two values in the depth-map (I already store 4 values in the color-output already) and I want to store 5 values for a special-effect and have a normal functioning Z-buffer at the same time. I've been thinking about using about a 32-bit depth buffer where I use about 24-bit for depth-values and 8-bits for an additional value ( will be in the range 0.0 - 1.0 ). Later I'm going to use the values depth and colormap for the effect. Can anybody help me here? Shall I try to store the value as the fraction part and the depth value as interger part. Should I try something like the following? depth = (floor)(dept*something) + value; and later value = frac( depth ) depth -= value dept/something

Share this post


Link to post
Share on other sites
Advertisement
Look into stencil buffers. It might be what you want. Although I'm not sure if you can access it from shaders or not.

Share this post


Link to post
Share on other sites
There are two problems:

1. You can't write a specific value into the depth buffer. The values are transformed to and from an internal representation and may change (perhaps only slightly).

2. The hardware uses the depth buffer, of course. The non-depth data can't be ignored and is likely to cause problems.

Share this post


Link to post
Share on other sites
The stencil buffer may indeed be what you want, but if not, try using multiple render targets. If all you're looking to do is increase the space you have for data output, you can create a regular colour render target and write to it using the additional colour outputs in the pixel shader. That'd save you from any crazyness like packing/unpacking values or things like NVidia hardware shadow buffers.

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!