Light Volume

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 );

		...
		...
		...

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.

yes, perhaps a more complete example is in order…

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… :frowning:

That’s why any help would be appreciated! :slight_smile:

How the artifact looks like? You can use the GLIntercept to check if the stencil buffer contains expected content.

Light volumes are kindof same as shadow volumes but handled differently.
You using stencil pass or fail method?