Jump to content
  • Advertisement
Sign in to follow this  
Eitsch

3D Decals using stencil

This topic is 4674 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

 glColorMask(0, 0, 0, 0);
glStencilFunc(GL_ALWAYS, 1, 1);
glDepthMask(GL_FALSE);

glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT);
drawDecal()
glColorMask(1, 1, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

glDepthMask(GL_TRUE);

glStencilFunc(GL_NOTEQUAL,1,1);
DrawTerrain();


glStencilFunc(GL_EQUAL, 1, 1);
drawDecal()


glStencilFunc(GL_ALWAYS, 1, 1);

drawTheRest();
the problem now. i can see the decal through all the mountains. how could i avoid this effect? i need good performance. thanks [Edited by - Eitsch on September 7, 2005 6:05:04 AM]

Share this post


Link to post
Share on other sites
Advertisement
Well as of right now, this is what you're doing...
Render decal into stencil buffer
Render terrain everywhere except where the decal was rendered in stencil buffer
Render the decal to color buffer
This will clearly always cause holes to appear in your terrain whenever a decal would be rendered to the same spot in screen space as part of your terrain.

What you should be doing for decals is just (very basically) get the polygons where it should be rendered, add decal polygons onto those and render. No need to use the stencil buffer.
There are a decent amount of resources on doing it this way out there. I don't know of any off-hand, but I'm sure [google] does.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!