Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Deformable Surface

Discussion in 'Works In Progress - Archive' started by V0odo0, Nov 9, 2016.

  1. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Hello friends!

    Have you seen how player interacts with snow surface in Assasins's Creed 3 or Batman: Arkham Asylym? If not, take a look:


    I think it's pretty nice feature which brings more realism into the game. I haven't found such surface deformation system for Unity on Asset Store so I've decided to make this one. Work still in progress but basic things are done and I would like to share the results with community.



    The basic technique is similiar to AC3 and Arkham Asylym but I'm using power of compute shaders for almost all heavy calculations and manipulations with textures. It means that there is no direct impact on CPU performance.

    The one bad thing that compute shaders and tesselation requires DX11. So Windows platform only.

    And here what's already done:
    * Realtime deformation with various settings such as deformation speed and smoothness
    * Realtime normal map generation
    * PBR shader
    * Not only flat surface supported. Even more you can edit base heightmap and depth of the surface in editor similiar to terrain editing

    Next steps:
    * More realistic looking deformation
    * API for interaction with surface. It will give the possibility to add physics behaviour. For example, decreasing the speed of the character after entering to snowdrift
    * Terrain alignment. Just place the surface anywhere above your terrain and click "Align"!

    There is more things that I should consider developing deformable surface system? Please, let me know what you think about it.
     
    Last edited: Nov 13, 2016
  2. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Cool, would you be willing to share code, I'm looking for walking in the snow effect! Will buy if needed.
    Another question is, couldn't this be recreated with terrain deformation?
     
  3. karlhulme

    karlhulme

    Joined:
    Nov 5, 2012
    Posts:
    33
    looking good, great work!
     
  4. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    It will be paid asset for Asset Store. All source code will be included.

    There will be the feature which let you fit the surface onto the terrain. It means that the surface does not depends on the terrain configuration.

    Thanks!
     
  5. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    YAAAY!

     
    Tzan, punk, karlhulme and 1 other person like this.
  6. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Hi, how long do you expect before you can make it available on eg the staore?
     
  7. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    573
    can this be used in a big terrain, or the framerate will be an issue
     
  8. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Hi. Around two weeks if there will be no issues with Asset Store submission process.
    In practice, I think there is no reason to place the surface on the whole terrain. It is better to place it on small important areas where your player can walk on.

    The performance is highly depends on the heightmap resolution you choose. Higher heightmap resoultion lets you make the surface wider but it will consume more GPU resources. Also, as I mentioned above there is almost no impact on CPU performance and it will not take long from the main thread.
     
    jbonastre likes this.
  9. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,083
    I saw your post about this on reddit a couple days ago and was really impressed. Shame to see it's DX11 only since I do all my dev on a mac.

    Still, if I ever take the plunge to Windows based development I may give this a look again!
     
  10. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    2 weeks, cool! :)
     
  11. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Thanks!

    DX11 requirement is not the only reason. Compute shaders requires OpenGL 4.3 which is still not available on OS X as I know. Compute shader is the core of my project so it is not possible to implement it using Mac.
     
  12. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Just ended up with surface editing. Similiar to terrain editing, but with two painting modes. The first one is for heightmap, and other one for the deformable part. It may be useful to make a tire tracks or footprints for example.

     
    Last edited: Nov 13, 2016
  13. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Nice, looking forward to this.
     
  14. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Just played around with Unity built-in car controller and mud
     
    strich likes this.
  15. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Physics implementation is ready! May be helpful in order to decrase player speed for example.
     
    Farelle likes this.
  16. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Guys! Here is another video of game named Steep from Ubisoft with such deformation system. I suppose they used nearly the same but more advanced technique. Looks quite good!

    At the same time, I'm finished working on the first release version and waiting for approval from Asset Store.
     
    jbonastre likes this.
  17. FreeFly90

    FreeFly90

    Joined:
    May 28, 2016
    Posts:
    177
    it looks awesome, really well done! :)
     
  18. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Cool! Can't wait, can I ask how much you plan to sell it for?
     
  19. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    It will cost 35$
     
  20. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
  21. cdiaz

    cdiaz

    Joined:
    Aug 1, 2012
    Posts:
    6
    Hi! I purchased the plugin and it works great so far. The only "bad" thing is it has very little functionality available that should be easy to provide with the core you have developed. Unfortunately, I'm not familiar with shaders, so Im having trouble developing it myself.

    I need to be able to "throw" soil/snow in real time in a given spot. Right now you can only achieve this in editor through the brush system (and particularly, the GetPixels call). How could I reply this in real time by demand?

    I also lack a method to "smooth" the areas Im deforming, since the edges I get are too sharp. I had an smoothing algorithm on my own that worked great, but as I said dont know enough shading to port it there.

    Thank you very much,
     
  22. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    529
    Hi,

    today i have many bugss coming from deformable surface.
    maybe related to last unity update ?

    Assets/DeformableSurface/Scripts/Editor/DeformableSurfaceEditor.cs(148,70): error CS0117: `UnityEngine.XR.WSA.SurfaceData' does not contain a definition for `SHADER_MAPS_TEX_NAMES'
     

    Attached Files:

  23. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Hi, is there a way of saving the deformations at runtime, so you can load the same deformation next time a game starts, ie can it be persistent?
     
  24. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Hello. What Unity version are you using?

    Yes, it is possible. Example scene has save / load buttons. Inspect RollTheBallManager script to see how this works.
     
  25. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    529
    i have deleted and reimported the plugin and the error is gone