Jump to content

  • Log In with Google      Sign In   
  • Create Account


Stencil buffer issues


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 22 October 2013 - 01:22 PM

so i "sort of" figured out my issue with the stencil... http://i.imgur.com/v4abqYA.png
 
the yellow is the stencil rendering of a sphere, so only the pixels it hit are processed by fragment shader
 
The problem is where rendering multiple spheres close to eachother... the stencil setup is slightly incorrect and part of it gets 
 
Any idea what i might need?
 
This is the current setup:
 
        glDepthFunc( GL_LESS );
        glStencilMask( 0xFF );

        glCullFace( GL_FRONT );
        glStencilFunc( GL_ALWAYS, 1, 0xFF );
        glStencilOp( GL_KEEP, GL_REPLACE, GL_KEEP );
        
        renderSpheres();

        glCullFace( GL_BACK );
        glStencilFunc( GL_EQUAL, 1, 0xFF );
        glStencilOp( GL_KEEP, GL_ZERO, GL_REPLACE );

        renderSpheres();

Edited by 3TATUK2, 22 October 2013 - 02:52 PM.


Sponsor:

#2 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 22 October 2013 - 02:59 PM

I fixed it by doing it like this:

        glDepthFunc( GL_LESS );
        glStencilMask( 0xFF );

        glCullFace( GL_FRONT );
        glStencilFunc( GL_ALWAYS, 1, 0xFF );
        glStencilOp( GL_KEEP, GL_REPLACE, GL_KEEP );
        
        renderSpheres();

        glCullFace( GL_BACK );
        glStencilFunc( GL_EQUAL, 1, 0xFF );
        glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );

        renderSpheres();

And then before the third pass which renders the color onto the stencil: glStencilFunc( GL_EQUAL, 2, 0xFF );

 

But, does anyone know how to do this with one pass using glStencelOpSeparate()? I'm having some trouble with figuring that out



#3 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 22 October 2013 - 06:25 PM

Got it

glDisable( GL_CULL_FACE );
glStencilOpSeparate( GL_BACK, GL_ZERO, GL_INCR, GL_ZERO );
glStencilOpSeparate( GL_FRONT, GL_ZERO, GL_ZERO, GL_INCR );
render();
glEnable( GL_CULL_FACE );


#4 TheChubu   Crossbones+   -  Reputation: 4063

Like
0Likes
Like

Posted 22 October 2013 - 08:08 PM

C will crouch!


"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

 

My journals: dustArtemis ECS framework and Making a Terrain Generator





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS