3
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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 :)

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ It's the player that places it by shooting, so nothing can prevent the player from shooting at the edges or curved areas \$\endgroup\$ – Vadim Tatarnikov May 10 '16 at 13:24
  • \$\begingroup\$ I understand. But like I say it can work only in some circumstances. In my circumstance there was an explosive effect which helped cover up the decal. And also it needed re positioned only occasionally.Cant get away with it always though. \$\endgroup\$ – RobM May 10 '16 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.