Search Unity

Physics Obi Particle Based Physics (Cloth, Rope, Fluid) thread

Discussion in 'Tools In Progress' started by arkano22, Jun 30, 2015.

?

Performance vs compatibility

Poll closed Oct 9, 2015.
  1. I don't care about performance, keep my data intact please.

    0 vote(s)
    0.0%
  2. I don't care if I have to re-do some stuff, as long as it runs faster.

    14 vote(s)
    100.0%
  1. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    Does it work with unity wind system?
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
  3. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Obi Ropes in action:

     
    laurentlavigne, devoncode and hopeful like this.
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Or we could have a muscle simulation to create the blendshape to begin with :thinkaboutit: marvelous designer but for muscle
     
  5. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    That looks nice!
    The water shader is also looking good
     
  6. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
  7. nikolay_i

    nikolay_i

    Joined:
    Jan 5, 2020
    Posts:
    13
    Hello. We have silent crash in the project
    Here is a postmortem of the crash, with details about issue in the obicloth package

    1. After adding 2 instances of one prefab with ObiCloth component to the scene unity started crashing when we tried to start the scene in PlayMode. without any standard debug popup with crash details. UnityEditor log files didn't contains any usefull info
    2. I opened Event Viewer and found following Application Error report
    Code (csharp):
    1.  
    2. Faulting application name: Unity.exe, version: 2019.2.21.21133, time stamp: 0x5e38c5b9
    3. Faulting module name: ntdll.dll, version: 10.0.18362.418, time stamp: 0x99ca0526
    4. Exception code: 0xc0000374
    5. Fault offset: 0x00000000000f9269
    6. Faulting process id: 0x6b68
    7. Faulting application start time: 0x01d62d2078750ad6
    8. Faulting application path: C:\Program Files\Unity2018\2019.2.21f1\Editor\Unity.exe
    9. Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
    10. Report Id: a875fdea-0fcf-41e5-912f-1cc022204ef2
    11. Faulting package full name:
    12. Faulting package-relative application ID:
    13.  
    And error 0xc0000374 indicate that it's a heap problem. But the crashes appeared on several machines in our office. so that wasn't because of the failed RAM modules.
    3. I started follow Windows Debugging manual
    3. At the end of the manual there is an instruction how to generate dump files for any crashes in windows. So I added following keys as adviced to the registry
    • Open the registry.
    • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting
    • Create LocalDumps folder if it’s not there.
    • Add following keys:
      • “DumpFolder”=<FolderPath goes here> , for example, C:\Temp
      • “DumpCount”=dword:00000010
      • “DumpType”=dword:00000002
    4.After that. dump files started to be stored in to the temp folder. So I opened MSDebugger and added the symbols pdb location.
    5. After the crashes unity started to show poup with details and small dump files about just errors. Here is an output of the error
    Code (csharp):
    1.  
    2. ========== OUTPUTTING STACK TRACE ==================
    3.  
    4. 0x00007FFBECC1ACEF (ntdll) RtlSizeHeap
    5. 0x00007FFB49726806 (AcLayers) NotifyShims
    6. 0x00007FFB398158F4 (mono-2.0-bdwgc) [d:\th\minkernel\crts\ucrt\src\appcrt\heap\free_base.cpp:107] _free_base
    7. 0x00007FFB3955A18E (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\mono-debug.c:512] mono_debug_add_method
    8. 0x00007FFB396811A8 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\debug-mini.c:282] mono_debug_close_method
    9. 0x00007FFB395D5429 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini.c:2414] mono_codegen
    10. 0x00007FFB395D3258 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini.c:3858] mini_method_compile
    11. 0x00007FFB395D7041 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini.c:4197] mono_jit_compile_method_inner
    12. 0x00007FFB395DB462 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2133] mono_jit_compile_method_with_opt
    13. 0x00007FFB396B5C26 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-trampolines.c:716] common_call_trampoline
    14. 0x00007FFB396B7C44 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-trampolines.c:848] mono_magic_trampoline
    15.   ERROR: SymGetSymFromAddr64, GetLastError: 'The specified module could not be found.' (Address: 0000026861A103A3)
    16.   ERROR: SymGetModuleInfo64, GetLastError: 'A dynamic link library (DLL) initialization routine failed.' (Address: 0000026861A103A3)
    17. 0x0000026861A103A3 ((<unknown>)) (function-name not available)
    18. 0x000002687B52DFBB (Mono JIT Code) [C:\buildslave\unity\build\Modules\UIElements\UXML\VisualTreeAsset.cs:132] UnityEngine.UIElements.VisualTreeAsset:CloneTree (UnityEngine.UIElements.VisualElement,System.Collections.Generic.Dictionary`2<string, UnityEngine.UIElements.VisualElement>)
    19. 0x000002687B52DDAB (Mono JIT Code) [C:\buildslave\unity\build\Modules\UIElements\UXML\VisualTreeAsset.cs:121] UnityEngine.UIElements.VisualTreeAsset:CloneTree (UnityEngine.UIElements.VisualElement)
    20. 0x000002687B52D9AB (Mono JIT Code) [C:\buildslave\unity\build\Modules\UIElements\UXML\VisualTreeAsset.cs:106] UnityEngine.UIElements.VisualTreeAsset:CloneTree ()
    21. 0x000002687B52D023 (Mono JIT Code) [C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:238] UnityEditor.InspectorWindow:LoadVisualTreeFromUxml ()
    22. 0x000002687B52C413 (Mono JIT Code) [C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:199] UnityEditor.InspectorWindow:OnEnable ()
    23. 0x00000268D64EA218 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    24. 0x00007FFB395DBFB0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
    25. 0x00007FFB39562142 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
    26. 0x00007FFB3956B13F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
    27. 0x00007FF6EFE51012 (Unity) scripting_method_invoke
    28. 0x00007FF6EFE4ACC1 (Unity) ScriptingInvocation::Invoke
    29. 0x00007FF6EFE4AF3E (Unity) ScriptingInvocation::InvokeChecked
    30. 0x00007FF6EFEA9EB2 (Unity) SerializableManagedRef::CallMethod
    31. 0x00007FF6EFE080AB (Unity) MonoBehaviour::DidReloadDomain
    32. 0x00007FF6EFEA9956 (Unity) SerializableManagedRefsUtilities::AwakeInstancesAfterBackupRestoration
    33. 0x00007FF6EFE08AFF (Unity) MonoManager::EndReloadAssembly
    34. 0x00007FF6EFE13C69 (Unity) MonoManager::ReloadAssembly
    35. 0x00007FF6EE44E103 (Unity) ReloadAllUsedAssemblies
    36. 0x00007FF6EE42BCBF (Unity) EditorSceneManager::RestoreSceneBackups
    37. 0x00007FF6EDEB3F18 (Unity) PlayerLoopController::EnterPlayMode
    38. 0x00007FF6EDEC757D (Unity) PlayerLoopController::SetIsPlaying
    39. 0x00007FF6EDECA4D7 (Unity) Application::TickTimer
    40. 0x00007FF6EE75F0A0 (Unity) MainMessageLoop
    41. 0x00007FF6EE761ABF (Unity) WinMain
    42. 0x00007FF6F141C962 (Unity) __scrt_common_main_seh
    43.   ERROR: SymGetSymFromAddr64, GetLastError: 'Unknown error [-1073741819]' (Address: 00007FFBEB617BD4)
    44. 0x00007FFBEB617BD4 (KERNEL32) (function-name not available)
    45. 0x00007FFBECC4CED1 (ntdll) RtlUserThreadStart
    46.  
    47. ========== END OF STACKTRACE ===========
    48.  
    6. I found it very suspicious that the crash started with UnityEngine.UIElements even that we do not use UIElements in the project
    7. I searched the project source files for the UIElements entries and found ObiSettingsProvider, and then I just commented OnActivateMethod.
    8. After that I started receive following crush dumps
    Code (csharp):
    1.  
    2. ========== OUTPUTTING STACK TRACE ==================
    3.  
    4. 0x00007FFBECC1ACEF (ntdll) RtlSizeHeap
    5. 0x00007FFB25AA6806 (AcLayers) NotifyShims
    6. 0x00007FFB206158F4 (mono-2.0-bdwgc) [d:\th\minkernel\crts\ucrt\src\appcrt\heap\free_base.cpp:107] _free_base
    7. 0x00007FFB203D5241 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini.c:2329] mono_codegen
    8. 0x00007FFB203D3258 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini.c:3858] mini_method_compile
    9. 0x00007FFB203D7041 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini.c:4197] mono_jit_compile_method_inner
    10. 0x00007FFB203DB462 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2133] mono_jit_compile_method_with_opt
    11. 0x00007FFB204B5C26 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-trampolines.c:716] common_call_trampoline
    12. 0x00007FFB204B7C44 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-trampolines.c:848] mono_magic_trampoline
    13.   ERROR: SymGetSymFromAddr64, GetLastError: 'The specified module could not be found.' (Address: 00000214249803A3)
    14.   ERROR: SymGetModuleInfo64, GetLastError: 'A dynamic link library (DLL) initialization routine failed.' (Address: 00000214249803A3)
    15. 0x00000214249803A3 ((<unknown>)) (function-name not available)
    16. 0x000002144A3930E3 (Mono JIT Code) [C:\Users\NikolayKandalintsev\workspace\TKSingen\Assets\Plugins\Obi\Scripts\Utils\ObiParticleAttachment.cs:339] Obi.ObiParticleAttachment:Disable (Obi.ObiParticleAttachment/AttachmentType)
    17. 0x000002144A392983 (Mono JIT Code) [C:\Users\NikolayKandalintsev\workspace\TKSingen\Assets\Plugins\Obi\Scripts\Utils\ObiParticleAttachment.cs:167] Obi.ObiParticleAttachment:OnValidate ()
    18. 0x00000214D81F8888 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    19. 0x00007FFB203DBFB0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
    20. 0x00007FFB20362142 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
    21. 0x00007FFB2036B13F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
    22. 0x00007FF6EFE51012 (Unity) scripting_method_invoke
    23. 0x00007FF6EFE4ACC1 (Unity) ScriptingInvocation::Invoke
    24. 0x00007FF6EFE4AF3E (Unity) ScriptingInvocation::InvokeChecked
    25. 0x00007FF6EFEA9EB2 (Unity) SerializableManagedRef::CallMethod
    26. 0x00007FF6EFE04643 (Unity) MonoBehaviour::CheckConsistency
    27. 0x00007FF6EFE023E4 (Unity) MonoBehaviour::AwakeAfterRestoreFromBackup
    28. 0x00007FF6EFEA9956 (Unity) SerializableManagedRefsUtilities::AwakeInstancesAfterBackupRestoration
    29. 0x00007FF6EFE08AFF (Unity) MonoManager::EndReloadAssembly
    30. 0x00007FF6EFE13C69 (Unity) MonoManager::ReloadAssembly
    31. 0x00007FF6EE44E103 (Unity) ReloadAllUsedAssemblies
    32. 0x00007FF6EDEC94FD (Unity) Application::TickTimer
    33. 0x00007FF6EE75F0A0 (Unity) MainMessageLoop
    34. 0x00007FF6EE761ABF (Unity) WinMain
    35. 0x00007FF6F141C962 (Unity) __scrt_common_main_seh
    36. 0x00007FFBEB617BD4 (KERNEL32) BaseThreadInitThunk
    37. 0x00007FFBECC4CED1 (ntdll) RtlUserThreadStart
    38.  
    39. ========== END OF STACKTRACE ===========
    40.  
    9. Here it become obvious that the problem is in the ObiParticleAttachment and Enable function of the ObiParticleAttachement class it didn't work proper with AttachmentType.Static
    10. I checked the ParticleAttachments on the object and changed Static to Dinamic, returned commented code back (step 7) and crashes disapeeared


    Hope that helps.

    p.s. I tried to register on your forum, but didn't receive confirmation email so I post it here.
    Thanks.
    //Nikolay
     
  8. AryaTcs

    AryaTcs

    Joined:
    Jun 21, 2019
    Posts:
    8
    Hi,
    I am new to Unity. Can you please tell me how to make continuous liquid flow where i can control speed of liquid flow and there shouldn't be space between flow of liquid. i can see the gap between the flow of liquid how to get continuous flow when speed is increased. Please support. Thanks in advance.
     
  9. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Generally we don't offer support here. We have our own support forum (http://obi.virtualmethodstudio.com/forum/index.php) and email. Will answer your question here for convenience, though.

    You can't ensure no spacing in the flow under all circumstances because in Unity (like in all game engines, or rather, all computer programs), time is discrete. Particle spacing is automatically calculated so that density (the amount of particles per volume unit) is constant and no pressure spikes take place. This means some frames, particles are spawned (1,2,3, or more layers of particles), and some other frames, they aren't. You can't spawn a particle in-between frames.

    In offline fluid simulators this is usually circumvented by post-processing the simulation, detecting gaps and seeding additional particles there (sheet/filament preservation) or by sub stepping emission. Neither is doable in realtime.

    Your best bet is to reduce the emission speed. Sometimes reducing the solver gravity also helps, both with this and with compressibility (less gravity = less pressure = less work for the solver).
     
    Last edited: May 27, 2020
  10. vizgl

    vizgl

    Joined:
    Nov 4, 2014
    Posts:
    61
    Is there is way to create ropes without blueprints?
    I am planning use few ropes on every game level, they all will be different so in my case I don’t need use shared blueprint, but must create many blueprints for every rope. I didn’t find option which allow to store(serialize) rope control points in the Rope component itself without blueprint container.
    Is there is a way to do that?
     
  11. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Why would you even want to do that? regardless of where you serialize the control points, the amount of data is exactly the same. It won't generate less data if you serialize them in the scene (ObiRope component) compared to using a separate asset (the blueprint).

    Serializing in blueprints instead of scenes has the added benefits of not bloating your scene with extra data, and the scene file will not constantly show up as modified in version control systems (git, svn, etc) every time you modify a single rope. This was a major pain point for many users in previous Obi incarnations and one of the main reasons that drove us to design blueprints in the first place: to decouple scene data from actor data.

    If you need to create many blueprints because each individual rope is slightly different, there's nothing wrong with this at all. You can even do that at runtime if needed. Same pattern is used for many other assets in Unity: if you need to have 250 individual materials/textures/models/audio samples in a scene, you can.
     
    Last edited: Jul 31, 2020
  12. vizgl

    vizgl

    Joined:
    Nov 4, 2014
    Posts:
    61
    At the current state, architecture with blueprints are good for big projects. But as you know, most of the unity projects are simple mobile games or even prototypes(where dev time is very important). With blueprints we need more time(if game mechanics is based on ropes) to create and organize blueprints.
    It would be nice to have 2 ways(every dev choose own) to store ropes data:
    - blueprints
    - inside Rope or other game object component
     
  13. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    This exact same mechanic is used with most other Unity assets. If you need 20 materials in your scene, you need to create 20 materials and then assign them to their respective renderers. I don't see how storing all the data in the scene would be of any benefit to anyone, it does not make things easier to use, faster, nor saves any memory/storage space. o_O

    Maybe you can write a small editor script that generates a blueprint automatically every time you add a new rope component, and assigns both. Less than 10 lines of code that would save you from having to manually create and drag the blueprint for each rope, but that's about it. Also a valid solution for any other task of mass-creating components/assets. Let me know if you need help with this.
     
    Last edited: Jul 31, 2020
  14. vizgl

    vizgl

    Joined:
    Nov 4, 2014
    Posts:
    61
    Unity has prefabs, I can create 1 rope prefab, and place it anywhere multiple times, without increase scene size.
    If I want make small changes to the rope, I will create prefab variant and make changes to it.
    I think current implementation with blueprints is unnecessarily, because it can be simply replaced with prefabs workflow.
    Nevertheless I have some idea how to work with this
     
  15. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Prefabs store all serializable data in an object. Blueprints only store particle/constraint data, since actors also have quite some data of their own that is not necessarily tied to the blueprint. The amount of data stored in a blueprint can get really large (specially for long ropes), so it makes sense to separate it from the rope itself, instead of forcing users to make a prefab out of every rope in their scenes to keep sane scene file sizes. This a well known hot/cold data splitting pattern used a lot in architectural design.
     
    IsDon likes this.
  16. vizgl

    vizgl

    Joined:
    Nov 4, 2014
    Posts:
    61
    I found bug.(?)
    Let's make 2 ropes with the same blueprint(also reproduced with two different blueprints) and enabled self collisions.
    Also add ObiParticleDragger to the scene, to allow drag ropes.
    Ropes collide with each other, except particles with the same indices.

    For example, ropes has same length and same particles count 5(ropes on the screenshots has around 20 particles, so problem is not in the gaps)
    Every particle on every rope is enumerated 0,1,2,3,4.
    Collision are worked between particles with different indices, but when I try collide points 0-0, 1-1... they doesn't collide.
    No collision(same index, 0-0):
    upload_2020-8-5_12-39-48.png

    Has collision(different indices 2-1)
    upload_2020-8-5_12-42-25.png
     
  17. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi,

    This is by design, as explained in the manual:
    http://obi.virtualmethodstudio.com/tutorials/collisions.html

    Only particles in different phases are guaranteed to collide with each other.

    Since you enabled self-collisions for both ropes, but both have the same phase (the default one), they will collide with each other applying rest pruning: particles in indices that overlap will ignore collisions with each other. Indices 0 and 0 obviously overlap, so they will ignore each other. This is important to prevent constraint fighting, which causes jittering because collisions separate particles apart but distance constraints pull them back together.

    Solution: give a separate phase value to each of your ropes. This can be done on a per-control point basis using the path editor, or done at runtime for entire ropes using rope.SetPhase(). Keep in mind that there's only 32 different phases available.

    Note: Also, please refrain from posting in the Unity forums asking for support. I seldom check the Unity forums (couple times a week at most), official Obi support forums/email exist for a reason.;)
     
    Last edited: Aug 5, 2020
  18. mitesh123

    mitesh123

    Joined:
    Nov 8, 2018
    Posts:
    1
    Hello,I am using obi Fluid. i am developing product for augmented reality using ARFoundation for android. i seen your tutorial and buying asset from assets store.when i build apk its hangs and runnig very slow and also particles not appearing.can you suggest me settings how i can use obi fluid in arfoundation. I am making chemical Mixing Scene.And AR session also have camera and your scene have main camera with profiler & renderer. i added on arcamera but it cant works.Please help me....
     
  19. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi,

    Fluid rendering uses screen-space ellipsoid splatting, which is akin to deferred rendering. Most mobile devices are extremely fill-rate limited, so you will need to use downsampling for fast rendering. See:
    http://obi.virtualmethodstudio.com/tutorials/fluidrendering.html

    Depending on how ARFoundation works and how it blends the scene with the camera feed, you might need to modify the fluid shaders to work in conjunction with AR.

    Also note that we don't offer support trough the Unity forums. We have our own support channels (Obi forums and support email), so please use them if possible.
     
    mitesh123 likes this.
  20. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    @arkano22 I bought obi Rope some time ago, We just waited to improve it to our game the problem is that We are on 2018.4 and I saw your product is no more downloadable for that version. Why is like that? Is there any version that work on 2018.4 or if not could we ask for refund? Best Regards
     
  21. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi Jakub,

    I answered your support email, check your inbox ;). cheers!
     
  22. DevATsci

    DevATsci

    Joined:
    Jul 23, 2020
    Posts:
    48
    Hi @arkano22 were using ObiRopes. At compile time the build crashes with this error

    Code (CSharp):
    1. Shader error in 'Obi/Particles': invalid subscript '_ShadowCoord' at line 92 (on xboxone)
    2.  
    3. Compiling Vertex program with DIRECTIONAL SHADOWS_SHADOWMASK LIGHTPROBE_SH
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
    5.  
    This line of code is highlighted in the Particleshader.shader script

    Code (CSharp):
    1.                 UNITY_LIGHT_ATTENUATION(atten,i,0);
    Were using D3D12 on an Xbox1x to compile (this error also happens on D3D11). Can you help with the workaround please?
     
  23. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    I'm assuming you're using an older version of Obi, since line 92 in the shader no longer does attenuation. There should be a "nolightmap" definition in the #pragma at line 21:

    Code (CSharp):
    1.  #pragma multi_compile_fwdbase nolightmap
    If it's already there, then the problem might be something else. Depending on what kind of rendering options you're using, unity might not be defining _ShadowCoord internally, which is used for shadow mapping. It's unclear to me in what cases this might not be defined, though.

    Simplest workaround is to just replace:
    Code (CSharp):
    1.                 UNITY_LIGHT_ATTENUATION(atten,i,0);
    with
    Code (CSharp):
    1.                float atten = 1;
    This will remove shadow support from the particle shader, but it's highly unlikely you're using it for a release build (as it's mostly used for debugging/visualization in editor).
     
    DevATsci likes this.
  24. DevATsci

    DevATsci

    Joined:
    Jul 23, 2020
    Posts:
    48
    Hi @arkano22

    Thanks for the perfect response. Always nice to meet a Pro. I got the build working by selecting "Build this platform" in the inspector on the particleshader.shader script which is where the above lines of code come from. However your bug fix i also inputted and it worked on both accounts. Always good to have 2 fixes instead of one.

    Thank you for your assistance.
     
    Last edited: Oct 26, 2020
  25. xpxilom

    xpxilom

    Joined:
    Aug 28, 2014
    Posts:
    30
    I am creating a game. It's about untangling rope

    Almost everything is ready.

    But I don't know how to save the string positions.
    that is, the knots already made.

    When I play unity, I can create the knots, but how can I save the positions of the knots?
     
  26. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    To get/set particle properties such as positions/velocities, you can use the particle API. See:
    http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html
     
  27. amoka

    amoka

    Joined:
    Dec 18, 2015
    Posts:
    58
    Hi,

    What is the situation with parachutes today? Can they easily be made with Obi Cloth and Obi Rope? I read in this forum that someone tried it but had to cancel this solution due to bad performance on mobile. I would need it for PC VR.

    I just need a simple circular parachute, like dropping a crate from the sky: have the parachute open, slowly descend and then collapse flat on the ground or the crate.
     
  28. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Parachutes are completely doable. It all depends on the resolution of the mesh and your solver settings. A relatively simple mesh with coarse self collisions is fine. If you intend to have really dense mesh deformation and fine self-collisions, this just isn't feasible in any platform. (not just with Obi, but with any cloth simulator).

    It also depends on whether parachute dynamics affect your gameplay in any way. If it's just for eye candy, this might be overkill. A simple upwards force on the object makes for a fine parachute most of the time, if all you want is for the object to fall slower while the parachute is open.
     
    Last edited: Dec 16, 2020
  29. amoka

    amoka

    Joined:
    Dec 18, 2015
    Posts:
    58
    The parachute does not necessarily need to apply physics forces, so it may remain eye candy, but the blow-up and collapse part would be nice to look acceptably realistic.

    How many vertices do you think for a simple mesh and how many for a dense mesh?
    Would collapsing on the ground work without self-collision?

    And what about the ropes of the parachute, would I need to use some other tool for them, too, like Obi Rope? Or is Obi Cloth able to handle them, too? Like long strips of cloth?

    This is a nice example of what I'm after only that it is animated in 3dsMax, and the ropes are cheated as cloth strips:
     
  30. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Once you're simulating cloth dynamics, forces exerted on the object kinda come for free. So either you fake both the cloth and the object forces, or you simulate them.

    Below 1000 vertices would be ideal. However this is not the only deciding factor: timestep length, iteration count, substepping, self collisions, collisions, etc all have an impact on performance and quality, so depending on what's acceptable you might go higher on poly count and lower on quality, or viceversa.

    It all really boils down to what your ms/frame budget is. If you have 8 ms of frame time to spare (this is seldom the case in VR), and there's only one parachute in your scene, you can go nuts. Typically it's more about 2-3 ms budget tops, so you want to keep things tight. Deformable physics simulation is expensive, so it must be used when necessary, not when it just looks cool.

    Yes, collapsing would work fine. However the cloth would not collide with itself, so you risk it crumpling into a triangle puddle on the floor. Depending on your mesh/textures, this can be acceptable. For instance, if both sides of the parachute have similar colors/patterns, it can be hard to tell if it's self-intersecting at all.

    Long strips of cloth are fine in this case.

    Will make an example in Obi and collect some metrics for you. At least you will know if it's in the ballpark of what you can afford in terms of performance.
     
    Last edited: Dec 17, 2020
  31. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    I made a simple parachute video (790 vertices). You can find perfomance metrics in the video description:
     
    Last edited: Dec 17, 2020
    hopeful and IsDon like this.
  32. toddw

    toddw

    Joined:
    May 9, 2010
    Posts:
    130
    Hi @arkano22,

    I'm working on a project in which I would like to be able to support up to 10 or so bipedal skinned humanoid characters on screen at a time. Some of these characters will have dynamically animated clothing, such as a loin cloth on a zombie. With unity's cloth component in 2020.1.2f1 I noticed there's a huge frame rate spike when I call gameobject.SetActive(true) on any characters that have a Unity cloth component implemented. The loin cloth in this case is about 1,800 vertices, so it's fairly optimized. As a result, I determined Unity's cloth is not a viable option and so I bought Obi Cloth.

    I was able to get the ObiSkinnedCloth working per your tutorial here
    . Unfortunately when I ran the game and had about 5 enemies spawned I found my FPS basically died, down from 60 to somewhere around 5 FPS. I spent some time profiling and noticed the primary issue is the repeated heap allocations occurring in the scope of the ObiUpdater.cs > BeginStep, Substep and EndStep methods. I was able to resolve some of the heap allocations by changing the List<IObiJobHandle> handles list to a class level buffer array and just tracking the count of assigned elements in a class level integer, which did improve the frame rate, but unfortunately the call to ISolverImpl.Substep is still creating instances of OniJobHandle every frame, which allocates from the heap and kills performance. The OniJobHandle class then gets down into you Oni API, which I can't see obviously since it's a dll, nor can I change.

    So given that there is no quick fix that I can accomplish on my end, I'd like to know if you have any plans to boost performance by making your cloth implementations use memory pooling instead of pulling from the heap every frame, because unfortunately as it stands right now there's no way I could use this on any platform for more than 1 character at a time.
     
  33. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi,

    OniJobHandle is just a handle for a job, so even though it is allocated on the heap, the performance hit probably comes from the workload being done by the job itself. There's no way performance can go from 60 to 5 fps just from handle allocations, at least not with normal usage patterns.

    Also, keep in mind that Unity cloth executes in LateUpdate(), and so it is impervious to death spiraling. Obi on the other hand uses fixed-timestepping by default (ObiFixedUpdater), so performance can be affected my multiple FixedUpdate() calls per frame. Check that FixedUpdate() is called only once or twice at most every frame. Note that you can always use ObiLateUpdater instead, to mimic Unity's cloth update scheme (which is a bit hacky, tbh).

    Have you tried using the Burst backend instead? It uses Unity's own multithreaded job system and the Burst compiler. Full source code is also included, so you can inspect it closer/customize it if needed. No need to use Oni except for backwards-compatibility purposes, as it will be deprecated at some point. See: http://obi.virtualmethodstudio.com/tutorials/backends.html

    Either way, the way you describe both your Unity cloth and your Obi implementations sounds off. 1800 vertices for a cloth object is quite a lot, specially if you're having 10 of these on screen at the same time. That's 18000 simulated vertices per frame, and probably x2-x3 as many constraints (roughly, edges) that need to be evaluated multiple times per frame, depending on the amount of substeps/iterations you’re using. With the default 1 substep - 3 iters, that’s easily +100k constraint evals/frame. No CPU-based cloth simulator you find is going to be able to handle that in a reasonable amount of time.

    Lastly, please use the official support means: Obi forums or support email. I seldom check the Unity forums.

    cheers,
     
    Last edited: Jan 2, 2021
  34. toddw

    toddw

    Joined:
    May 9, 2010
    Posts:
    130
    Thanks for the response and sorry for not using your official support forum, I'll be sure to do that in the future. I didn't think 1,800 was that much but I've been wrong before... To be clear, in a scene with nothing else but the enemy playing an idle animation and the 1,800 vert loin cloth mesh using an ObiSkinnedCloth, ObiSkinnedClothRenderer, ObiSolver with Burst backend and ObiLateFixedUpdater, the FPS will drop to 10 with 8 instances of this character in the scene.

    Here is a screen shot:
    upload_2021-1-3_2-24-43.png

    Here is the profiler stats in this scene:
    upload_2021-1-3_2-25-31.png


    Here is the same scene with all 4 of the obi components disabled:
    upload_2021-1-3_2-27-25.png

    And the profiler with all the obi components disabled:
    upload_2021-1-3_2-28-25.png

    Problem is, this is best case scenario where nothing else is going on in the scene, but in the actual game there is naturally a substantial amount more overhead, so these heap allocations really count there.

    But as you said, this scene is simulating 14,400 vertices due to the 8 loin cloths in it, so if I'm over budget then I'll have to focus on optimizing the loin cloth mesh. Unfortunately I don't know what that budget is, so I guess I'll have to do some experimentation to see what is reasonable. That said, Obi still may not be feasible for me if reducing the vertex count doesn't reduce the heap allocations respectively, but I'll keep my fingers crossed.

    Thanks.
     
  35. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    By using a ObiLateFixedUpdater for each character instance, you're forcing each solver to wait for all other solvers to finish their simulation before starting its own. This negates many multithreading benefits and makes your simulation behave as if running single-threaded. You can tell by the many FixedUpdate.ScriptRunDelayedFixedFramerate calls in your profiler.

    Just use one Updater component for all solvers in your scene, as indicated in the manual:
    http://obi.virtualmethodstudio.com/tutorials/updaters.html

    The idea is that an updater schedules all simulation tasks for as many solvers as you need, at a given point during Unity's frame update cycle (FixedUpdate, Update, LateUpdate, or custom, depending on which updater subclass you use). Then, it waits for all these tasks to be completed before continuing.

    Here's an overview of Obi's architectural design and the role played by each core component:
    http://obi.virtualmethodstudio.com/tutorials/bigpicture.html

    1800 verts for the loin cloth is definitely a lot. Cloth simulation works by tracking the motion of each individual vertex in the cloth (a "particle") and then constraining their position/velocity relative to each other. This is similar to adding a rigidbody component to each vertex in the mesh, then creating a spring joint for each edge in the mesh. Of course there's lots of optimizations and situational shortcuts used just to make it tractable, but if you picture it this way, it will become apparent why cloth simulation is so expensive. This manual page describes the core principles of the simulation:
    http://obi.virtualmethodstudio.com/tutorials/convergence.html

    For context, here's a Gamasutra article detailing cloth simulation in Alan Wake:
    https://www.gamasutra.com/view/feature/132771/the_secrets_of_cloth_simulation_in_.php
    It's 10 years old, but things haven't changed so much since then when it comes to realtime clothing. You can see the main character's jacket sim mesh has maybe 100 vertices. If you've played Dark Souls 3 for instance, you'll notice many enemy characters feature cloth simulation in the form of capes, pants, etc, and the poly count for them is usually quite low as well (no fine wrinkles/draping).

    For high-detail cloth in a single character, Id' say 400-500 vertices is a reasonable amount as of today. In your case, you can probably get away with much less as the loin cloth is basically a rectangle. Keep in mind that high-res meshes will also decrease convergence due to the higher amount of constraints, which means the cloth will look stretchy. You will need to spend more iterations/substeps on constraints to counteract that (in Unity's built-in cloth, you'd use higher solver frequency).

    A word of warning though: as far as raw performance goes, Unity's built-in cloth cannot be beaten. It's as simple as cloth simulation can get and it makes many aggressive assumptions, but as a result lacks a lot of important features and doesn't look very good. If you gravitated towards Obi looking for better performance, it's very likely you will be disappointed. Obi is extremely fast for what it does, but it does a lot more than the built-in solution, and cuts less corners. Let me know if you feel like getting a refund at any point.

    cheers!
     
    Last edited: Jan 3, 2021
    manpower13 likes this.
  36. toddw

    toddw

    Joined:
    May 9, 2010
    Posts:
    130
    Wow, you're absolutely right, I got a dramatic improvement in performance by using a single ObiLateFixedUpdater, sorry I admittedly didn't read much of the manual but rather went by your tutorial video instead.

    upload_2021-1-3_14-0-44.png

    Thanks for offering but I don't need a refund, you deserve to be compensated for your hard work. Besides even if I don't end up using Obi for character clothing I do like the blueprint painting tool way better than Unity's which I find to be very cumbersome and buggy, so I'll likely use Obi for other environmental cloth simulations. All in all I just need to spend some time creating optimized clothing rather than using the high poly stuff I get from DAZ3D.

    Thanks!
     
  37. toddw

    toddw

    Joined:
    May 9, 2010
    Posts:
    130
    Turns out I was able to optimize the Loin Cloth down to 410 verts in Character Creator 3 using the InstaLOD tool in a matter of minutes. Now I've got 15 instances of this character on screen with simulated cloth and maintaining 80 FPS. Not sure how it will scale in game with all the other resource usage, but this looks promising, thanks again!

    upload_2021-1-3_15-17-20.png
     
    hopeful likes this.
  38. sedate

    sedate

    Joined:
    Aug 6, 2020
    Posts:
    2
    Hello,
    I am developing a simulator of medical robots. I found your amazing demo that using the Obi Rod to simulate a spring.I would like to use your Obi Rope/Rod to model the catheter in my medical robot simulator. And I would like to make sure that if the rope/rod can push an object that attach to it acting as real catheter.
    Thanks.
    Looking forward to your reply!
     
  39. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Yes it can, full two-way coupling with rigidbodies is supported both for collisions and attachments.
     
  40. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    IsDon, hopeful and look001 like this.
  41. Vikibaba

    Vikibaba

    Joined:
    Feb 24, 2017
    Posts:
    2
  42. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    There’s barely any physics going on for a typical bomb fuse, unless the bomb is moving around and/or the fuse needs to interact with nearby colliders/user input.

    If all you want is a tubular mesh that gets consumed, there’s no need to use Obi Rope at all, it would only complicate matters. A simple tube mesh and a grayscale ramp in the alpha channel will allow you to use the alpha clip threshold to do the “consume” effect.
     
  43. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    I have a question, this appears to do exactly what I want but my character uses more than 4 bones for the SkinWeights Looking around the support forum I've found some reference to the fact that more than 4 bones are not supported. Is this true?
     
  44. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    True. Currently only 1, 2 or 4 weights are supported.
     
  45. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    thank you, can't be used for my character but offcourse still useful for the other objects in scene :)
     
  46. sedate

    sedate

    Joined:
    Aug 6, 2020
    Posts:
    2
    Hi, I have purchase the obi rope, and tried to attach an obi rod to my dynamiclly bending cylinder.
    I want the obi rod to push my cylinder to move, and meanwhile the cylinder's movement or rotation can also affect the obi rod, so I chose dynamic particle attachment. I attach my cylinder to an obi particle using the obi particle attament component, choose the dynamic type, check the constriant orientation, set the compliance as 0, set the break threshold as Infinity. Also, I have made the mass ratio between the cylinder and the particle as small as posible just following the official advice.

    The reslut I hope to achieve is like that, the cylinder and rod are glued together. But I found that my cylinder and obi rod cannot tightly joined together and have a slight jitter and obvious offset.


    I cannot figure out what's the problem. Is there anything wrong? Or can the obi rod be joined with my cylinder like they are being glued together?

    Thanks!
     
  47. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi there,

    Make sure the rod is not colliding aganist the cylinder. This situation along with the solution (use phases to disable collisions between the attached part of the rod/rope and the collider) is described at the end of this page:

    http://obi.virtualmethodstudio.com/tutorials/pinconstraints.html
     
  48. 5c4r3cr0w

    5c4r3cr0w

    Joined:
    Mar 8, 2016
    Posts:
    35
    Hello,

    I just wanted to ask How can I get OnCollissionEnter event when Particles collides with collider?
     
  49. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi,

    See:
    http://obi.virtualmethodstudio.com/tutorials/scriptingcollisions.html

     
  50. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    In obi rope when i am set my rope. The rope shape is not set as original shape. if I will do the dumping is 1 . it's perfect but the rope look not realistic.

    please any one can help me.
    Thanks in advance.