Hi,
I'm using OpenGL FBO's to render into. I used to just use a depth
renderbuffer, and if multisampled I used this (which works):
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT,samples,GL_DEPTH24_STENCIL8_EXT,width,height);
My goal is to make the depthbuffer available as a texture in
postprocessing Cg shaders. So I have to rewrite the above to use
textures. Not using multisampling I use this (which also works):
// Create texture
glGenTextures(1,&texDepth);
glBindTexture(GL_TEXTURE_2D,texDepth);
if(flags&CREATE_STENCIL_BUFFER)
{
// Depth+stencil packed
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, width,
height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
} else
{
// Just depth
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width,
height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
}
glTexParameterf(...);
// And attach it to the FBO so depth renders into this texture
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texDepth, 0);
if(flags&CREATE_STENCIL_BUFFER)
{
// Add stencil as well
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, texDepth, 0);
}
However, when trying to multisample, I get a black screen. Should I use
glTexImage2DMultiSample() or something? Anyone knows of a tutorial on
setting up a multisample FBO where the depth buffer is a texture?
(instead of just a renderbuffer)
Thanks,
Ruud
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
|
|
0
|
|
|
|
Reply
|
Ruud
|
1/20/2010 11:48:08 AM |
|
Ruud van Gaal wrote:
> I'm using OpenGL FBO's to render into. I used to just use a depth
> renderbuffer, and if multisampled I used this (which works):
>
> glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT,samples,GL_DEPTH24_STENCIL8_EXT,width,height);
>
> My goal is to make the depthbuffer available as a texture in
> postprocessing Cg shaders. So I have to rewrite the above to use
> textures. Not using multisampling I use this (which also works):
....
> // And attach it to the FBO so depth renders into this texture
> glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
> GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texDepth, 0);
....
> However, when trying to multisample, I get a black screen. Should I use
> glTexImage2DMultiSample() or something?
I've been working on it a bit (beginning to sound like Skybuck! ;-) )
and I made a workaround by using the old renderbuffer approach for the
multi-sample FBO, and only creating textures for the downsampled
(anti-aliased) FBO.
It does mean my blit command now include depth buffer (small performance
hit, 140 vs 128 fps):
glBlitFramebufferEXT(0,0,width,height,0,0,width,height,GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT,GL_NEAREST);
Is there a better way to get access to the depth buffer?
Thanks,
Ruud
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
|
|
0
|
|
|
|
Reply
|
Ruud
|
1/20/2010 2:35:38 PM
|
|
On Jan 20, 3:35=A0pm, Ruud van Gaal <r...@racer.nl> wrote:
> glBlitFramebufferEXT(0,0,width,height,0,0,width,height,GL_COLOR_BUFFER_BI=
T|GL_DEPTH_BUFFER_BIT,GL_NEAREST);
>
> Is there a better way to get access to the depth buffer?
>
Probably not. I haven't used the depth buffer like
this but everything I've done with mutisample
buffers needed me to explicitly downsample the buffer
before I could access the contents.
(Which makes sense - the definition of multisample
is multiple values per pixel)
--
<\___/>
/ O O \
\_____/ FTB.
http://www.topaz3d.com/ - New 3D editor for real time simulation
|
|
0
|
|
|
|
Reply
|
fungus
|
1/22/2010 12:46:52 AM
|
|
|
2 Replies
946 Views
(page loaded in 0.054 seconds)
Similiar Articles: Render to depth texture - comp.graphics.api.openglHi, I'm using OpenGL FBO's to render into. I used to just use a depth renderbuffer, and if multisampled I used this (which works): glRenderbuf... still struggling with FBOs and depth texture (for shadow map ...I originally had the depth-texture attachment, but the rendering was not correct. I switched to the renderbuffer depth attachment, with incorrect results again. FBO: depth render buffer objects - comp.graphics.api.opengl ...still struggling with FBOs and depth texture (for shadow map ... FBO: depth render buffer objects - comp.graphics.api.opengl ... still struggling with FBOs and depth ... Strange Texture Problem - comp.graphics.api.openglRender to depth texture - comp.graphics.api.opengl Strange Texture Problem - comp.graphics.api.opengl Strange, that the render-to-texture using FBO works fine without such ... FBO and reading with glReadPixels - comp.graphics.api.opengl ...Render to depth texture - comp.graphics.api.opengl FBO and reading with glReadPixels - comp.graphics.api.opengl ... I don't want to use the render image as texture, so is ... Write Depth Map to Depth buffer - comp.graphics.api.opengl ...Render to depth texture - comp.graphics.api.opengl Write Depth Map to Depth buffer - comp.graphics.api.opengl ... Render to depth texture - comp.graphics.api.opengl Write ... renderbuffer objects - comp.graphics.api.openglYou can use the ARB_depth_texture extension > to get a texture format capable of holding depth values. To render the > texture (not 'to the texture', to prevent ... Textures and alpha masking - comp.graphics.api.openglYou can't erase the stuff you once render with a texture containing alpha. ... depth mask ... the polygon alpha ... control the transparency depth of any texture's ... how to render to metafile? - comp.graphics.api.openglIs it possible to render OpenGL calls directly to a MS metafile? I ... Hi, I am relatively new to opengl. I am trying to use 2D texture and 3D texture for volume rendering ... Rendering to shadow map with alpha testing on ATI cards - comp ...still struggling with FBOs and depth texture (for shadow map ... After rendering to the depth buffer, I tested the result using ... Rendering to shadow map with alpha ... Creating a Depth Texture - Microsoft Corporation: Software ...Demonstrates how to create a texture that contains depth information for a scene using a render target and a custom effect. To render a depth texture, also called a ... How To: Create a Depth Texture - Microsoft Corporation: Software ...In your game's LoadContent method, create a new RenderTarget2D for rendering the depth in your scene. You may want to choose a surface format that gives you the ... 7/23/2012 6:46:13 AM
|