Framebuffer Objects and GLSL

Started by
2 comments, last by V-man 14 years, 10 months ago
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?
Advertisement
If you want to do multipass rendering, then why not render to the screen? Why do you want to do RTT?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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?
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();
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement