Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shared stencil buffer between framebuffers?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 ZBethel   Members   -  Reputation: 544

Like
0Likes
Like

Posted 17 March 2013 - 07:53 PM

I'm writing a game where I need to apply a gaussian blur to parts of the scene. I've created an FBO with a depth-stencil buffer attached, and I'm rendering my scene to that buffer. I would like to set the stencil buffer to 1 for any fragment that requires blur, so my rendering queue has logic to set/unset that based on the requirements of the renderable. There are only a few sprites that are being blurred.

 

I'm trying to wrap my head around how OpenGL handles frame buffers with attached render buffers and all that. Is there a way I can share the stencil buffer across a couple frame buffer objects as well as my back buffer? Ideally, I would like to render everything into one scratch FBO (while doing stencil writes), and then render a first gaussian pass into the second FBO ignoring fragments not flagged by the stencil buffer. Finally, I'd like to render the second pass into the main framebuffer (also with stencil testing enabled).

 

Is this possible? I'm not quite understanding how OpenGL interprets which stencil buffer to use. I assume anytime I'm calling glStencilFunc, it's acting on the currently bound framebuffer object. In that case, do I need to somehow grab the default stencil buffer and attach it to my scratch FBOs?

 

Thanks!



Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 5906

Like
0Likes
Like

Posted 18 March 2013 - 02:59 AM

You typically use multiple buffers at once, most likely a depth_stencil and at least a color buffer. Therefor you can change the color buffer while keeping the depth_stencil buffer:

// render color buffer
color_0 = my_color_buffer;
depth_stencil = my_depth_stencil_buffer;

// bur pass
source_buffer in shader: my_color_buffer
color_0 = my_blurred_buffer;
depth_stencil = my_depth_stencil_buffer;

// apply blurred buffer to target buffer
source_buffer in shader: my_blurred_buffer;
color_0 = my_color_buffer;
depth_stencil = my_depth_stencil_buffer;






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS