I want to paste a bullet hole image onto a geometry face when a bullet (or a ray, to be precise) hits it. How would I do that?
with a decal
Please correct me if Iām wrong but thereās currently no built-in utility for making decals, it has to be done from scratch mostly.
There are many alternatives depending on the specific requirements, this is one alternative thatās been mentioned in the past: How to project decals - Wolfire Games Blog
I have this in my todo list and I havenāt done it myself yet.
How do others do it?
im also interested about best apprach into this.
There was/is one lib, not sure if still working one:
But generally im also curious what would be best way to achieve this for a character for example.
I could create quads assigned to bone links, use mentioned lib, but im still not sure about best way. (on animated character)
Iāve made a decal system based on that article a few years ago, and itās been on my priority list to clean the library up to make an alpha/beta release of it available, but the one big feature I left out was vertex-cropping for parts of the decal that are outside the dimensions, and instead I just discard the pixels in the shader as a quick fix, which was sufficient for my project where I was using decals for effects on the ground that donāt last very long. But the vertex cropping is definitely necessary for rendering many static decals that last for a long or indefinite duration, and for decorative decals that could be batched together in the scene design process.
It has been a long time since I updated my code on github to match the progress Iāve made with decals on my local project, and I was fairly new to JME when I wrote this. But here is the repository if anyone is interested in taking a look at the code, or if anyone is possibly interested in contributing to the repository or helping with testing sometime in the near future to make this a finished decal library.
I have not implemented any code to solve this yet, but my plan for placing a decal on an animated character (like a tatoo, for example) is to transfer over the bone weights from each vertex (if possible) when Iām copying over the rest of the vertex/index/texcoord buffers for generating the decal, and then the decal should be able to be added to the characterās node/spatial with the animComposer (similar to a piece of clothing that has bone weights matching the character) and should follow the animations fairly accurately.
And here we fall off the edge of the cliff of āhundreds of ways to do a thing each with their own trade offsā⦠which is why I suspect sgold gave a simple answer to a simply worded question. Especially since ādecalā is the appropriate key word for searching (especially on the forum).
In google, you may also search for āsplatā⦠because most of the āprojectionā approaches can bog down after a few hundred bullet holes⦠if thatās a realistic use-case for OP.
well, for a tatoo, i just overlay another transparent texture(like phong one) and blend with default one.
Yeah, for an animated character itās really the only feasible way for tattoos.
yup, but about bullets on animated character you say i need search āsplatā keyword?
No, I wasnāt answering any questions about animated characters because thatās not what OP asked.
If you want to put thousands of bullet holds around your level then āsplatā or āsplattingā may be a better keyword to search for. It could may be adapted to character animation also, I guess. Never really thought about it. Depends on which splat approach is taken but the one I always think of is a shader trick.
I think one of the GPU Gems books had something about it. I remember thousands of random flowers on a surface or something. My books are not handy.
To make things clear, the geometries I want to splat are completely static, no moving parts or anything.
Thereās an idea, but itās not fully mature, you can remove the bullet from the physics space when it collides with the geometry face, it would stick to the object, then change the bullet color to completely black(or leave it as itās or change its texture as you want ), it is a little bit of deceiving option, but it wonot satisfy you, if you want an advanced option.
I think @capdevon has made a more dynamic progress in this option(sticking bullets) :
EDIT : I realized that you are using rays & not geometric shaped bullets, this way would work only if your bullets are Spatials.