I’ve been thinking about ways to do dismemberment and wounds in UE4, and since I’m not an artist, and UE4 doesn’t have the old UE3 bone-break system anyway, I decided to see if it was feasible to implement Valve’s Left 4 Dead 2 style dismemberment/wound system, which uses a shader based system.
The idea is to create an ellipsoid at the hit location, subtract out geometry around it, and spawn in an appropriate wound mesh. I managed to quickly build up a test using just a sphere, and a material which masks out the geometry around it. Here are the results, the material and how to use it, and a list of improvements to bring it up to snuff with Valve’s implementation. Some of this stuff is a bit hard for me (especially making wound meshes! So please any artists interested in an easy to use wound/dismemberment system, this could use your help), so I figured I’d release what I have and see if the community can help out to get something great for everyone, and improve all of our games at once
RESULT (notice the hole in the white-for-debug shirt)
You’ll need to feed this location with hit positions at some point, which will replace the socket location I have for testing there. You’ll also technically only want to set the hit location once, unlike what I have below which sets it on tick for testing purposes. To expand to allow multiple hits, add more vector parameters in the material, and do the same thing with the custom node with the new positions for each, then add them all together
Work to be done:
Implement pre-skin position support, so that sphere/ellipse position naturally follows animated characters (this is key!) DONE!
Set up the ellipsoid rotation/size DONE!
Use the blood mask
Draw blood layer
Create wound meshes
Get wound mesh spawning
Support slashes in addition to holes (thin ellipsoid, needs different blood texture)
(Specific to your game)
Pick slash or ellipsoid based on attack type
Set slash/ellipsoid rotation based on hit direction
Edit: Update - This system is now implemented - pre-skin position support in the material. Blood mask and wound meshes are the last remaining step
Thank you ! here is some screenshots. my setup is a bit different as i am trying to make it work on a static object but it should be similar.
Here is the material setup
My static mesh simple setup ( i added a socket named default)
I don’t see anything wrong with your setup - it’s probably assumptions on my end that ended up being wrong.
Have you tried setting the HitPosition parameter in your material to a constant value? See if you can play with it until the dark circle appears in the mask node. Otherwise I’ll probably have to play with it myself to figure it out.
If you don’t mind packaging up the project I’ll be happy to take a look at it (or just moving the actor and the material to a new project and packaging that).
How is the position determined ? From my understanding, the vector created by the linearColor is used as a position, and my quess is in Unreal units. i tried setting the vector on start to 0,0,0 , 0.5,0.5,0.5, 10, 100 100 100.
My Cube is 1 meter height so i tried a bunch of value anyway.
Were you able to download the files correctly ?
I tried other things too and cannot figure out what could be wrong
in the material, which kind of Param did you use ? i used a VectorParam.
Also, how is the circle that appear in the opacity mask created ? the nodes in the material seems to only check the position and determine if it should be 1 or 0.
It makes the circle using the custom node that’s returning the length between the two input positions.
I did download your assets and manage to get them to work in the editor, but couldn’t figure out why it wasn’t working. I’m going to take another look at my project here where I have it working and see if I can’t figure it out.
If someone who knows more about materials wants to chime in with the right way to replicate what the paper is doing (texkill/clip on anything inside a certain radius of the point), please do I’m not the best at this.
So I think I figured it out - it seems to be a problem with the cube mesh itself. I tried the same exact code on the Starter Content cylinder mesh and it worked out fine. Also you can just directly pass a local-space position for Hit Position - no need to do Unrotate or subtract the world position as I was doing.
If you open up the blueprint you should see the hole appear at the bottom (0, 0, 0). I’ve set the Hit Position variable to (0, 0, 100) which is the top of the cylinder, so if you hit Play after loading the TestMap, it should move to the top. You can also click on the BP during runtime and change the Hit Position - it will update when you stop editing the values.
Here’s a screenshot of the cylinder in the viewport in editor with the hole at the default position:
Here’s a screenshot of the cylinder during runtime with the hole set to be at 0, 0, 100):
Hi n00854180t this is looking really good. I’ve been in several discussions about this topic myself and have plans to implement a Gore System using several techniques: Left 4 Dead, SoF GHOUL, Destructible/Fracture Meshes, and Collage Construction. I’m aiming for a Gore system suitable for a multitude of creatures of various shape and limb count. Perhaps use it to pull a similar effect to Mortal Kombat X Ray Attacks.
I’m under the impression L4D exterior wounds are 100% vertex shader manipulation with all the needed transparency, depth etc, to simulate filler ‘caps’ for the internals. There is no mesh swapping or spawning. I purchased the Advance Dissolve FX Kit for this purpose.
Your character appears to have separate clothing meshes. I believe L4D using single mesh body (base body + clothing). I would anticipate the technique being applicable to modular base body and clothing pieces, but I’m curious as to how you’re going to approach it.
Check out the white paper again - they made wound meshes in Maya using a high res mesh of interior organs which they projected onto a texture then formed around the high res geometry to give it shape. They definitely do some sort of wound-mesh spawning - the vertex shader only masks out the ellipsoid area (sphere for now in mine).
Since it all happens in local component space, as long as each material has the functionality and is being fed the same point, it should end up masking the same area. Plus the wound mesh would hide that area anyhow.
I managed to get your latest exemple to work. i believe the issue was the scale of the object or something in the material. It’s simpler now and it works.
I played around with it and made a linetrace where my cursor is aiming to help with the debugging.
How were you planning on doing multiple hit ? the only thing i can think of that would work in blueprint would be a predetermined array of hitposition.
I did some research on if it’s possible to “save” the result to a texture and update it constantly but no luck so far.
Yeah basically if you want multiple hits, you just need to add more Hit Position parameters to the material, and then duplicate that whole section of code, and then add the resulting masks together before plugging it into the opacity mask.
Edit: To make it easier, you might set up a material function with all the code from where it takes the hit position parameter, to where it wires to the opacity mask. Then just set up extra hit position parameters, wire them into their own material function for the mask, and then add all the outputs and wire it to the opacity mask.
Since it’s just simpler math save for length (and you could optimize it by using length squared and then just passing smaller amounts for the size, which is the multiply node there).
As an aside, if someone can figure out how to make these masked areas follow an animated mesh properly, and/or set up the ellipse generation, I’d be eternally grateful. And as a reminder, artists capable of making wound meshes are also much needed!
Hey guys, so I figured out a workaround to get the hit location into the local space of the mesh, so that animations don’t cause the “hole” to shift around.
If you use the location of a socket, then inverse transform it by the skeletal mesh’s transform, and set that as the location (no unrotate or anything) it will move with the animation at that socket. You can use an offset to change the location a bit without it ruining the effect.
Getting the forward/right/up vectors and the radius/length of the capsule in there is the next job.
Edit: Got up/right/forward vectors into the material, and tested a janky wound mesh for the neck area.
To get it to look 100% right in motion without hacks, it will need some engine changes - namely being able to get the pre-skinned vertex position.
Here’s more information:
Unfortunately I don’t think I will have time to work on that for a while, and will just be using hacky workarounds with the current system (i.e., base the position off of a socket).
If anyone wants to take a stab at that, that would rule, and is essentially the main thing left that’s missing aside form more wound meshes.
Assuming it does real time mesh cutting - doing realtime cuts like that is kind of a pain - most of these other methods exist so that you don’t have to try
There are a few odds and ends around the internet that talk about doing real time mesh cutting, but it gets insanely complex when talking about an engine like UE4 and using it on animated characters.
That said, you can use this system (the L4D2 style one) for the type of cuts you see there simply by trickery - e.g., you spawn a copy of the character character and invert the wound mask so that it hides everything but the part you sliced off.
Also the system in this post doesn’t use pre-placed breaks at all, just FYI