Advertisement Jump to content


This topic is now archived and is closed to further replies.


Decals in engines

This topic is 5484 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

I think i need some serious help with Decal rendering techniques. Right now, i have a world loaded in my engine, which is basically nothing but a huge triangle soup which has been "Octree-ed" upon. Now.... what i want to do is... if i shoot in my world.. i want some decal to be put on the triangles. I have already implemented the general ray-tracing routines to find out the closest triangle been hit within the Octree Nodes. 1. But a wall might have several triangles.. (usually two) and if i just trace a ray and then put a decal on the triangle that the ray hits, the decal might be clipped somewhere at the middle of the wall ( where the two triangles meet). 2. Some triangles have alpha masking... how do i handle those triangles and only render the part of the decal which falls in places where the alpha values are , say, above 0.5 or soemthing. 3. Which technqiue do you reckon is better.... a. Rendering decals by drawing a quad and then clipping at the edges of the triangle b. Or rendering the triangle again with the decal texture enabled and with new texture coordinate calculated for it Can we please have a thorough discussion on how to implement decals in Game Engines... NOT JUST A DEMO

Share this post

Link to post
Share on other sites
I do the ''redraw triangles'' approach, as I have small triangles, and don''t really have geometry that is modelled with alpha test.

I would recommend creating a mini-frustum from your decal. Your decal makes up the near plane of the frustum. Define some distance at which your decal will fade away. This is your distance from the near to far plane.

There is fast code to test AABB vs frustum that you can use to quickly pass your frustum down the octtree to find all triangles intersecting the frustum. Go through these tris and throw away those facing away from the frustum''s near plane normal ( the direction you shot ).

Save this list of front-facing tris in a list until your decal fades away.

Share this post

Link to post
Share on other sites
I recommend clipping against each polygon affected by the decal individually and building a new triangle list for the decal itself. Then render it with some kind of polygon depth offset. You''ll have to write some kind of routine that will find all surfaces in your world that are within a certain radius of the decal''s center.

For decal application, see Mathematics for 3D Game Programming and Computer Graphics, Section 9.2. For a depth offset technique, see Section 9.1.

The decal clipping technique is also described in Game Programming Gems 2, Section 4.8.

Share this post

Link to post
Share on other sites

  • 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!