Bullet holes on curved surfaces and corners

Bullet holes on curved surfaces and corners

So right now I am making an FPS game where the gun creates bullet holes (plane with texture) on impact, but there is a problem with that, if I shoot at the edge the plane will stick out and also bullet holes will not look proper when I shoot at a curved surface. I know there's at least 2 ways one is shaders and another mesh manipulation, but I could not find any tutorials on how to do it and never understood neither of them. Is anyone able to explain in detail exactly how I would achieve the effect?
Thanks in advance.


Answer 1:

I think unity can use stencil buffer though I never used it, if you are not able to do that I’ll investigate deeper, One way to achieve that is to cut-out pieces of walls using some lowpoly spheres and stencil buffer, then fill that holes with an “hole” 3d model, so ask an artist to make a hole model wich looks like a cone so it can fir in a variety of holes and use normals to orient that hole.

Picture showing my idea

Take a wall corner, if you paint a sphere in the stencil buffer before the wall, and after the wall then you will have a spherical shape carved out, after that you disable stencil buffer and you render in the wall the hole cone (the cone is designed arounr a sphere so that it will always fit any empty space).

the hardest part I think is finding the normal for the shot, the short way would be to do some ray casts around the hitted point to find out if all normals are equals or not, then you average them.

Answer 2:

What I’ve done in the past is to simply not place the decal close to the edge. I know it sounds a bit cheap but its fast simple and can look fine under some circumstances. Just Move the decal in a bit 🙂