DistanceToNearestSurface node sounds like it’s going to be crazy versatile, it could be used for seafoam, clouds going around buildings/mountains, maybe even change how your character moves when it gets close to a wall.
This is a really inventive use of the global distance field! Awesome stuff.
Well you can only sample it on the GPU in a material graph, so it needs to be visual-only effects. 's soft body approximation is just a visual effect, the actual collision between the balls is using the standard physics.
One thing I am curious about , are the spheres themselves in the distance field? Static meshes are in the distance field by default if they cast shadows and have ‘Affect Distance Field Lighting’ enabled. If the spheres are in the distance field, usually you get a distance of 0 when you do a DistanceToNearestSurface with your own position. But if the spheres aren’t in the distance field, they would not squish each other.
Wow awesome sample. I donwloaded your contnet file and put its content in the content folder of a blank project. When I tried to open the map like in the video, I found nothing. I opened the contetn folder in the editor and I found nothing there too. How to use the content folder you provided, Thanks.
Very cool but I can’t open the assets in the UE4 (I put the Uasset on my content fonlder but nothing) any ideas?
This is very cool I have already test the Flex Nvidia soft body but you need to compile the Ue4 source from the ue4 flex branch and I get a lot of but soo that cool to be integreated in the 4.8 .
For anyone who is having issues running the project. Make sure to take heed of the following text written in the OP: “It is created on the master branch. It does not work with the latest version in the launcher 4.8 preview 4!!!”. So make sure you have the master branch.
Ah! That explaines the strange results I got at positive location. They all seem to be 0, unless you are inside another distance field, which now that you explain it makes a lot of sense. The colliders are less than half of the actual sphere size. It probably sees it as the nearest surface since you are inside it, which is closer than your own surface since you can’t get inside yourself.
Make sure you are working in the master branch from GitHub. It’s Unreal 4.9.0.
I though this idea was cool, so I made it for you. Hope you like it:
I would still suggest also looking into using the depth texture, since it makes more sense from a natural standpoint to base the distortion based on the distance behind the object from the viewers perspective. It also has the benefit of not needing DX11. But I can understand how the distance fields help to make an effect like this more gameplay consistent with distance fields. Especially in multiplayer.
Oh I see how it works now. If you get a value of 0 from DistanceToNearestSurface on your own surface, then you’re not intersecting anything. If you get a negative value, you are intersecting something else.
Hey Daniel, would it be possible to get the gradient of the distance field as a vector please? At work we do lots of volume math with sdfs and their gradients (just a simple finite difference).
One example would be dot products with the gradient and an up vector to get masks for the ground that we can remap to get falloffs.
It’s basically a ‘normal to nearest surface’ and would be handy to have it to do more specific effects similar to the cloaking one above (but imaging being able to cloak against just the wall and not the floor which having the gradient would allow us to do)