Fabian
Fabian

Reputation: 2000

How can I apply a fragment shader to every pixel?

I have some transparent decals rendered into a separate framebuffer. Now I'm trying to blend this buffer with the back buffer (active target).

I'm assuming that I have to load the color buffer of the fbo as a texture in a fragment shader and output the texture color to the active target. How can I tell the graphics card to do this operation for every pixel?

Upvotes: 1

Views: 963

Answers (2)

fen
fen

Reputation: 10115

my code for the fullscreen rectangle/quad this is old method - from OpenGL 1.1, but works :) For new OpenGL 3.* you have to use VBO/Arrays

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

glBegin(GL_QUADS);
glTexCoord2f( 0,0 );
glVertex3d( -1.0,-1.0, 0 );
glTexCoord2f( 1,0 );
glVertex3d(  1.0,-1.0, 0 );
glTexCoord2f( 1,1 );
glVertex3d(  1.0, 1.0, 0 );
glTexCoord2f( 0,1 );
glVertex3d( -1.0, 1.0, 0 );
glEnd();

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

of course you have to setup textures before

Upvotes: 2

jcoder
jcoder

Reputation: 30035

Draw a quad or two triangles that cover the whole screen.

Upvotes: 3

Related Questions