Skip to main content
GameDev.net gamedev.net
🔒 Locked

Depth vs. alpha

Started by bensta00 Jan 23, 2005 at 10:12 AM 1 replies 750+ views
Original Post
bensta00
bensta00
Hi, I'm doing a calculation and storing the result in the depth component using a Cg shader, however from what I can tell, when I use a pBuffer for this it doesn't keep the depth value I allocate in the texture I am using in the GL view, so I tried storing the result in the alpha component instead, then using another Cg shader I give this value to the depth component. From what I can see there seems to be a loss of precision. Could this be the case? I am setting my pBuffer and OpenGL view to be 32 bit. I assumed that the alpha component and the depth component would be of equal precision. Thanks, Ben.
Kalidor
Kalidor
Alpha is just another color channel, so for a 32bit color buffer, it's an 8bit alpha. However you could use a floating point buffer to get 16 or 32 bits for alpha, but for now those are much slower than regular buffers.

EDIT: As an addition to that, if you don't need the other color channels you could pack the depth value into them or use a 1 channel floating point buffer where the red channel is 32bits. But from what you said it seems like you do need the color channels.

And just to be sure, you are creating the pbuffer with a depth buffer, correct?
bensta00
bensta00
Argh, this is really annoying. Yeh the PBuffer has a depth buffer, but when I set the pBuffer to a texture, the texture's depth values have been wiped.

I can't set the pBuffer to be more than 32-bit. So I tried setting the depth to be 8-bit, so should be the same as the alpha component, but still I get different results!

And unfortunately I need the colour values too.

I think I must have made a silly mistake somewhere.

Thanks for the response

Ben

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.