I’m trying to make it so that when you shoot a character mesh, the spot that you shot receives a kind of bullet-hole decal, except as a blood hole. Assuming there is a way to get that precise location of impact, how would I put a decal onto such a complex piece of geometry?
I am new to 3D, and when I try experimenting with a decal in 3D, it stretches weirdly across the mesh instead of placing the small, unstretched image onto one of the surfaces of the mesh.
What I’m going for is similar to Hitman 3 where shooting a dead body puts a bloody bullet hole into the corpse where you shot, except with low poly characters. I found resources for putting decals onto simple geometry like walls, but not a character mesh.
you can’t. Decals are projected. you can do it, but there is no way to differentiate the visual layer, you can’t stick it to the UV, so it will look like a projection.
you can sort of make it work by sticking it to a node copying the transforms of the bone, you need hitboxes for this. but the visual layers problem will be there, because the mesh belongs to a single visual layer, so it will look wrong if the character moves too much.
in some games, decals can be placed relative to the UV through a shader, but this also requires a special UV wrapping to prevent cutting of a decal and it’s more advanced.
you can use custom textures for different impact areas. you need a texture with the hole in different (most important) areas like the chest or the head, then you can create different materials and switch the material.
at this point you can also use different meshes for the same effect, this is done for destruction in games like call of duty and fallout 3.
What exactly do you mean by having hitboxes? While I will probably skip blood decals for now, one thing I wanted to be sure of was spawning a particle emitter that creates a linear “hose” of blood squirting out from whatever point you shot, which may be a similar effect to this decal but actually possible.
Would loading different materials be processor heavy? They are low poly characters with 1024x1024 textures, and I assume I would need multiple to account for different scenarios (eg chest, chest and back, chest and head, etc).
I might consider hiring someone later on to make a plugin that would allow for texture alteration, since I am trying to have dynamic character destruction be a focus of the game.
When a model is textured, each triangle in the mesh has UV coordinates for its corners, and those UV coordinates map to locations in the texture. You can stretch a small amount of texture over a large triangle or a large swathe of texture over a very small triangle. Good modellers will use this to put detail in places that need it, so often a lot of texture space is faces, for example.
The problem with this approach is, if you want to do something like this with bullets, the low detail areas look bad. If your models are custom (or can be customized), maybe ask your artist if they can make the texture size (roughly) uniform across the model.
If I was going to do this kind of thing, my temptation would be:
get models that are textured as uniformly as possible, so the surface area to texel ratio is as constant as can be managed
multitexture; have a damage texture in addition to the regular texture
try to get all the models textured the same way, so that (for example) the left leg is the same texture locations on every model, so looking up where to scribble on the damage textures is as simple as possible
BoneAttachment3D or some custom SkeletonModifier
that will get the transform of the bone, then add an Area3D as child of this.
when the Area3D detects a hit, it tells the player, and then you spawn something as child of that Area3D or BoneAttachment3D, that way it will move with the bone.
try to use few, for the most important areas like the chest, the head, 2 for each arm, 2 for each leg, maybe a few more for the spine and pelvis.
that is far easier than a decal.
switching a material is not.
the more materials a mesh has, the least efficient, if you can keep it to one material per mesh or even 2 or 3 it should be fine.
yes.
switching meshes is easy if you model the character with different variations and the same skeleton, in godot you can delete a meshintance3D and instantiate a different one from a scene and it will work with the skeleton. then you need gibs (look up alien vs predator 2 and fallout 3).
blood marks on different parts could be achieved with multiple textures that are layered on top of each other.
godot does not support switching textures during game tho, so these will have to be part of the material at almost all times. you can have a damaged version and an intact version for better performance.
for adding holes on a texture, that would however require a Texture2DRID, which needs a Vulkan shader, and those are hard to code.