Sign in to follow this  

Two values in depth buffert?

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

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