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.
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.
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.
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 )
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.
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
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.