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

razfaz

Member
Mar 24, 2021
215
216
# 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
210
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
86
88
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
349
349
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
86
88
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
349
349
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: