SteamVR 2.2 + nvidia Flex errors
See original GitHub issueI am trying to use the SteamVR Plugin with the nvidia Flex fluid renderer. On their own, they all work fine. But when combined, there are runtime errors.
Setup:
- Unity 2018.3.6f1 (latest at this time)
- SteamVR Plugin 2.2 (latest from asset store)
- nvidia Flex for Unity 1.0.5 (latest from asset store)
Steps to reproduce:
- Create a new Unity project
- Import the SteamVR Plugin from the store
- Import nvidia Flex for Unity from the store
- Turn on your VR system (HTC Vive in my case)
- Open the flex no.9 Fluid Renderer sample scene, press Play and observe the fluid flow fine in VR
- Now disable the
Camerain that scene and drop in the[CameraRig]from the SteamVR prefabs - Press Play now and observe that the fluid stops flowing after a few seconds and the following errors appear:
ArgumentException: ComputeBuffer.SetData() : Accessing 35100 bytes at offset 0 for Compute Buffer of size 35000 bytes is not possible.
UnityEngine.ComputeBuffer.SetData (System.Array data) (at C:/buildslave/unity/build/Runtime/Export/ComputeShader.bindings.cs:124)
NVIDIA.Flex._auxFlexDrawFluid.UpdateMesh (NVIDIA.Flex.FlexContainer+ParticleData _particleData) (at Assets/NVIDIA/Flex/Auxiliary/_auxFlexDrawFluid.cs:247)
NVIDIA.Flex.FlexContainer.UpdateDrawFluid (NVIDIA.Flex.FlexContainer+ParticleData _particleData) (at Assets/NVIDIA/Flex/Assets/FlexContainer.cs:788)
NVIDIA.Flex.FlexContainer.UpdateSolver () (at Assets/NVIDIA/Flex/Assets/FlexContainer.cs:696)
NVIDIA.Flex.FlexContainer.FixedUpdate () (at Assets/NVIDIA/Flex/Assets/FlexContainer.cs:605)
NVIDIA.Flex.FlexScene.FixedUpdate () (at Assets/NVIDIA/Flex/Helpers/FlexScene.cs:68)
LogWarning - Mapping a buffer that was already mapped
File - ..\..\dx\utils.cpp (62)
UnityEngine.Debug:LogError(Object)
NVIDIA.Flex.FlexContainer:ErrorCallback(ErrorSeverity, IntPtr, IntPtr, Int32) (at Assets/NVIDIA/Flex/Assets/FlexContainer.cs:491)
NVIDIA.Flex.FlexExt:MapParticleData()
NVIDIA.Flex.FlexContainer:UpdateSolver() (at Assets/NVIDIA/Flex/Assets/FlexContainer.cs:688)
NVIDIA.Flex.FlexContainer:FixedUpdate() (at Assets/NVIDIA/Flex/Assets/FlexContainer.cs:605)
NVIDIA.Flex.FlexScene:FixedUpdate() (at Assets/NVIDIA/Flex/Helpers/FlexScene.cs:68)
I understand that it seems to be Flex “crashing” here and not SteamVR, which is why I first posted this issue on the nvidia forums, however as SteamVR is implicated (Flex works fine without it) I am here to see if SteamVR Plugin could be improved in some way to not affect other such systems.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Flex Unity v1.0.5 + SteamVR: Fluid Error - XR – VR/AR/MR
I downloaded Flex v1.0.5 (latest as of Feb 2019), opened example no.9 Fluid Renderer, pressed Play and I can see the fluid work...
Read more >Any fix for the constant crashing with SteamVR and Nvidia ...
Two weeks ago I started having the exact same issue on a GTX1070 and Acer WMR. Turning off Reprojection (Motion Smoothing) fixed it...
Read more >My 3090 Settings for my G2 (2.7.11) - DCS Forum
I use fpsVR for measurement. This guide is aimed at Intel, Nvidia, SteamVR WMR users, others you will be able to get some...
Read more >OpenComposite OpenXR | Page 7
So AMS2 still launches through Steam VR but OpenXR... ... A surprisingly common problem is the keyboard not working properly.
Read more >ALVR
ALVR - Air Light VR. Stream VR games from your PC to your headset via Wi-Fi. This is the Oculus Quest app, that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Wow i managed to fix this :
The flicker happened because the SetData needs to be called in all cases, the code can be simplified by removing the else, and writing only one SetData at the end.
Now for me this works, i dont really know if this doesnt create side effects, i’ve read somewhere on unity forums that recreating ComputeBuffer every frame is not a good idea. Thats as far as my knowledge goes on this topic.
I hope this helps.
The solution by @reforia keeps the number of drawn particles at the maximum. This becomes a problem when deactivating the fluid source, as the fluids will not despawn until every single one of them has reached the end of its lifetime. Instead I propose this workaround.
Start with a fresh (unmodified) _auxFlexDrawFluid.cs, and simply replace:
at line 245 with:
The crash happened because
indicesdoesn’t appear to dynamically change size. So if our max particles is 4000, thenindiceswill have a length of 4000 as long as there’re any particles around.indexCounton the other hand directly reflects how many particles are alive, which may for instance be 3672. So when copying the indices we need to limit what we’re copying by the size ofm_indexBuffer. Creating a newm_indexBufferto match the maximum amount of particles on the other hand causes particles to visually stay in the scene.