Unreal Engine how can we achieve soft Skin Physics in Unreal Engine

razfaz

Member
Mar 24, 2021
232
227
# Coding 'SoftBody' Intermezzo

You can't battle the current Cmp/PhX science regarding "Computural-SoftBody" implementation without getting insights and dirty hands into Vertex Buffers, no matter if Base Mesh or Nanite Tesselated.

Besides that, it doesn't really matter which engine you use; we're talking about fundamental things.
The engines try to give us solutions, but since SoftBody isn't a simple solution, it's currently badly available out of the box.

Okay, Unreal has ChaosFlesh and Unity has... I don't know.
In any case, both solutions are a waste of time at the moment (RuntimePerformance wise).


## If you are very crazy and don't shy away from a coding challenge, then I might have a devilish temptation that could help you.

You'll need a very RockSolid and performant centralized Vertex DataBase+Manager C++ Interface Solution to build on.

Such solid Base would help You a hell for implementing Your own VertexFactory, Solvers, MeshManager, Shaders, Nanite Materials and so on without caring much about buffers. *insert meme that blows Your mind here*

In the past, we've repeatedly been confronted with RHD, buffers and their pain etc.
That really annoyed me too!

We usually tend to create vertex-buffers when we need them through our way of coding, implementing them for each feature when we need it, etc. Yeah, I know, a bit shortsighted no? Because we need this for more than one implementation, and we know it!

Well, what about creating a centralized, capsulated and rock-solid RDG, Buffer and Vertex Hub for your needs?
That's my Nerdy Suggestion.


Not easy to do (I know), but can/will be done shorter than all the time all Devs spend on the battle with Acc-Exceptions and Nights of Debugger Sessions in Sum.


Here (as follows) is a short Guide/Plan/Path for the interested (worth a try I think):
Code:
# A Theoretical Hub (Managing RGD/Buffers in one place)
- [ ] 2.0 Establish Hub as the backbone
  - [ ] 2.1. Implement initial RDG buffer creation and upload.
  - [ ] 2.2. Add double-buffered positions for async compute.
  - [ ] 2.3. Optimize hub for simulation and rendering sync
    - [ ] 2.3.1. Use RDG `FRHICommandList` with fences for zero-sync dispatch.
    - [ ] 2.3.2. Minimize UAV/SRV transition overhead in `TransitionBuffers`.
    - [ ] 2.3.3. Test 10 iterations at 60 FPS on `SKM_Quinn.fbx` (43k verts).
  - [ ] 2.4. Enable multi-actor scaling
    - [ ] 2.4.1. Implement `RegisterActorInstance` for shared buffer offsets.
    - [ ] 2.4.2. Use Geometry Collection to precompute clusters, share buffers.
    - [ ] 2.4.3. Test 5 actors (225k verts total) at 60 FPS.
  - [ ] 2.5. Add Niagara buffer output support
    - [ ] 2.5.1. Export positions to `FNiagaraDataBuffer` for VFX.
    - [ ] 2.5.2. Use Niagara fence-based async readback.
  - [ ] 2.6. Integrate with rendering pipelines
    - [ ] 2.6.1. Support `CustomRDG` mode with `VertexFactory` WPO.
    - [ ] 2.6.2. Implement `NaniteDisplacement` mode with texture conversion.
    - [ ] 2.6.3. Prepare `NaniteSkeletal` mode for 5.6+ buffer handoff.
-----
[END OF TRANSMISSION]
 
Last edited:

JigglySquish

Member
Game Developer
Oct 1, 2023
119
211
I don't think a 'true' softbody implementation is even desirable. You're better off using a variety of custom deformers based on context. No general solution is going to fit all your needs.
 
  • Like
Reactions: Velomous

darkevilhum

Newbie
Sep 9, 2017
87
91
Velomous Did you ever find a solution to the distance field size limit? I've searched far and wide to see if we can access Mesh Distance Fields but there is just no answer on this topic.

I decided to just add a distance field based vertex deformation to my character with some masks, just so that the environment and static meshes cause subtle soft body-like reactions on the skin. But it's really annoying that I can't do it with smaller meshes to add the effect to say hands and such.
 

Velomous

Member
Jan 14, 2024
376
367
Velomous Did you ever find a solution to the distance field size limit? I've searched far and wide to see if we can access Mesh Distance Fields but there is just no answer on this topic.

I decided to just add a distance field based vertex deformation to my character with some masks, just so that the environment and static meshes cause subtle soft body-like reactions on the skin. But it's really annoying that I can't do it with smaller meshes to add the effect to say hands and such.
No, but I did find an alternative to distance fields that didn't have this limit; depth fade.

https://f95zone.to/threads/how-can-...physics-in-unreal-engine.137663/post-14473701

I figured it out by chance, for whatever reason I was playing with depth fade in materials and then switched to distance field view and noticed that it made the mesh almost visible in the distance field view when it shouldn't be.

That was the closest I ever got.
 

darkevilhum

Newbie
Sep 9, 2017
87
91
No, but I did find an alternative to distance fields that didn't have this limit; depth fade.

https://f95zone.to/threads/how-can-...physics-in-unreal-engine.137663/post-14473701

I figured it out by chance, for whatever reason I was playing with depth fade in materials and then switched to distance field view and noticed that it made the mesh almost visible in the distance field view when it shouldn't be.

That was the closest I ever got.
Hm I see. I did play around with your depth fade discovery but it's restricted to materials with the transparent/translucent shader space which doesn't work well/at all for a character shader.

