PDA

View Full Version : Can depth value be rendered into texture (Solved)



shapeare
09-22-2011, 05:59 AM
I found an article through this link:
OpenGL Framebuffer tutorial (http://www.gamedev.net/page/resources/_//feature/fprogramming/opengl-frame-buffer-object-101-r2331)

there is a sentence says "A renderbuffer are just objects which are used to support offscreen rendering, often for sections of the framebuffer which donít have a texture format associated with them such as the stencil or depth buffer."

Why framebuffer does not have a texture format associated with depth buffer? Does this mean I cannot render depth to texture directly using a framebuffer?

overlay
09-22-2011, 08:13 AM
Yes you can attach a texture object (TO) as the depth buffer of an FBO.

Depending on the generation/capabilities of the OpenGL implementation () on your system, it might be possible or not.

Look at this other tutorial, it does not say there is such restriction: http://www.songho.ca/opengl/gl_fbo.html

Same for the OpenGL spec: http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf section 4.4 page 319.


You can use attach a TO to the depth buffer of an FBO to bake a shadow map, for example.

Alfonse Reinheart
09-22-2011, 11:33 AM
That tutorial quote was misleading. The idea for renderbuffers is this.

Let's say you want to render to a texture. But you probably also want a depth buffer and maybe a stencil buffer too. You could create a texture with such formats and attach that to the FBO, but some implementations don't support some combinations of depth and stencil buffers. Also, using a texture for something like that is overkill. So you can use a renderbuffer with those formats instead.