- Home /
Decals on corners
I've tried different approaches to make decals (bullet holes, blood splats, etc.), but performance wise, the best metod seems to be instantiating a plane on the hit point of the surface, be it a prefab plane or a runtime built plane mesh. It's working fine, but now I need to solve the infamous problem of decals around corners of a mesh, so I was wondering if there is an easy way to get this done.
I thought I could just check the hit mesh, and scale the decal plane if its bounds exceeds a corner on a wall, but I couldn't find an easy way to detect a corner on a mesh.
Any suggestions?
@Erik YES there is a fairly simple 90% solution to the corner problem. http://forum.unity3d.com/threads/2562-blood-splatter?p=719943&viewfull=1#post719943
Answer by Anton Petrov · Nov 04, 2010 at 08:47 AM
I have not tried doing it in the Unity yet.
But in games (like Quake) they use procedural meshes for decals. When you have found a face to put decal on you should clip your decal rectangle by target face edges. So your rectangle may become triangluated a bit.
Or you can just ignore decals which do not fit inside the target face entirely.
I was going for the procedural mesh generation, and I got some results so far: the hit triangle is being "duplicated" in a new mesh, along with it's adjacent triangle (right now, just it's opposite one, but I also tried and succeed to generate all it's adjacent triangles, sharing vertices with it). Now I just need a way to "complete" the missing triangles to end up with quads.
I am not sure I understood you right, but it looks like you build a decal mesh from target triangles.
And I suggest you to clip your rectangular decal with target face edges. Where target face is a polygon made of adjacent coplanar triangles for$$anonymous$$g for example a wall.
Good luck!
Yes, that's exactly what I did. Now the problem was that if the wall being hit was made up of big triangles, the decal quad would be too big in size (since it's generated by a copy of the wall triangles). I tried to Lerp the decal vertices towards the hit point, and it's kinda working, though in this way the decal mesh is awlays dependent on the original triangles being hit, which is not a big deal. I was looking for a better way to generate a square plane for the decal, just making sure it's not going to exceed the wall's boundaries.