The only other thought I've had on this recently and not yet explored is if I simply added static meshes (like spheres) to fill out a characters hand (very small ones that fit) and then applied some arbitrary uniform scale to every static mesh I added, let's say 100. That would make them big enough for distance fields, and then maybe I could offset the "effect" on the shader side to account for that 100 increase in scale? I'll try it out and see if that's feasible.
 

Velomous

Member
Jan 14, 2024
376
367
Hm I see. I did play around with your depth fade discovery but it's restricted to materials with the transparent/translucent shader space which doesn't work well/at all for a character shader.

The only other thought I've had on this recently and not yet explored is if I simply added static meshes (like spheres) to fill out a characters hand (very small ones that fit) and then applied some arbitrary uniform scale to every static mesh I added, let's say 100. That would make them big enough for distance fields, and then maybe I could offset the "effect" on the shader side to account for that 100 increase in scale? I'll try it out and see if that's feasible.
Maybe... I don't think it'll work out very well though, with the increased scale you lose a lot of accuracy. I had a theoretical solution to that which I remember testing, instead of making a sphere the right side, make a capsule that's super elongated, but I think it didn't work. It could just be I didn't elongate it enough, but more likely the size limitation applies 3 dimensionally and won't be overcome unless both height and width are large enough.

Another possibility would be to make a more elaborate shape, like a cone/spike, or perhaps a big box with a portrusion of some kind.

I think diving a bit into c++ to figure out how to access the mesh distance fields would probably be a better and easier approach, could just make a new material function for accessing it based on the existing distance field accessing function.

Or alternatively just making a shader that deforms based on other meshes' colliders. Now that I think of it, didn't u already have something like that?

Edit: On unity, I found out that , the international version and the superior chinese version (which is definitely what aforementioned SakuraRabbit uses btw, he or she is chinese). So, standard unity is a cucked inferior version of unity :HideThePain: .

There's some progress on nanite substitutes for unity though, unity china already has a solution for that, has had it for a few years i think, but one of the next few versions will have something they're calling the mesh lod system (creative name, right?) there's also some guy that's been working on a plugin nanite alternative called nano tech. They also have a visual scripting language like blueprints (think it's a lot less mature though) but literally nobody uses it. Nobody would have used blueprints either actually if it weren't for the convenient starter templates that made playing with it a whole lot easier and simpler than the classic c++ workflow.

I didn't get around to testing any of the fun stuff on unity just yet because I've lost myself to creating a character controller for some reason (it's fun, gotten me to stretch my C# programming legs a bit too, refresh my memory on it all, which will make it easier for me to dive into c++ in unreal eventually too). I'm more or less done with it though i'll be making a new thread when i finish.
 
Last edited:
  • Like
Reactions: darkevilhum

Velomous

Member
Jan 14, 2024
376
367
Well there's an idea, guy just builds his own physics engine that supports softbody so he can have softbody physics :HideThePain: It's in unity though, but a lot can be learned from it.


I've played out the unity experiment, I wanted to see how much work it'd take to get a softbody sim setup there, and I tried to do so with obi softbody. What I found was that it's not reliable, i couldn't figure out how to make it work with regular colliders (based on the documentation it seemed like it should support that pretty much out of the box; I was using a pirated version though) so anytime I enabled it my character would just drop through the floor. With a bit more finagling I maybe could've gotten it worknig but overall I was unimpressed, the performance was lackluster too. I mean it was good if you compare it to say chaos flesh, but it was bad compared to my own experiments with niagara particle softbody; and ultimately using the same technique as it too.

I had some fun with unity though, writing my own character controller was cool, I am even pretty happy with it and I think I'll use some of the techniques I learned for my freecam implementation in unreal, I would even say it was a fairly good character controller, I mean it had full physics support and jumping, collisions, complete ground movement method (walk up/down slopes and stairs in what I find is the most optimal way possible) and very high configurability, I'm fairly proud of it even if it's just barebones, the majority of the heavy lifting is already done in it and all that was left at this point was fixing a few minor issues, refining it, and applying some code using the exact same principles (literally could just copy paste and do a very minor edit) to handle collisions at head-height. Then it'd be complete. The most difficult thing (all the math) is already done. I learned a lot of fun things and shook off a lot of rust by doing this, which was my main reason for doing it in the first place.

There's a vid in the spoiler if you want to see how it went.

You don't have permission to view the spoiler content. Log in or register now.

One really important thing I learned from unity was to appreciate the physics tick, which I never properly made use of in Unreal.

Anyhow, speaking of niagara softbody I believe my next experiment will be to try to make the niagara softbody solution actually work. When I last tested it it was just proof of concept (I wanted to see if it was feasible at all, and it was) my first major challenge going into that is handling collisions, and my second challenge after that will be setting up some kind of weight paint mechanism.

To make a truly ideal niagara softbody solution, I would have to somehow arrange for particle driven collision (so i'd either have to cut out physics asset based collision entirely or make the colliders always be smaller than the mesh, which would allow me to use them to control maximum collision depth for the softbody stuff, which is not a bad idea at all). I think if it's done right it can be uesd to solve a lot of problems (like making clothes always fit the character properly, and perhaps as an alternate clothing physics system as well since chaos cloth is really damn hard to work with at runtime)

But before I do all that i want to import a proper morphable character model and maybe some animations to go with it and do some work on my character creator because well...Making the character creator so far has been super fun tbh and I wanna do some more of that first.
 
Last edited: