View Full Version : Decaling with Stencil (Programming with OpenGL: Advanced Rendering )
01-08-2002, 09:25 AM
... er... Hi "Guys"
when a fragment passes the stencil test, glStencilFunc() isn't the fragment written to the color buffer (granted that it passes the remaining tests)?...
If that is the case, why is the decal polygon set to pass the stencil test in step (5) [ glStencilFunc(GL_EQUAL, 1, 1 ) ] of Programming with OpenGL: Advanced Rendering (http://www.sgi.com/software/opengl/advanced96/node31.html)
01-08-2002, 10:14 AM
... Funny I should be the one replying my own question!
Well ... I tried it out, and it appears I was right! step 5 should be glStencilFunc(GL_NOTEQUAL, 0xFF, 0xFF); Besides, steps 6 [ glStencilMask(GL_FALSE) ] and 7 [ glDisable(GL_DEPTH_TEST) ] do not appear necessary! ...
My example consisted of a small RED polygon on the plane z = 0, and a larger BLUE plane on the plane z = 1. I used the stencil buffer (in the manner described above) to unmask the RED polygon ...
01-08-2002, 10:38 AM
I don't remember this example exactly, but you probably do want to disable the depth tests and stencil masks when you are decaling on a surface using stencil. You want to disable the depth test to help avoid Z fighting. Float imprecision will kill you here. As for the stencil, the general thought is that some of the decals might overlap, so changing the stencil value might cause some of the decals to not draw properly.
Isn't faster and easyer to do polygon offset instead of using stenciling for Decaling ??
I'm quite sure about it.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.