Skip to main content
gamedev.net
🔒 Locked

Depth Stencil Buffer

Started by OandO Aug 2, 2011 at 7:00 PM 2 replies 2.2k views
Original Post
OandO
OandO
The latest in a line of buffer-based questions:

I'm trying to set up a 24 bit depth buffer. The total size of the buffer must be 32 bits, and I've found that I can use an internal format of GL_DEPTH24_STENCIL8, but what's the correct value for the "format" argument of glTexImage2D? Should it be GL_DEPTH_COMPONENT? Also, presumably the stencil component can be written to, and isn't purely for packing the remaining space. What's the correct way to write to each component individually using gl_FragData?
johnchapman
johnchapman
Use GL_DEPTH_STENCIL as the 'format; argument, GL_UNSIGNED_INT_24_8 as the 'type' argument.

I'm not sure about writing to the stencil component via gl_FragData (it's deprecated!); enable the stencil test while rendering and use glStencilOp()/glStencilFunc() to determine what gets written to the stencil byte per fragment.

http://www.opengl.org/sdk/docs/man4/
OandO
OandO
Thanks, that makes sense.

My current drivers only have support for GLSL 1.2, so I'm sticking with gl_FragData for the time being at least.
OandO
OandO
Continuation of this question:

I want to be able to linearise the depth values for later use. At the moment I'm rendering the depth straight to a texture (using GL_DEPTH_ATTACHMENT_EXT) which means that it's not affected by any shaders. I\m guessing the solution is probably to output non-linear depth to a renderbuffer, and calculate depth from a vertex shader then draw it into a texture attached to GL_COLOR_ATTACHMENT1_EXT. The problem is finding a format (or some completely different solution) with which I can accomplish this.

Edit: Nevermind, I think I've managed to solve this one myself.

Topic Locked

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

Sign in to reply to this topic.