The Most Basic GLSL problem (possibly ever)

Started by
4 comments, last by V-man 15 years, 9 months ago
Hey guys, i have been writing some shaders, doing some blur things, separating bright colours from a texture into another texture. I am using FBOs and i am wondering if there is a simple way of taking the colour i am drawing into the fragment shader and out the other side int a colour attachment. I want to do this so i can initiate my fragment shader, draw to the screen and the original image goes in one colour attachment and then the bright colours go into another colour attachment on the same FBO. I wonder if that makes sense... But yeah i want to save myself an extra render by killing two birds with one stone, but so far i haven't been able to take what i am drawing through a fragment shader without making any alterations... This is probably simpler than i am explaining it... help plz :(
Advertisement
Sounds like you need the ARB_draw_buffers extension. Although you'll need 2 colour buffers on one FBO (AFAIK you can't render to the screen and an FBO in one go).

Regards
elFarto
yeah thats what i meant, draw to two colour buffers in on FBO, i will check out that extension, thank you
K i think i know what has happened hear :P
I wasn't very clear and i rambled, what i actually need is some GLSL
code, i have tried something like this

main()
{
gl_Position = ftrsanform():
}

main()
{
gl_FragColor = gl_Color;
}

but all i get it a black screen, what i really want is
something like this

Turn on shader
Turn on FBO with tex1 attached
DrawModels
Turn off FBO
Draw a tex1 that contains exactly what
i would have had if i just drew the models
to the screen.
Sounds like you just need to render a fullscreen quad with tex1 applied.

Regards
elFarto
//Fragment shader
gl_FragColor = gl_Color;


In this case, gl_Color is not setup. You need to write to gl_FrontColor or something like in the vertex shader. I think the code looks like
gl_FrontColor = gl_Color;
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