Download

WIP - Dynamic Left 4 Dead 2-Style Wounds/Dismemberment

Hello everyone!

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

RESULT (notice the hole in the white-for-debug shirt)

UPDAAAAAATEEEE!!!

How to use:

Download this project for an example: L4DTestWounds

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

Hi !

this is really cool. I was currently messing around trying to create something similar to this.

By following your exemple i was not able to get it to work. Could you check if your missing important informations ?

how is the actual circle in the alpha is created ?

i am sorry that i am not actually offering help but asking questions, but i have been looking for something like this for quite a while now

@Reboot - post some screenshots of your material and your setup for setting the hit position and I’ll take a look and see if I can find any problems.

Also make sure you replicated the “Custom” node with this code:



return length(actorpos.xyz - inp.xyz);


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
1f2b5daddfedf78f2d8a23facd3823f820121122.jpeg
13673b9bdec1132b07361d551a3095aaa90d8aca.jpeg

My static mesh simple setup ( i added a socket named default)

My actor setup
3c96882cf13731d626fe5d040b3547558f28db75.jpeg

and the blueprint setup

any idead what i am missing ?

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.

I uploaded the asset to mega, just click on download through browser, the file is only 307kb
it is an actor, a static mesh, a material ans a material instance.
https://mega.nz/#!A1ITHAoI!AyoKLg2LSY3N3i-ll2ahwlWLgJfx7MkulX0aVN0uivA

Yeah it technically should end up being in the object’s local space, in Unreal units. Your guess is correct.

Probably something I did or didn’t do in the material correctly.

Were you able to download the files correctly ?
I tried other things too and cannot figure out what could be wrong :frowning:

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 :slight_smile: 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.

Try this project (mediafire link - 2mb project) and see if you can get it to work.

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.

The cylinder needs guts!

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.

Hi !

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.

Made a gore mesh for the neck in Sculptris, and set up a test using new ellipse settings.

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.

Edit: Any way to access pre-skinned vertex positions in a material? - Rendering - Unreal Engine Forums

I’ve made some progress working on getting the “pose-space” (pre-skinned) vertex positions passed through into the material.

Hey since ur into looking for dismemberment options anyway,could u maybe discribe how this is done https://www.youtube.com/watch?v=jciX99FSZRU&index=13&list=PL6Ca1d0AQcv3lLCpbbeTRVS1gWjwIeEfs&feature=iv&src_vid=oAlbp7eiRVk&annotation_id=annotation_225320 , it seems to cut in realtime,instead of using preprogrammed breaking points ,would rly like that for my lightsaber unreal game with ps move,however i only figured out how to do the precalced dismemeberment :confused:

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

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

For Unity there are a few real time mesh cutting solutions… e.g. Unity Asset Store - The Best Assets for Game Making