Distance Field Soft Bodies

It’s in there!!! DistanceFieldGradient. Gotta normalize if you just want direction only.

Of course you can compute your own gradient by finite differencing the DistanceToNearestSurface, but this node is faster as it only does the clipmap selection once.

I would love to know what other use cases you know of for distance + gradient.

Here’s how the collision plane is extracted using the DistanceToNearestSurface + gradient. This is in the context of a particle that has position and velocity state. Look in ParticleSimulationShader.usf in master or future 4.9 for the rest of the shader.

float DistanceToNearestSurface = GetDistanceToNearestSurfaceGlobal(InPosition);
float MaxCollisionDistance = CollisionRadius + length(DeltaPosition.xyz);

if (DistanceToNearestSurface < MaxCollisionDistance)
{
float3 CollisionWorldNormal = normalize(GetDistanceFieldGradientGlobal(InPosition));
float3 CollisionWorldPosition = InPosition - CollisionWorldNormal * DistanceToNearestSurface;

float4 CollisionPlane = float4(CollisionWorldNormal.xyz, dot(CollisionWorldPosition.xyz, CollisionWorldNormal.xyz));

I do a lot of custom expression work on particles for simulations at work. One simple case is to get particles to stick to a surface if they penetrate. Another is a ‘tangent force’. It’s two cross products. First you do a a cross product with the gradient and an arbitrary ‘direction’ vector. Then you get that result and cross product it with the original gradient. You get a vector which ‘slides along the surface’ of the original geo and follows its contours. Would be interesting for possible water effects.

Another use case I am thinking of is using them to do a world position offset on a character to do warping effects near other objects. like a gravity/black hole stretching thing or also something giving off heat and making the vertices of other objects wobble with some noise in the direction of the gradient to simulate heat haze.

Also fake monochromatic GI from the world. it would be from everything and with no colour info but used in a subtle way would be like a cheap bounce effect.

This is amazing!!

I downloaded the content package but the balls don’t deform… :confused:

I’ve made a test with this project on 4.9.2 and it doesn’t work for me too… don’t know why… the balls are overlapping each other

Sorry if my question doesn’t make much sense or my wording is wrong (i don’t work with stuff like this alot) but is there to sort of stop calculations, like once the ball/surface has been pushed in (making the displacement value of that area lower than its original value) it cant pop out again, even after the colliding object has been removed. I was thinking to maybe clamp the max value to the current minimum somehow but, would that clamp for the whole mesh ?
I cant seem to figure this out, maybe i need to take a break or maybe I looking at this whole thing wrong.
Any help is appreciated, thanks.

The project doesn’t work under master version too, tested it today, 4.11 … what is wrong ?

This project file is no longer available, would anyone have a copy to share?
I want to implement this sort of functionality but am a total beginner with Unreal Engine ( moving over from Unity )

Hey does this self-collide?

Experimenting with soft bodies in UE4 atm. Super curious what approach you used for your jelly!

Hello can you remake this in newer versions, please ? I couldn’t make it works…

Link leads to 404

Does anyone have a copy of the ZIP?

Would be awesome to get working version of this in newer engine version or copy of the zip:(

I managed to bring back that cloaking effect in 4.20 and make my version of it using dithering. I haven’t had much luck with the squishy effect however, only managing a slight squish using distance fields. Here’s my graph for cloaking. In newer versions distance fields became a feature to be ticked in the project settings.

Hey,

I was getting back into unreal picking up on some old project and recalled this distance field soft bodies thread and by pure chance i still have the original project zip

Here ye go distancefieldsoftbodies.zip

I have no idea if it works in current versions but maybe you can learn from it at least :slight_smile:

I didnt even know this was possible, this looks great!

Hi,
Tried it, but it seems it’s lacking the deformation. It looks more like just clipping, while in the original video while bouncing and even after settling down there are deformation curves on the balls.
Started with UE like a week ago so I might have missed something

Version 4.25.
It seems like materials, physic materials, material instance all that loaded OK though.


https://forums.unrealengine.com/core/image/gif;base64

Edit: I forgot to enable Distance field generation in project settings, now works like a charm!

does anyone know if its possible to use this technique to apply the same effect on skeletal meshes? or any other way? i’m willing to pay for it.

Unfortunately, you can not use Distance fields with skeletal meshes.