Knife scratch and bullet holes in CSS

Started by
14 comments, last by Willbo 19 years, 6 months ago
Quote:Any suggestions on easy ways to clip the decals? Or to bend them around corners where they lay on multiple faces?


The best reference I know of on this is Eric Lengyel's article 'Applying Decals to Arbitrary Surfaces' in GPG2. The book also comes with code for the implementation on a CD. My decal system is based on this method, and it works great.

The basic idea is as follows. You construct the decal from an intersection point (i.e. where a bullet hits) and the surface normal at that point. From this info you create a rectangular volume centered on the intersection point and aligned with the normal. The width and height of the volume are the desired width and height of the decal, and the depth is chosen as appropriate to include the appropriate polygons.

Then what you do is take each surface that intersects this volume, and add its triangles to the decal one by one. As the triangles are added, they are clipped to the volume so that only the portions inside the volume remain.

What you are left with is a decal surface that perfectly follows the contour of the surfaces it affects. You can then use the z-tweaking method of your choice to avoid z-fighting.

The implementation is a little involved, but it's not too bad. If you don't have GPG2, I highly recommend picking it up for the source code if nothing else.
Advertisement
Quote:Original post by jyk
... Smart stuff...


So is this a multi-texturing effect rather than a texture mapped quad?
Quote:So is this a multi-texturing effect rather than a texture mapped quad?


If you're refering to the Lengyel method, no, it doesn't use multitexturing. Multitexturing would require that the exact input tris be used, but in this case the tris must be clipped to get the right results.

Also, it's only a quad in the simplest case, i.e. a flat surface with no clipping. In the general case, it's a mesh of tris that maps to the underlying surface.

Not sure if I answered your question, though...
Maybe a good idea to check for the 3 closest point on the 3 triangle-edges, if a point lies in the bullet-hole area then check which triangle shares the same edge, where the point was on, and put another decal on that point facing it to the normal of that triangle. should work too
To get stuff on to multiple surfaces you clip the decal to each of the multiple surfaces. You can see Quake 3 doing this with triangle outlining on (/r_showtris 1), I'm sure there are similar commands for other games. There's a tutorial on decals over at flipcode, although the links to the example images and the source code are unfortunately broken.
-- Jonathan
Quote:Original post by Cypher19
One thing I'd like to see though, is on metallic materials, have a decal that isn't just a black dot but is a normal map showing an indentation, so that the bullet dent is seen with just bump mapping and specular lights.


Actually, what i'd like to see is decals with bumpmapping+parallax mapping, so they would have depth, and actually look like a hole.
Should be coded just like a regular decal, but with a nice shader.
I wonder if anyone has tried that yet... there were talks of "geometry decals" a while ago to carve smallish holes in walls, but parallax makes it much simpler.
Working on a fully self-funded project

This topic is closed to new replies.

Advertisement