PDA

View Full Version : Deferred shading - light volume



dylhoxic
07-10-2008, 10:31 AM
I've successfully implemented a deferred shading demos.

I'm trying to optimize it and so I'd like to use light volume.

So for directional light, I use a fullscreen quad like this :

glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);

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

glBegin (GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 0.0f);
glEnd();

// ... restore matrix

Now for a point light, I have got some code to draw a sphere but I'm a bit lost :

Do I need some special texture coordinate or can I just send the vertices and use GLSL for proper lighting ?

Thanks

LangFox
07-13-2008, 07:27 PM
just the vertex of the sphere. It's used to get the screen pos and exclude unnecessary pixel.

dylhoxic
07-14-2008, 12:01 PM
Thanks,

I've just noticed your post about the same subject. This might help me.

Problem:Light volume projection & Deferred Shading (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Main=47178&Number=239063#Post239063)