Sign in to follow this  
Niddles

Framebuffer Objects and GLSL

Recommended Posts

Hello. The past couple of days I have been looking at GLSL and how everything associated with it works. I came to the conclusion that I should have different shader programs that I can use as I do multiple passes on a framebuffer object. I have been looking at fbo's and much to my demise, I can not figure out how to work the things. I thought you draw to the framebuffer, and then tell GL which buffer I should draw. What is the syntax to do this, as all I can find on the internet is ways to use FBO's to draw to textures. Or is that the way to do it? You render an FBO to a texture and then just draw the texture to the screen. I am really confused about all of this framebuffer object nonsense, or whether this is the right way to do my shaders for my program. I want to be able to manage my shaders like this, because of the way I have my rendering scenegraph set up. I can just add shader objects as a renderable component, and render them separately as I run down the scenegraph. Maybe I am completely missing the point of both of these?

Share this post


Link to post
Share on other sites
Hmph, maybe I have a big misunderstanding how multi-pass rendering works. I thought you had to do your passes offscreen in a fbo that you have created, and then render that to the screen. How would I do multi-passes rendering directly? Also, how much will this slow the system down? Is this the best way to go about using multiple shaders?

Share this post


Link to post
Share on other sites
How to do multipass?

glDepthFunc(GL_LEQUAL);

Pass 1:
RenderCube_with_light_1
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); this does additive blending

Pass 2:
RenderCube_with_light_2

Pass 3:
RenderCube_with_light_3
glDisable(GL_BLEND);

SwapBuffers();

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this