Decals in engines

Started by
1 comment, last by browny 20 years, 3 months ago
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
Z
Advertisement
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.
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.

This topic is closed to new replies.

Advertisement