1

I'm currently working on my FPS game and going to make bullet holes(decals) but google doesn't help me at all. I cannot find the shader or any source that explains how to. If anyone did something like this one please help. Thanks in advance.

Wallstrider
  • 856
  • 1
  • 7
  • 22
  • Can't you simply draw an hole decal texture on the model in the same position that was just hit by a bullet? – pinckerman Nov 10 '13 at 01:18
  • Yes I did but it looks not good when it appears on a complex geometry. Assume I have a spherical model and the bullet hole will not bend around this model properly. It will just appear to the closest point of this model. – Wallstrider Nov 10 '13 at 15:24
  • it looks you need to merge bullet texture to model texture and reload it. but, not sure how this is expensive. – Davor Mlinaric Nov 11 '13 at 07:23
  • I haven't clue how to do it in a code :)) – Wallstrider Nov 11 '13 at 23:16

1 Answers1

1

I take it you are casting a ray when you shoot? This way you can detect where it collides with a wall. If you have not done this, you should start there. When you know where the ray hits the wall you can create a flat plane on top of the geometry with your bullet hole texture on it including a alpha texture.

Madmenyo
  • 8,389
  • 7
  • 52
  • 99
  • Yes I have rays and everything about positions as well. But a plane is not good approach for me because it won't **bend around the models** and look ugly when it will be appearing on the sphere for example. I've found an example of a volume decal shader [here](http://www.humus.name/index.php?page=3D&ID=83) but still not implement it on XNA. – Wallstrider Mar 29 '14 at 09:50
  • That renders the decals on a convex box, pretty much an inside out model. If your models are slightly more complex i don't expect this to work. Your best bet is finding the texture coordinates and mix in the texture on your model, but that creates a problem if you have overlapping texture/UV space. – Madmenyo Mar 29 '14 at 09:56
  • I know it is not proper SE policy to just post a link, but i am short on time. A quick google presented this: http://xbox.create.msdn.com/en-US/education/catalog/sample/picking_triangle to " access vertex position data from a model" – Madmenyo Mar 29 '14 at 09:58
  • My final goal for now just find the the shader that will do the "mixing textures". – Wallstrider Mar 29 '14 at 10:04
  • Riemers has a good tutorial on multi texture mixing and has a shader ready for you. http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series4/Multitexturing.php – Madmenyo Mar 29 '14 at 10:14
  • Yes, I saw many tutorials with terrains but it works actually for terrains. There is so much vertex tricks etc. which I actually don't need. And I cannot put textures where I want from that tutorial as well. ;( – Wallstrider Mar 29 '14 at 11:14
  • I'll better try to port volume decal example from link that I posted. Because that shader 100% match my needs. And I don't need overwrite the logic just port it. But porting .shd to .fx for XNA a bit problematic for me. :D Also I've freezed my project cuz of it and making a 2D game for now. – Wallstrider Mar 29 '14 at 11:35