User Tag List

Results 1 to 33 of 33

Thread: Distance Field Soft Bodies

  1. #1
    2

    Lightbulb Distance Field Soft Bodies

    Hi everyone,

    Today I made a little test using the master branch of Unreal Engine. The idea was to mimic the effect of soft bodies by using the new "DistanceToNearestSurface" node.

    Here is the result:


    Since it uses the material to deform it, it is completely fake, but I still think it looks pretty good. I'm not using it myself for anything, so if you need it or would just like to give it a try here is my content package:
    www.roelbartstra.com/resources/downloads/distancefieldsoftbodies.zip

    It is created on the master branch. It does not work with the latest version in the launcher 4.8 preview 4!!!!!!

    Here is the material overview:
    Name:  MaterialOverview.png
Views: 6356
Size:  505.4 KB

    If you want more accurate physics results you could maybe try making a physics repulsor per sphere.

    Feel free to ask any questions and ENJOY!
    Last edited by Roel; 06-09-2015 at 06:00 PM.

  2. #2
    0
    Awwww this is so awesome!

    Can't wait to use it in 4.8 w/ a shield deformation effect I had in mind, this distance field feature is just too cool!
    Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-source template)

  3. #3
    0
    Luminary

    Join Date
    Mar 2014
    Posts
    1,996
    Oh my god, you're genius! Thanks!
    Time to resurrect my little jelly!

  4. #4
    0
    Luminary
    Join Date
    Mar 2014
    Posts
    1,612
    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.

  5. #5
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    570
    This is a really inventive use of the global distance field! Awesome stuff.

    maybe even change how your character moves when it gets close to a wall.
    Well you can only sample it on the GPU in a material graph, so it needs to be visual-only effects. Roel'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 Roel, 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.

  6. #6
    0
    Luminary
    Join Date
    Mar 2014
    Posts
    1,612
    I was thinking about a stealth game where your character cloaks near walls and uncloaks in the open. But you could use it for snow piling up more around buildings, or leaves, or trash.

  7. #7
    0
    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.

  8. #8
    0
    Awesome idea!

    Distance Fields are going to prove so useful!

  9. #9
    0
    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 .

  10. #10
    0
    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.

  11. #11
    0
    Quote Originally Posted by GalaxyMan2015 View Post
    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.
    I see. Now 4.8 is released and is no longer in preview. Can this now work in the full 4.8 or do we still need the master branch to make it run ?

  12. #12
    0
    Quote Originally Posted by zeOrb View Post
    Oh my god, you're genius! Thanks!
    Time to resurrect my little jelly!
    Cool! Let me know if you run into any issues

    Quote Originally Posted by DanielW View Post
    One thing I am curious about Roel, 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.
    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.

    Quote Originally Posted by PLASTICA-MAN View Post
    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.
    Quote Originally Posted by Charles View Post
    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 .
    Make sure you are working in the master branch from GitHub. It's Unreal 4.9.0.

    Quote Originally Posted by ZacD View Post
    I was thinking about a stealth game where your character cloaks near walls and uncloaks in the open. But you could use it for snow piling up more around buildings, or leaves, or trash.
    I though this idea was cool, so I made it for you. Hope you like it:


    Here is the overview:
    Name:  MaterialOverview.png
Views: 5061
Size:  505.6 KB

    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.
    Last edited by Roel; 06-10-2015 at 02:54 PM. Reason: Material overview added :)

  13. #13
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    570
    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.
    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.

  14. #14
    0
    Luminary
    Join Date
    Mar 2014
    Posts
    1,612
    The cloaking looks awesome, I could definitely seeing a game or power up based around it.

  15. #15
    0
    OK , thank you for your time !

    I will check that but for my project I think that I will still with the 4.8.

    Very cool work!!

  16. #16
    0
    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)
    Visual Effects Artist, Weta Digital, Wellington New Zealand
    BLOG www.danielelliott.co.uk
    @danielelliott3d https://twitter.com/danielelliott3d
    Unreal Engine and VFX Tutorials https://www.youtube.com/user/DokipenTechTutorials
    2015 Showreel: https://vimeo.com/116917817

  17. #17
    0
    This is going to be my new favourite node. Just had an idea... will report back in several days...

  18. #18
    0
    Quote Originally Posted by dokipen View Post
    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)
    In the live stream Daniel said they used the gradient to calculate the normal for making the GPU particle collision. I would really like to know how this is done with that node.

  19. #19
    0
    Luminary

    Join Date
    Mar 2014
    Posts
    1,567
    this threads got some good stuff in it

  20. #20
    0
    I'm pretty sure both nodes exist as per this image from the engine features preview:


    I'm building master right now to test it since it seems absolute world position is broken in promoted right now...

  21. #21
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    570
    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).
    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.

    In the live stream Daniel said they used the gradient to calculate the normal for making the GPU particle collision. I would really like to know how this is done with that node.
    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));

  22. #22
    0
    Quote Originally Posted by DanielW View Post
    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.
    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.
    Visual Effects Artist, Weta Digital, Wellington New Zealand
    BLOG www.danielelliott.co.uk
    @danielelliott3d https://twitter.com/danielelliott3d
    Unreal Engine and VFX Tutorials https://www.youtube.com/user/DokipenTechTutorials
    2015 Showreel: https://vimeo.com/116917817

  23. #23
    0
    This is amazing!!

  24. #24
    0
    I downloaded the content package but the balls don't deform...

  25. #25
    0
    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

  26. #26
    0
    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.

  27. #27
    0
    The project doesn't work under master version too, tested it today, 4.11 ... what is wrong Roel ?

  28. #28
    0
    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 )

  29. #29
    0
    Hey does this self-collide?

  30. #30
    0
    Quote Originally Posted by zeOrb View Post
    Oh my god, you're genius! Thanks!
    Time to resurrect my little jelly!
    Experimenting with soft bodies in UE4 atm. Super curious what approach you used for your jelly!

  31. #31
    0
    Promoter
    Join Date
    Dec 2014
    Posts
    190
    Hello can you remake this in newer versions, please ? I couldn't make it works...
    ABC Augmented Reality by UE4
    GooglePlay

    ArchVis VR

  32. #32
    0
    Link leads to 404

  33. #33
    0
    Does anyone have a copy of the ZIP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •