Skip to main content
gamedev.net
🔒 Locked

Decals

Started by r691175002 4 replies 6k views
Original Post
r691175002
r691175002
I'm finding it hard to track down easy ways of applying decals to arbitrary surfaces. Things like scorch marks, footprints, tire treads and bullet holes. Are there any specific techniques that are used for decals or papers on the subject?
Tenac
Tenac
There's this, the images and download link may not work since it is very old but it's still useful and explains how it works pretty well:
http://www.flipcode.com/archives/Decals_Explained.shtml
Sphet
Sphet
Hey there.

The best resource for decal application I have read is in Game Gems 3. It describes a system that works like this:

For a given decal, consider a point, the center of the decal, and a tangent and binormal, describing the orientation of the decal. Given the tangent and binormal, as well as a width and length of the decal, create four planes that bound the decal's edges. Add two more planes based on the 'thickness' of the decal.

Take all the triangles in the world and clip them against the planes. Use all the best algorithmic optimizations to cut down the number of triangles - in our engine we use an AABB that approximates the decal combined with a KD-Tree overtop of the triangles. For each triangle, clip it against each plane. The article outlines doing this with the sutherland-hodgeman clipper, which works great. The sutherland-hodgeman clipper is a generalized polygon clipper and it generates a resulting polygon that, because of clipping inside a box, yields a convex polygon which can be triangulated into a collection of triangles.

The resulting triangles are then mapped using planar mapping which bases the UV on how far from the origin the point is.

The cost of this system is the clipping, which is only done once when the decal is created. After creation the decal can be saved frame to frame and rendered at little cost.

The secret is the sutherland-hodgeman clipper:

here's a java sample:

http://www.cc.gatech.edu/classes/AY2003/cs4451a_fall/ClippingApplets%20Folder/Sutherland-Hodgeman/index.html


here's wikipedia:

http://en.wikipedia.org/wiki/Sutherland-Hodgeman



The article in GPG3 is really a good place to start - it's called 'Decalling arbitrary surfaces' or some such.


Best of luck

S.
Sphet
Sphet
Quote:
Original post by Eric Lengyel
Quote:
Original post by Sphet
The best resource for decal application I have read is in Game Gems 3.


I believe you mean Game Programming Gems 2, section 4.8.


Eric,

Thanks for the correction. My apologies! I don't have the book here in front of me.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.