PDA

View Full Version : Light Volume



bobGL
02-23-2008, 06:05 PM
Im playing around will light volume and they look great... the only thing is I can't get rid of a 1px (or something) artifact around it... Im sure it comes from my stencil test code... I try to fiddle with it but can't get rid of these artifacts... does anyone have an idea??? or can point me a better technique than the one Im using? tks in advance!



...
...
...

glDepthMask( GL_FALSE );

glColorMask( GL_FALSE,
GL_FALSE,
GL_FALSE,
GL_FALSE );

glEnable( GL_DEPTH_TEST );
glEnable( GL_STENCIL_TEST );

glClearStencil( 0 );
glClear( GL_STENCIL_BUFFER_BIT );
glEnable( GL_CULL_FACE );



glCullFace( GL_FRONT );
glDepthFunc( GL_GREATER );
glStencilFunc( GL_ALWAYS, 1, 1 );
glStencilOp( GL_KEEP, GL_REPLACE, GL_KEEP );

render_light_volume( tmp );



glCullFace( GL_BACK );
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );

render_light_volume( tmp );



glColorMask( GL_TRUE,
GL_TRUE,
GL_TRUE,
GL_TRUE );

glDepthFunc( GL_ALWAYS );
glStencilFunc( GL_NOTEQUAL, 1, 1 );
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );

glDisable( GL_CULL_FACE );

render_light_volume( tmp );

glEnable( GL_CULL_FACE );
glDisable( GL_STENCIL_TEST );
glCullFace( GL_BACK );
glDepthFunc( GL_LEQUAL );
glDepthMask( GL_TRUE );

...
...
...

Komat
02-24-2008, 12:03 PM
What exactly is that code supposed to do? Most code which marks something within the stencil (whether it is a shadow volume or pixels influenced by the light) uses the GL_INCR and GL_DECR stencil operations.

Brolingstanz
02-24-2008, 02:55 PM
yes, perhaps a more complete example is in order..

bobGL
02-24-2008, 03:31 PM
Im implementing the example of deferred shading example of the more opengl programming book... however Im trying to tweak it a little cuz I think their approach is a bit too generic... I make the whole thing work except that artifact on the light volume that I can seems to be capable to fix... :(

That's why any help would be appreciated! :)

Komat
02-24-2008, 05:24 PM
How the artifact looks like? You can use the GLIntercept to check if the stencil buffer contains expected content.

_NK47
03-02-2008, 03:08 PM
Light volumes are kindof same as shadow volumes but handled differently.
You using stencil pass or fail method?