Jump to content
  • Advertisement
Sign in to follow this  
Tleety

OpenGL Pixelated area on stencil buffer

This topic is 986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i'm trying to archive an effect where i have an area of the screen that will be lower resolution to the rest. And i just wanna ask if my thinking is right.

 

I have 2 FBO's, they each share the same renderBuffer, so i can use the same stencil to both. but have a different resolution on the texture i draw the scene to.

 

My draw loop looks somthing like this:

Attach the full resolution FBO
Clear depth and stencil.
Draw the scene in full resolution.
Draw to stencil buffer the area that will be pixelated
Attach the FBO with low res texture
Clear depth
See if the stencil is equal to 1 and if so draw to the low res texture:
    state->StencilFunc(GL_EQUAL, 1, 0xFF);
Draw the scene again but this time to the low res texture.
Later i combine the 2 textures and then have a pixelated area on the screen in the shape of my stencil.

I have some concerns about this.

First it feels like there should be a better way to do this that does not require drawing the scene twice.

Second i don't actually know if i can use the same RenderBuffer on 2 different FBO's in the way I'm thinking.

 

I have implemented my solution, but it is currently not working, so i just wanna know if this way is possible, or if there is a better way to implement this since i'm quite new to OpenGL.

 

What I'm currently getting working is using the stencil and hiding objects that are behind it, but i'm not able to get the second part, where i'm drawing to the LowRes texture, it always come out black.

If you want to look on my code I'm happy to provide any samples needed. 

Share this post


Link to post
Share on other sites
Advertisement

Since you are using a renderbuffer that I'm assuming is the size of your the larger resolution texture. Then whenever you bind the FBO with the lower resolution texture you have to change the viewport and possible scissor area to match, the area that was stenciled out.

Share this post


Link to post
Share on other sites

Since you are using a renderbuffer that I'm assuming is the size of your the larger resolution texture. Then whenever you bind the FBO with the lower resolution texture you have to change the viewport and possible scissor area to match, the area that was stenciled out.

Ah, that makes sense, i got the rendering to the second FBO working last night, but there was some obvious problem with what it chose to render, but it's probably as you said with the viewport, I'm going to implement that and see if it works :)

Share this post


Link to post
Share on other sites

So, I've been trying to get this working. I can get it working with 2 separate Renderbuffers, and the Viewport/scissor works as i expect, but when I'm trying it with the same renderbuffer for both FBO's, i cant get the viewports/scissor to get the right proportions.

 

Right now i have one FBO with 1920x1080 RenderBuffer, and 1920x1080 textures, and another FBO with the same RenderBuffer bound, but the textures are 480x270.

Can i make the renderbuffer (Depth+stencil) a texture instead? Will this help me solve the problem, or is it possible to do with renderbuffers, im just doing my viewports incorrectly?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!