Advertisement Jump to content
Sign in to follow this  

3D Decals using stencil

This topic is 4887 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);

glColorMask(1, 1, 1, 1);



glStencilFunc(GL_EQUAL, 1, 1);

glStencilFunc(GL_ALWAYS, 1, 1);

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
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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!