Search Unity

[Released] Deformable Surface

Discussion in 'Assets and Asset Store' started by V0odo0, Nov 20, 2016.

  1. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks for the answer. What heightmap resolution do you recommend (or do you use in your demo video) -- pixels to meters ratio?
     
  2. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Surface in scene with green ball is 64x64 units (meters) and has resolution set to 5. It is 320x320px heightmap texture.
     
    gecko likes this.
  3. jaelove

    jaelove

    Joined:
    Jul 5, 2012
    Posts:
    302
    Hi when testing your asset in the Unity editor everything works fine, but when I create a standalone build the game crashes before the scene loads and I get this error message . Any ideas? I'm using Unity 2017 by the way.

    D3D shader create error for pixel shader [0x887a0005]
    D3D shader create error for vertex shader [0x887a0005]

    [...]

    d3d11: failed to create 2D texture id=2881 width=512 height=512 mips=10 dxgifmt=29 [D3D error was 887a0005]
    d3d11: failed to create buffer (target 0x1 mode 0 size 2905872) [0x887A0005]

    [...]

    ========== OUTPUTING STACK TRACE ==================

    0x00007FFC28BCE5E0 (d3d11) CreateDirect3D11SurfaceFromDXGISurface
    0x00007FFBA535F9DB (UnityPlayer) UnityMain
    0x00007FFBA537DADB (UnityPlayer) UnityMain
    0x00007FFBA5380C1B (UnityPlayer) UnityMain
    0x00007FFBA5380CC9 (UnityPlayer) UnityMain
    ERROR: SymGetSymFromAddr64, GetLastError: 'Se ha intentado tener acceso a una dirección no válida.' (Address: 00007FFBA4E12468)
    0x00007FFBA4E12468 (UnityPlayer) (function-name not available)
    0x00007FFC2E027BD4 (KERNEL32) BaseThreadInitThunk
    0x00007FFC2EAECED1 (ntdll) RtlUserThreadStart

    ========== END OF STACKTRACE ===========

    *** Crash! ***
     
  4. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    It is hard to say what causing the crash but I'm almost sure it is GPU or Unity engine issue. Here is my suggestions.

    1. Make sure that your GPU has DX11 support
    2. Check the Auto Graphics API in Player Settings > Other Settings or include DX11
    3. Update your GPU drivers to the latest version
    4. Try to build the example scene on clean Unity project
    5. Try to build your project on the latest Unity engine version (2019.3)
     
  5. jaelove

    jaelove

    Joined:
    Jul 5, 2012
    Posts:
    302
    My gpu has direct x support. I can't just update the project to 2019, so many things will break and are incompatible, it is a huge project. Everything works in the Unity Editor and in play mode but I get crashes when I try to run the game as a standalone build. My programmer has experienced the same crashing issue on his computer as well.
     
  6. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    I have found a bunch of threads where users gets the same crash in various situations. Also I can't see any relations between your crash report and my asset. Except this one:
    According to this line I assume that it happens when deformable surface creating the render textures on initialization but there is nothing unusual in that piece of code (see DeformableSurface.cs, line 143). I recommend you to test the asset on clean project and report back if crash appears. Otherwise, I conclude that this is an engine crash and you should send a bug report to Unity.
     
  7. jaelove

    jaelove

    Joined:
    Jul 5, 2012
    Posts:
    302
    Ok Thanks
     
  8. CosmicBoy

    CosmicBoy

    Joined:
    Apr 16, 2014
    Posts:
    35
    Hey there,

    Just got this asset and am running on Unity 2019.3, GPU updated to latest Drivers and supports DX11. Upon pressing play in the example scene the entire terrain collapses? Anything i'm doing wrong or missing? No errors in the console relating to it
     

    Attached Files:

  9. CosmicBoy

    CosmicBoy

    Joined:
    Apr 16, 2014
    Posts:
    35
    @V0odo0 Ok so i'm pretty sure this is the problem https://forum.unity.com/threads/writing-and-reading-from-a-rwtexture2d-doesnt-work.494700/

    "On certain hardware, you cannot use float4 in compute shaders." Seems to be the case with alot of dx11 nvidia hardware which is what we are developing on on multiple computers.

    Here is a possible solution although I have no idea how to implement it https://www.reddit.com/r/gamedev/comments/6zbie1/dx11_unity3d_rwtexture2d_fails_on_nvidia_hardware/

    Will a solution be implemented to support all dx11 hardware?
     

    Attached Files:

    Ady_Rian likes this.
  10. Ady_Rian

    Ady_Rian

    Joined:
    Dec 14, 2019
    Posts:
    2
    @CosmicBoy i have the same problem. do you already fixed it?
     
    CosmicBoy likes this.
  11. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Hi. Thanks for pointing out. Do you mind if I send you modified shader a bit later to test it?

    Do you mind if I send you modified shader as well?
     
  12. Ady_Rian

    Ady_Rian

    Joined:
    Dec 14, 2019
    Posts:
    2

    no, I just hope, it will help. I sent you an email on Thursday the 30.04.2020.
     
    CosmicBoy likes this.
  13. CosmicBoy

    CosmicBoy

    Joined:
    Apr 16, 2014
    Posts:
    35
    Hey there, if the offer is still open that would be great! Looking to implement this on levels I'm currently working on
     
    ChaosResolution likes this.
  14. BettoSan

    BettoSan

    Joined:
    Dec 7, 2017
    Posts:
    57
    Why in the v2.1 update, the height seems smaller than in the v1.1.2 version.
    Before, the height of the snow seemed to be up to the character's knees. Now it's flattened to the heel.

    Where could I work to increase this height? No Shader or script?

    Any tips on where to start?
     
  15. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    There was no actual changes related to height values between v2.1 and 1.1.2. You can adjust max height and offset in settings tab.

    Does the surface in RollTheBall example scene looks flattened for you after fresh asset import? If so, please send me more details with some screenshots.
     
  16. BettoSan

    BettoSan

    Joined:
    Dec 7, 2017
    Posts:
    57
    I deleted the "DeformableSurface" folder and installed it again.
    Now everything is fine.
    I verified that the flattening is setting "Max Offset" to 0.1 - I used 0.5 again.
     
  17. BettoSan

    BettoSan

    Joined:
    Dec 7, 2017
    Posts:
    57
    "Recover Over Time" works on a small scene.
    In another, bigger scene, with the same settings, this one doesn't work. The "Deformable Surface" corrects almost instantly, even if you mark 0.12 in "Recovery Speed".
    I deleted objects in the scene until everything normalized.
    What to do?

    "Recovery Speed" is related to the FPS in 1/1000.
    I reduced the scene to 120 FPS and then "Recovery Speed" works with 0.12 to 1.17.
    With the scene at 320 FPS, "Recovery Speed" works well at 0.32.
    Is this a coincidence?
     
    Last edited: Dec 19, 2020
  18. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Hello, can I ask for guidance on how to use the height map import, or how can I paint on textures/normal maps? Thanks.
     
  19. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Hi, also, if you look at the video bel0ow, can I ask for guidance on how to smooth the edges, you see near the rocks the deform surface is very odd looking/jagged:
     
  20. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    It seems like you didn't exclude the terrain layer from Deform Mask. It is highly recommended to have one separated layer for renderers that can produce deformation effect.

    To do so, create a layer called e.g. "DeformObjects" and select it in Deform Mask of Deformable Surface component. Then, attach some capsule or sphere shaped renderers with simple lit shader to your vehicle's bottom part or wheels with "DeformObjects" layer selected. Don't forget to exclude this layer from your main camera culling mask.
     
    Fibonaccov and khos like this.
  21. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Awesome, with a bit of fiddling it works, many thanks for your help :)
     
  22. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Would it be ok to ask another question? Via C# script, how can I detect when an object is deforming a surface, is there a API or method I can use to test for this? I have a car that deforms a sand surface and want to spawn a dust particle system, only when the surface is deformed. Hope you can provide some input on this.
     
  23. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    There is a GetCollisionOffset method that allows you to sample current depth at given position. You can call it in Update method of your custom script attached to wheels, provide a whell world position and spawn particles if returned value is above zero.
     
    khos likes this.
  24. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Thanks, I was able to solve this via an ontriggerstay event and looking for object name. Cheers!
     
  25. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Hi, I'm pretty stoked by your asset, it is really useful.
    I have an issue/question though, in my scene I have 3 deform surfaces:

    E.g.:
    upload_2021-6-27_13-56-45.png

    when playing the FPS is around 30, if I disable these three FPS goes to 60/70 or higher, is there any advice on how to improve the FPS?

    Here is a sample of the settings of one:
    upload_2021-6-27_13-58-8.png

    Thanks in advance.
     
  26. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Note that each deformable surface instance has its own camera that renders scene depth within surface bounds each frame. That's why it is important to use separated layer for deform mask.

    It might be better having one big surface instead of multiple small ones since each camera have a bunch of expensive operations before actual rendering.

    Since you have multiple instances, set DeformEnabled to false for the surfaces that has no deform object within its bounds. It is up to you how to manage this trough code.
     
    khos likes this.
  27. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Ok thanks, also looking at other parts, possibly like unity terrain grass/draw distance etc :)
     
  28. HAMILCAR_TECHNOLOGIES

    HAMILCAR_TECHNOLOGIES

    Joined:
    Dec 14, 2018
    Posts:
    12
    Hi
    Does it work well on mobile devices ?
     
  29. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Hi. Unfortunately not.

    Requirements: DX11 & Shader Model 5.0 support
     
  30. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
  31. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Hi.

    1. Which version of Unity are you using?
    2. Is your project using standard render pipeline?
    3. If you talking about console errors then make sure that they comes from my asset scripts in stack trace.

    Since deformable surface's Camera has modified projection matrix for culling process, the errors may occur when that camera tries to cull or render water object. Exclude all layers in DeformableSurface component settings and leave the one for objects that should affect deformation. Otherwise your water object might affect deformation when it should't.
     
    khos likes this.
  32. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Many thanks, I'm 2019, standard render pipeline, I think they are coming from KCS, but could it be the order of script execution, not sure. Anyway, thanks for the advise, I'll try to check the layers as you mention, thanks.
     
  33. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Sorry for bringing back this old post...I'm reviewing this part of my project again, currently I use a collider to check if the player (vehicle) is in the collider area (cube, same size as the deform surface area), then I use SetActive to enable the deform surface object, if not it disable the whole deform layer. It works but sometimes when enabling the deform surface object the deforming does not not work. Is there are issue with disabling/enabling these deform surface objects at runtime (I have 3 in total)?
     
  34. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Just reading the older reply, will setting DeformEnabled to false be the best approach?
     
  35. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Hi, can I ask if your asset supports decals, I'm using an asset called wet stuff to add rain/puddles, all my rocks etc show the wet stuff, but not your deformation surface. Can I ask if there is anything I can do to make the decals show on the deform surface?
    Wet stuff asset info here: https://placeholder-software.co.uk/wetstuff

    Many thanks for any help given.