Search Unity

[RELEASED] GPU Instancer

Discussion in 'Assets and Asset Store' started by LouskRad, May 3, 2018.

  1. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Thank you for your kind words!

    I am not sure why you are getting this error. I assumed it was caused by the other issues you mentioned. We can investigate them if you can email us a sample.

    Hi there,
    Thank you for reporting this issue, we will make the necessary changes on the next update.
    When you change the fov, you will need to call CalculateHalfAngle method again, if you want the LODs to be updated.
     
  2. WeltenbauerRenn

    WeltenbauerRenn

    Joined:
    Jun 20, 2017
    Posts:
    40
    I just had an issue with the GPUIstancerHiZOcclusionGenerator. We do a render to texture for a character portrait on a different camera. For some reason that screws up the size of the _tempDepthTextureForTex2DArray RT.

    Resulting in spamming of
    Code (CSharp):
    1. [Assets/ThirdParty/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs line 263]
    2.  
    3. Graphics.CopyTexture called for entire mipmaps with different memory size (source (Depth) is 1883952 bytes and destination (Depth) is 16588800 bytes)
    4. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    5. UnityEngine.Graphics:CopyTexture (UnityEngine.Texture,int,int,UnityEngine.Texture,int,int)
    6. GPUInstancer.GPUInstancerHiZOcclusionGenerator:UpdateTextureWithComputeShader (int) (at Assets/ThirdParty/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:263)
    7. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRendering (UnityEngine.Camera) (at Assets/ThirdParty/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:250)
    8. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRenderingSRP (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at Assets/ThirdParty/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:196)
    9.  
    I could could fix this by moving the width and height check in HandleScreenSizeChange() out of the if. For some reason the hiZTextureSize not changed.

    Code (CSharp):
    1. Vector2 newScreenSize = GetScreenSize();
    2. if (newScreenSize != hiZTextureSize)
    3. {
    4.     CreateHiZDepthTexture();
    5.  
    6.     //CUSTOM CODE START
    7.  
    8. // #if UNITY_2018_3_OR_NEWER
    9. //                 if (_isDepthTex2DArray && unityDepthTexture != null && _tempDepthTextureForTex2DArray != null &&
    10. //                     (unityDepthTexture.width != _tempDepthTextureForTex2DArray.width || unityDepthTexture.height != _tempDepthTextureForTex2DArray.height))
    11. //                 {
    12. //                     _tempDepthTextureForTex2DArray.Release();
    13. //                     _tempDepthTextureForTex2DArray = null;
    14. //                 }
    15. // #endif
    16. }
    17.  
    18. #if UNITY_2018_3_OR_NEWER
    19. if (_isDepthTex2DArray && unityDepthTexture != null && _tempDepthTextureForTex2DArray != null &&
    20.     (unityDepthTexture.width != _tempDepthTextureForTex2DArray.width || unityDepthTexture.height != _tempDepthTextureForTex2DArray.height))
    21. {
    22.     _tempDepthTextureForTex2DArray.Release();
    23.     _tempDepthTextureForTex2DArray = null;
    24. }
    25. #endif
    26. //CUSTOM CODE END
     
  3. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    in our gameobjectless pipeline, we don't even use a GPUI Prefab Manager in the scene as we register prototypes as they are needed. Yesterday I updated GPUInstancer to the new version and I stumbled upon I problem I didn't have any memory about. GPUI wasn't recognising our instanced custom shaders anymore, they were not found among the bound shaders and therefore GPUI was falling back to standard shaders (
    GetInstancedShader was failing). I had to put a PrefabManager in the scene and drag and drop all the prefabs again in there to magically solve the problem. I could remove the prefab manager from the scene after, so it's all good for us, but I don't remember why we need to do this to register the shader bindings (somehow, I didn't understand/I forgot the mechanism).
    Is it normal we have to do this to register the shader bindings?
     
  4. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Thank you for the feedback. We will make this change for the next update.

    Shader bindings are located under GPUInstancer/Resources/Settings/GPUInstancerShaderBindings.asset.
    The references would be lost if for any reason this file was removed/corrupted.
     
  5. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    yes my questions was more about: should I expect the shader bindings to be automatically regenerated or I have to do the manual process to create the prefab manager and register the gameobjects to generate the bindings even if we don't use the prefab manager itself in our gameobjectless pipeline?
     
  6. jpdoiron-Bkom

    jpdoiron-Bkom

    Joined:
    Oct 15, 2020
    Posts:
    1
    Hey Guys, hope you are all allright.

    I've been playing with GPUI on switch, most of it works (ish) , except plenty of random instances doesn't show. I was wondering if you had a wild guess on what could go wrong. Shader seems to works, it doesn't crash of throw warning. It just doesn't render everything.

    Any suggestion would be welcomed,

    upload_2021-6-20_17-27-35.png
     
    newguy123 likes this.
  7. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Code (CSharp):
    1.  public static GPUInstancerPrefabPrototype ClonePrototypeAtRuntime(GPUInstancerPrefabManager prefabManager, GPUInstancerPrefabPrototype originalPrototype)
    2.         {
    3.             GPUInstancerPrefabPrototype clone = ScriptableObject.Instantiate(originalPrototype);
    4.             prefabManager.prototypeList.Add(clone);
    5.             GPUInstancerRuntimeData runtimeData = prefabManager.InitializeRuntimeDataForPrefabPrototype(originalPrototype);
    6.             GPUInstancerUtility.InitializeGPUBuffer(runtimeData);
    7.             return clone;
    8.         }
    We are testing the code you copy and pasted to us which is present also in version 1.5 and after some work, we agreed that we can't understand what's going on.

    I would expect that this line:

    Code (CSharp):
    1. GPUInstancerRuntimeData runtimeData = prefabManager.InitializeRuntimeDataForPrefabPrototype(originalPrototype);
    would actually be:

    Code (CSharp):
    1. GPUInstancerRuntimeData runtimeData = prefabManager.InitializeRuntimeDataForPrefabPrototype(clone);
    as, as we understand, now clone is just invalid? However, even with the fix we propose, it doesn't work.

    The fix proposed by us won't work, because this code still expect the Gameobject to exist at this point, exactly at this method:

    Code (CSharp):
    1. public virtual GPUInstancerRuntimeData InitializeRuntimeDataForPrefabPrototype(GPUInstancerPrefabPrototype p, int additionalBufferSize = 0)
    2. {
    3.     if (!GPUInstancerConstants.gpuiSettings.IsStandardRenderPipeline())
    4.         p.useOriginalShaderForShadow = true;    GPUInstancerRuntimeData runtimeData = GetRuntimeData(p);
    5.     if (runtimeData == null)
    6.     {
    7.         runtimeData = new GPUInstancerRuntimeData(p);
    8.         if (!runtimeData.CreateRenderersFromGameObject(p))
    9.             return null;
    What are we misunderstanding? We know that the data must be there, but it seems that the clone method is just too simple to work as intended.

    It does also make sense to use InitializeRuntimeDataForPrefabPrototype with the original prototype to fetch a valid runtime data, but then this is not copied in the clone object. I guess this would be a more valid approach, but method to clone a runtime data doesn't exist and it seems to involve quite a fair amount of work.
     
    Last edited: Jun 21, 2021
  8. Wenon

    Wenon

    Joined:
    Mar 18, 2018
    Posts:
    19
    Hello, how can I hide temponary object? I made a house building and the wall consists of single walls rendered with gpu instancer and you can also build on second floor but I have to hide the whole floor with objects as the player goes down to the ground floor in build mode and setactive to false just doesn't work. Is there any other way?
     
  9. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Hi Sebastiano,

    You are right that it is unnecessary to initialize the original prototype, we will edit this API method.
    Cloning the runtime data would be complex and unreliable. I would recommend to create a temporary GameObject and then destroy it after initialization.

    Here is an example:

    Code (CSharp):
    1. GPUInstancerPrefabPrototype clonedPrototype = ScriptableObject.Instantiate(originalPrototype);
    2. prefabManager.prototypeList.Add(clonedPrototype);
    3. // Create and edit your temporary GO here
    4. clonedPrototype.prefabObject = new GameObject();
    5. clonedPrototype.prefabObject.AddComponent<MeshFilter>().mesh = cloneMesh;
    6. clonedPrototype.prefabObject.AddComponent<MeshRenderer>().material = cloneMat;
    7. // Initialize to create the runtimeData for the cloned prototype
    8. GPUInstancerAPI.InitializeWithMatrix4x4Array(prefabManager, clonedPrototype, cloneMatrix4x4Array);
    9. // Destroy the temporary GO
    10. Destroy(clonedPrototype.prefabObject);
    Hi there,

    GPUI officially does not support Switch. Mainly because of technical limitations (e.g. Switch has limited support for Compute Shaders and UAV buffers). So we can not offer a reliable solution for this.

    You can try limiting the Compute Buffer usage by enabling Use Custom Rendering Settings from "Edit -> Preferences -> GPU Instancer" under "Rendering Settings [ADVANCED]". But as I said Switch is not supported nor tested, so no guarantees.

    Hi there,

    You can use the Auto. Add/Remove Instances feature under "Runtime Settings".
     
    jpdoiron-Bkom likes this.
  10. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    thank you very much for the help! We will investigate your proposed solution, but at glance, I am not sure where cloneMesh and cloneMat come from.
     
  11. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    cloneMesh and cloneMat is just an example. If you wish for example to use a different mesh and material for the cloned prototype. You can also Instantiate any GO and then destroy it after initialization.
     
  12. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    ok my problem at this point is either I can get the original mesh and material from the GPUI internal datastructures (I reckon I should be able to) or I have to store them myself. However, if I store them myself, then maybe there is no point to get rid of the original prefab, we are doing this operation mainly to save memory.
     
  13. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    I think easiest would be to keep one template prefab and use it to make new prototypes. Memory allocation for a prefab is very small if you do not have complex components that store a lot of data on it.
     
    sebas77 likes this.
  14. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    ok yes, it seems that's the wisest choice. Thank you.
     
  15. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    121
    Hey, I am getting a ton of errors since updating to the newest version.

    Code (CSharp):
    1. CSInstancedCameraCalculationKernel.compute: Kernel at index (0) is invalid
    2. 0x00007ff79114dc5c (Unity) StackWalker::GetCurrentCallstack
    3. 0x00007ff791156039 (Unity) StackWalker::ShowCallstack
    4. 0x00007ff79262fd2c (Unity) GetStacktrace
    5. 0x00007ff793720983 (Unity) DebugStringToFile
    6. 0x00007ff7909bd10c (Unity) ComputeShader::BeforeDispatch
    7. 0x00007ff7909c0981 (Unity) ComputeShader::DispatchComputeShader
    8. 0x00007ff791181296 (Unity) ComputeShader_CUSTOM_Dispatch
    9. 0x00000261edc3cd70 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.ComputeShader:Dispatch (UnityEngine.ComputeShader,int,int,int,int)
    10. 0x00000261edc3bd93 (Mono JIT Code) [GPUInstancerUtility.cs:535] GPUInstancer.GPUInstancerUtility:DispatchCSInstancedCameraCalculation<T_REF> (UnityEngine.ComputeShader,int[],T_REF,GPUInstancer.GPUInstancerCameraData,bool,bool,bool)
    11. 0x00000261edc3ad5b (Mono JIT Code) [GPUInstancerUtility.cs:355] GPUInstancer.GPUInstancerUtility:UpdateGPUBuffer<T_REF> (UnityEngine.ComputeShader,int[],UnityEngine.ComputeShader,int[],T_REF,GPUInstancer.GPUInstancerCameraData,bool,bool,bool,bool)
    12. 0x00000261edc3a96b (Mono JIT Code) [GPUInstancerUtility.cs:318] GPUInstancer.GPUInstancerUtility:UpdateGPUBuffers<T_REF> (UnityEngine.ComputeShader,int[],UnityEngine.ComputeShader,int[],System.Collections.Generic.List`1<T_REF>,GPUInstancer.GPUInstancerCameraData,bool,bool,bool,bool)
    13. 0x00000261edc396f3 (Mono JIT Code) [GPUInstancerManager.cs:566] GPUInstancer.GPUInstancerManager:UpdateBuffers (GPUInstancer.GPUInstancerCameraData)
    14. 0x00000261edc39013 (Mono JIT Code) [GPUInstancerManager.cs:278] GPUInstancer.GPUInstancerManager:LateUpdate ()
    15. 0x00000261edc38f1b (Mono JIT Code) [GPUInstancerPrefabManager.cs:82] GPUInstancer.GPUInstancerPrefabManager:LateUpdate ()
    16. 0x00000261edc3f05b (Mono JIT Code) [GPUICrowdManager.cs:249] GPUInstancer.CrowdAnimations.GPUICrowdManager:LateUpdate ()
    17. 0x0000026378ddfe50 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    18. 0x00007ffb7a9ae640 (mono-2.0-bdwgc) [mini-runtime.c:2812] mono_jit_runtime_invoke
    19. 0x00007ffb7a932ac2 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    20. 0x00007ffb7a93bb1f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    21. 0x00007ff790fc7cf4 (Unity) scripting_method_invoke
    22. 0x00007ff790fc0645 (Unity) ScriptingInvocation::Invoke
    23. 0x00007ff790f83cb4 (Unity) MonoBehaviour::CallMethodIfAvailable
    24. 0x00007ff790f83dbc (Unity) MonoBehaviour::CallUpdateMethod
    25. 0x00007ff790459208 (Unity) BaseBehaviourManager::CommonUpdate<LateBehaviourManager>
    26. 0x00007ff790462fca (Unity) LateBehaviourManager::Update
    27. 0x00007ff7908c6aea (Unity) `InitPlayerLoopCallbacks'::`2'::PreLateUpdateScriptRunBehaviourLateUpdateRegistrator::Forward
    28. 0x00007ff7908a7f7c (Unity) ExecutePlayerLoop
    29. 0x00007ff7908a8053 (Unity) ExecutePlayerLoop
    30. 0x00007ff7908aef09 (Unity) PlayerLoop
    31. 0x00007ff791cce621 (Unity) PlayerLoopController::UpdateScene
    32. 0x00007ff791cb3f43 (Unity) PlayerLoopController::EnterPlayMode
    33. 0x00007ff791cc97bd (Unity) PlayerLoopController::SetIsPlaying
    34. 0x00007ff791ccc524 (Unity) Application::TickTimer
    35. 0x00007ff792639521 (Unity) MainMessageLoop
    36. 0x00007ff79263d561 (Unity) WinMain
    37. 0x00007ff7944b5fc6 (Unity) __scrt_common_main_seh
    38. 0x00007ffbe52a7034 (KERNEL32) BaseThreadInitThunk
    39. 0x00007ffbe5bc2651 (ntdll) RtlUserThreadStart
    Code (CSharp):
    1. CSInstancedRenderingVisibilityKernel.compute: Kernel at index (0) is invalid
    2. 0x00007ff79114dc5c (Unity) StackWalker::GetCurrentCallstack
    3. 0x00007ff791156039 (Unity) StackWalker::ShowCallstack
    4. 0x00007ff79262fd2c (Unity) GetStacktrace
    5. 0x00007ff793720983 (Unity) DebugStringToFile
    6. 0x00007ff7909bd10c (Unity) ComputeShader::BeforeDispatch
    7. 0x00007ff7909c0981 (Unity) ComputeShader::DispatchComputeShader
    8. 0x00007ff791181296 (Unity) ComputeShader_CUSTOM_Dispatch
    9. 0x00000261edc3cd70 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.ComputeShader:Dispatch (UnityEngine.ComputeShader,int,int,int,int)
    10. 0x00000261edc3d143 (Mono JIT Code) [GPUInstancerUtility.cs:573] GPUInstancer.GPUInstancerUtility:DispatchCSInstancedVisibilityCalculation<T_REF> (UnityEngine.ComputeShader,int,T_REF,bool,int,int)
    11. 0x00000261edc3aeab (Mono JIT Code) [GPUInstancerUtility.cs:366] GPUInstancer.GPUInstancerUtility:UpdateGPUBuffer<T_REF> (UnityEngine.ComputeShader,int[],UnityEngine.ComputeShader,int[],T_REF,GPUInstancer.GPUInstancerCameraData,bool,bool,bool,bool)
    12. 0x00000261edc3a96b (Mono JIT Code) [GPUInstancerUtility.cs:318] GPUInstancer.GPUInstancerUtility:UpdateGPUBuffers<T_REF> (UnityEngine.ComputeShader,int[],UnityEngine.ComputeShader,int[],System.Collections.Generic.List`1<T_REF>,GPUInstancer.GPUInstancerCameraData,bool,bool,bool,bool)
    13. 0x00000261edc396f3 (Mono JIT Code) [GPUInstancerManager.cs:566] GPUInstancer.GPUInstancerManager:UpdateBuffers (GPUInstancer.GPUInstancerCameraData)
    14. 0x00000261edc39013 (Mono JIT Code) [GPUInstancerManager.cs:278] GPUInstancer.GPUInstancerManager:LateUpdate ()
    15. 0x00000261edc38f1b (Mono JIT Code) [GPUInstancerPrefabManager.cs:82] GPUInstancer.GPUInstancerPrefabManager:LateUpdate ()
    16. 0x00000261edc3f05b (Mono JIT Code) [GPUICrowdManager.cs:249] GPUInstancer.CrowdAnimations.GPUICrowdManager:LateUpdate ()
    17. 0x0000026378ddfe50 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    18. 0x00007ffb7a9ae640 (mono-2.0-bdwgc) [mini-runtime.c:2812] mono_jit_runtime_invoke
    19. 0x00007ffb7a932ac2 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    20. 0x00007ffb7a93bb1f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    21. 0x00007ff790fc7cf4 (Unity) scripting_method_invoke
    22. 0x00007ff790fc0645 (Unity) ScriptingInvocation::Invoke
    23. 0x00007ff790f83cb4 (Unity) MonoBehaviour::CallMethodIfAvailable
    24. 0x00007ff790f83dbc (Unity) MonoBehaviour::CallUpdateMethod
    25. 0x00007ff790459208 (Unity) BaseBehaviourManager::CommonUpdate<LateBehaviourManager>
    26. 0x00007ff790462fca (Unity) LateBehaviourManager::Update
    27. 0x00007ff7908c6aea (Unity) `InitPlayerLoopCallbacks'::`2'::PreLateUpdateScriptRunBehaviourLateUpdateRegistrator::Forward
    28. 0x00007ff7908a7f7c (Unity) ExecutePlayerLoop
    29. 0x00007ff7908a8053 (Unity) ExecutePlayerLoop
    30. 0x00007ff7908aef09 (Unity) PlayerLoop
    31. 0x00007ff791cce621 (Unity) PlayerLoopController::UpdateScene
    32. 0x00007ff791cb3f43 (Unity) PlayerLoopController::EnterPlayMode
    33. 0x00007ff791cc97bd (Unity) PlayerLoopController::SetIsPlaying
    34. 0x00007ff791ccc524 (Unity) Application::TickTimer
    35. 0x00007ff792639521 (Unity) MainMessageLoop
    36. 0x00007ff79263d561 (Unity) WinMain
    37. 0x00007ff7944b5fc6 (Unity) __scrt_common_main_seh
    38. 0x00007ffbe52a7034 (KERNEL32) BaseThreadInitThunk
    39. 0x00007ffbe5bc2651 (ntdll) RtlUserThreadStart
    Including multiple for the crowd extension. About ~146 in total
     
  16. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Please make sure that you have both the latest version of GPU Instancer and GPU Instancer - Crowd Animations in your project. If this is already so, please select both their respective folders in your project, right click on them and choose reimport. This should solve the issue.

    The reason for this is, some Unity versions have an issue with importing compute shaders because of a Unity internal bug. Reimporting them usually fixes it though.
     
  17. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    I am trying to figure out a different behaviour happening after the update.

    upload_2021-6-29_20-57-54.png

    as you can see, at this line (133, GPUInstancerShaderBindings.cs) the originalMaterial has 3 shaderkeywords, however the instancedMaterial has 2:

    upload_2021-6-29_20-58-55.png

    which breaks our rendering.

    I can't figure out why this happens, as it happens right after calling new Material(originalMaterial). It cannot be the intended behaviour.

    However, this code did change since the update, as before the logic was quite different:

    Code (CSharp):
    1. Material instancedMaterial = new Material(GetInstancedShader(originalMaterial.shader.name));
    2. instancedMaterial.CopyPropertiesFromMaterial(originalMaterial);
    it seems that even the following line resets the keywords:

    instancedMaterial.shader = GetInstancedShader(originalMaterial.shader.name);

    so the only workaround I am forced to use even though I don't understand why I should, is this

    Code (CSharp):
    1. Material instancedMaterial = new Material(originalMaterial);
    2.             instancedMaterial.shader         = GetInstancedShader(originalMaterial.shader.name);
    3.             instancedMaterial.shaderKeywords = originalMaterial.shaderKeywords;
    it looks like a unity bug to me.

    Edit: the material cloning fails to copy this field too, so I had to add another line:

    instancedMaterial.renderQueue = originalMaterial.renderQueue;
     
    Last edited: Jun 30, 2021
  18. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi. My projects works good on m1 mac. Zipping and copying same project to windows produced the following error:

    Graphics.CopyTexture called for entire mipmaps with different memory size...

    indicating GPUInstancerHiZOcclusionGenerator.cs script.

    I have done this and exception is gone, in that script, startin on line 241:

    #if UNITY_2018_3_OR_NEWER
    if (_isDepthTex2DArray && unityDepthTexture != null && _tempDepthTextureForTex2DArray == null)
    {
    // _tempDepthTextureForTex2DArray = new RenderTexture(unityDepthTexture.width, unityDepthTexture.height, 24, RenderTextureFormat.Depth);
    RenderTexture tex = (RenderTexture) unityDepthTexture;
    _tempDepthTextureForTex2DArray = new RenderTexture(tex);
    _tempDepthTextureForTex2DArray.dimension = UnityEngine.Rendering.TextureDimension.Tex2D;
    // _tempDepthTextureForTex2DArray.autoGenerateMips=true;//57837820
    _tempDepthTextureForTex2DArray.Create();
    }
    #endif

    So, I commented out the original code, used another override to create the destination texture that takes a reference texture to create settings. But, I am not sure casting like that would cause any problems.

    The exception is gone, but is it safe?
     
  19. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Yes it looks like a unity bug. We rolled this change back with the latest update. We also added a Preference option "Use Original Material When Instanced" that will let you use the original material without creating a copy if the shader was already setup for GPUI (by default it is enabled).
     
    sebas77 likes this.
  20. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    I can't say for sure. You would need to test with different resolutions and Graphics settings. If you can email us a sample project showing the error, we can investigate it.
     
  21. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    @LouskRad I use gpui with the vegetation engine shaders. After updating to the latest version, all my vegetation shaders no longer support indirect instancing. With the past updates i solved the issue by regenerating gpui shaders, however this time it's no longer working.
    Shader generations does not give any errors, i also get he console message that says GPUI support enabled for the shaders.

    Update:
    TheVegetationEngine is able to add instanced indirect support to shaders by it's own, so i resorted in using its tool.
     
    Last edited: Jul 1, 2021
  22. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    Anyone used GPUI together with World Streamer 2 ?

    Also @vlastan when it comes to TVE and GPUI, You dont need to generate shaders for GPUI when using TVE, you only install the settings for the render pipeline u use and NOTHING ELSE :). GPUI will cover that for u when adding GPUI support to ur trees. TVE works well with GPUI as long as u dont use that TVE menu to generate shaders for GPUI.

    Check my post https://forum.unity.com/threads/released-gpu-instancer.529746/page-50#post-6919583
     
  23. tim-schneider

    tim-schneider

    Joined:
    Oct 16, 2018
    Posts:
    1
    We ran into the same problem, and it turns out that all you have to do is double the instance count.

    When in SPI rendering mode Graphics.DrawMeshInstancedIndirect will alternate between rendering instances on the left and right eye. So if you normally render your instances like this [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] in SPI Mode they will be rendered like this [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]. unity_InstanceID will automatically be set to the same value for the left and right eye, so you dont even have to change any shader code.

    Tested on PC in Unity 2020.3.7f1 with HDRP 10.4.0
     
    Last edited: Jul 7, 2021
    GurhanH likes this.
  24. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Thanks for the feedback. We have made a quick test and it looks like it might be possible to make a workaround as you suggested. We will look into providing a generic solution to support SPI rendering mode without changing current GPUI workflows in a future update.
     
  25. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Im aware that Gpui should automatically edit tve shaders, however in my projects that isn't working anymore. Gpui converts the shaders, as it says in the console but simulating terrain details or entering playmode gets me giant grass meshes and 3fps.

    So i had to use that TVE shader settings panel to manually add gpui support. It seemed to work but now i am having problems with the original shaders (the one assigned to the original prefabs).
    All the foliage and trees that were using tve shaders are now invisible in the editor, i can see them in wireframe mode but the material is completely transparent.

    I think that by using the tve shader editing process, i modified the original shaders and now they won't work properly if not managed by gpui. I tried deleting gpui and reinstalling everything but i got to the same point. Clearing shader bindings and regenerating everything did not solve the issue.

    @GurhanH I have reinstalled gpui and tve again (haven't installed gpui shaders from tve) and now i am the point where the original tve shaders are looking fine and the generated gpui are not supporting indirect instanced. What could i do to ensure that gpui is handling properly tve shaders?
     
    Last edited: Jul 8, 2021
  26. kepesh

    kepesh

    Joined:
    Dec 29, 2017
    Posts:
    92
    Hi,
    If I have tons of rocks on a huge terrain (not using terrain details). Will those objects not visible to the camera (far in the distance) still take up memory?
    Thanks
     
  27. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Hi there,
    If you are using HDRP please try following these steps and let us know if it solves the issue:

    1- Make sure your are using the original TVE shaders for HDRP (do not use GPU Instancer setup provided by TVE)
    2- Change the line 2885 on GPUInstancerUtility.cs

    from this:

    additionTextStart = GPUInstancerConstants.gpuiSettings.isHDRP ? "\n#include \"" + includePath + "\"\n#pragma instancing_options procedural:setupGPUI\n#pragma multi_compile_instancing\n" : "";

    to this:
    additionTextStart = GPUInstancerConstants.gpuiSettings.isHDRP ? "\n#include \"Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl\"\n#include \"Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl\"\n\n#include \"" + includePath + "\"\n#pragma instancing_options procedural:setupGPUI\n#pragma multi_compile_instancing\n" : "";

    3- Click on Tools -> GPU Instancer -> Shaders -> Clear Shader Bindings and select "Yes" for both popups.

    Hi there,

    As long as you have GameObjects in your scene they will take up memory (visible or not). Using GPU Instancer by default might reduce some of this memory usage because it disables the mesh renderers. However if memory is a big concern, I would recommend using a no-GameObject workflow with GPUI.
     
  28. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Thank you very much. Doing that solved the issue!
     
  29. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    @GurhanH I have another question. I see that the tree detail manager has a setting to disable light probes, so i have to think that probes are supported, right?
    However i don't see the gpui trees being affected by the probes i have in my scene when going into play mode (the normal unity trees do get shaded by the probes in the editor)

    pROBES.jpg

     
    Last edited: Jul 11, 2021
  30. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    @GurhanH More on light probes:
    In the following video i recorded this strange behaviour i noticed after some playtesting. All the gpui vegetation changes ambient light intensity based on certain camera viewing angles.
    The lighting becomes consistent again when checking the "disable light probes" option in the managers.
    My project is running in HDRP as i mentioned earlier, but i observed the same effect in a built in project.

     
    Last edited: Jul 11, 2021
  31. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Hi there,

    GPU Instancer does not support light probes.
    • Light Probes are not supported (all the instances share the same probe value).
    You can see details of lighting limitations from here.

    Disable Light Probes option is there to disable the usage of a single light probe. You can see descriptions of these options by pressing the "?" icon on the top right corner of the managers or from the online documentation.

    Disable Light Probes: While using Indirect GPU Instancing, by default all the instances share the same probe value. You can disable light probe usage by enabling this option.
     
  32. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    I understand.
    So what would you advise to be the best way of handling illumination in a scene with gpui vegetation ?

    Currently i have a fully lightmapped and lightprobed environment and disabling the lightprobes for the gpui renderers makes the vegetation too bright and not accurate to the scene lighting.
    Leaving the default setting seems ok at first but in some spots the trees would change ambient intensity like i recorded in the video.

    I think i'll have to ditch light probes for exterior scenes and only use ambient lighting from the hdri
     
    Last edited: Jul 13, 2021
  33. apprenticegc

    apprenticegc

    Joined:
    Apr 21, 2012
    Posts:
    25
    I just load the prefab mobile demo scene to android phone. The demo will stop at very beginning. Below is from Android Logcat

    2021/07/14 08:09:39.422 1719 1738 Error vulkan invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceVersion") call
    2021/07/14 08:09:39.422 1719 1738 Info vulkan no Vulkan HAL present, using stub HAL
    ...
    2021/07/13 18:03:13.658 9155 9170 Info Unity Instantiated 10000 objects.
    2021/07/13 18:03:13.658 9155 9170 Info Unity UnityEngine.Logger:Log(LogType, Object)
    2021/07/13 18:03:13.658 9155 9170 Info Unity GPUInstancer.AstroidGenerator:Awake()
    2021/07/13 18:03:13.658 9155 9170 Info Unity
    2021/07/13 18:03:17.505 9155 9213 Warn Adreno-GSL <gsl_ldd_control:467>: ioctl fd 52 code 0xc02c093d (IOCTL_KGSL_SUBMIT_COMMANDS) failed: errno 35 Resource deadlock would occur
    2021/07/13 18:03:17.505 9155 9213 Warn Adreno-GSL <log_gpu_snapshot:376>: panel.gpuSnapshotPath is not set.not generating user snapshot
    2021/07/13 18:03:17.505 9155 9213 Warn Adreno-GSL <gsl_ldd_control:467>: ioctl fd 52 code 0xc02c093d (IOCTL_KGSL_SUBMIT_COMMANDS) failed: errno 35 Resource deadlock would occur
    2021/07/13 18:03:17.505 9155 9213 Warn Adreno-GSL <log_gpu_snapshot:376>: panel.gpuSnapshotPath is not set.not generating user snapshot
    2021/07/13 18:03:17.508 9155 9213 Warn Adreno-GSL <gsl_ldd_control:467>: ioctl fd 52 code 0xc0140933 (IOCTL_KGSL_TIMESTAMP_EVENT) failed: errno 22 Invalid argument
    2021/07/13 18:03:17.508 9155 9213 Warn Adreno-GSL <ioctl_kgsl_syncobj_create:3358>: (35, 17, 1154) fail 22 Invalid argument
    2021/07/13 18:03:17.509 9155 9213 Warn Adreno-GSL <gsl_ldd_control:467>: ioctl fd 52 code 0xc0140933 (IOCTL_KGSL_TIMESTAMP_EVENT) failed: errno 22 Invalid argument
    2021/07/13 18:03:17.509 9155 9213 Warn Adreno-GSL <ioctl_kgsl_syncobj_create:3358>: (35, 17, 1153) fail 22 Invalid argument
    2021/07/13 18:04:42.585 9155 9155 Verbose BoostFramework mAcquireFunc method = public int com.qualcomm.qti.Performance.perfLockAcquire(int,int[])
    2021/07/13 18:04:42.586 9155 9155 Verbose BoostFramework mReleaseFunc method = public int com.qualcomm.qti.Performance.perfLockRelease()
    2021/07/13 18:04:42.586 9155 9155 Verbose BoostFramework mAcquireTouchFunc method = public int com.qualcomm.qti.Performance.perfLockAcquireTouch(android.view.MotionEvent,android.util.DisplayMetrics,int,int[])
    2021/07/13 18:04:42.589 9155 9155 Verbose BoostFramework BoostFramework() : mPerf = com.qualcomm.qti.Performance@d396eb0

    I am using old phone, Sony Z5P with Android OS 7.2. Is my phone too old to run GPU Instancer?
     
    Last edited: Jul 14, 2021
  34. aaronmichaelfrost

    aaronmichaelfrost

    Joined:
    Feb 4, 2021
    Posts:
    39
    When in my VIVE Pro in HDRP using GPUI Tree Manager, all of my trees will flicker on and off at random intervals. I am not using frustum culling or occlusion culling. In the scene view, the trees do not flicker. When I uncheck XR Rendering in the camera's Output settings, the trees do not flicker. Instances rendered with GPUI Prefab manager do not flicker. Sometimes when I am closer to some trees they will stop flickering, other times they will continue flickering.
     
  35. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    That sounds like a good solution. I can't really recommend a specific setup, it depends on the scene.

    Hi there,

    GPU Instancer relies heavily on the power of the GPUs and that is why we do not recommend to use it with old mobile devices. I am not entirely sure, but it also looks like your device does not have Vulkan support.

    Hi there,
    Looks like you are using Single Pass Instanced rendering mode. GPUI did not support this rendering mode previously, but we just released a new version that adds support for SPI with some other VR fixes/improvements. Please import the latest version of GPU Instancer (v1.5.3) from the Asset Store and see if it solves the issue.

    Note: There are some bugs on Unity HDRP with VR. Unity provides incorrect projection matrices, which causes Occlusion Culling to not work correctly. So you might need to disable OC until Unity fixes this issue.
     
  36. aaronmichaelfrost

    aaronmichaelfrost

    Joined:
    Feb 4, 2021
    Posts:
    39
    I am trying to update.

    I have deleted the old files and imported the latest version from package manager.

    My Unity Package Manager says that I am on Version 1.5.3. However, my GPUI readme and components all say that I am using version 1.4.6. This is odd.

    When I press import, it shows that all of the boxes in the "Import Unity Package' window are unchecked. I cannot check them.

    I need to update in order to use the latest versions features! Thanks.
     
  37. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Unity Package Manager has bugs on some versions. You can follow the instructions on this post to overcome this issue:
    https://forum.unity.com/threads/released-gpu-instancer.529746/page-48#post-6737122
     
  38. aaronmichaelfrost

    aaronmichaelfrost

    Joined:
    Feb 4, 2021
    Posts:
    39

    Do I also need to regenerate prototypes for my trees?
     
  39. ssg3d

    ssg3d

    Joined:
    Mar 8, 2021
    Posts:
    3
    I have the gameobjectless workflow up and running and I am trying to get it working for a multicam setup

    I have followed directions in the API docs by creating a separate Prefab manager per camera and registering my instances in each and setting the camera for that prefab manager using public SetCamera(GPUInstancerManager manager, Camera camera). I cannot however find a method to enable the Use Selected Camera Only toggle in the prefab manager

    I am generating all of the nodes at runtime based on a configuration that determines number of cameras so cannot set it in editor

    I am getting instances dropping out intermittently on one of the cameras when i switch between them

    any thoughts?
     
    Last edited: Jul 16, 2021
  40. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Regenerating prototypes would not be necessary.

    I would advise setting the toggle in the manager's inspector if you're not going to change it at runtime. If you want to do it from code, you could access the cameraData field of the manager where you would find renderOnlySelectedCamera. So:

    myManager.cameraData.renderOnlySelectedCamera = true

    please also make sure that the autoSelectCamera field of the manager (or the editor property Auto Select Camera) is set to false when doing this - as otherwise it would set the camera to Camera.main.

     
  41. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Hello,

    I have two questions about occlusion.

    - I don't remember having worked with the Occlusion Cull Accuracy value before. I do remember I need to change the Occlusion Cull Offset to 0.1 to make occlusion not flickering in our game, but I have never tried Occlusion Cull Accuracy. The default seems to be 1, but if I read the documentation about it, it seems that the minimum number of samplings should be 5? Can you shed some light on this, please?

    - Each prototype has an Is Occlusion Culling parameter, which I assume means that it will be culled by the occlusion system. Does it make sense and can we have an Is an Occluder boolean too? I have some prototypes that do not make any sense as occluders so I would like them to not be considered as occluders, of course only if it would speed up the compute shader process. If not, then ignore this (I don't know the algorithm, but I have the feeling that the concept of occluder doesn't even exist).
     
  42. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    I need to report also two bugs.

    First bug: It happens only if the occlusion is on. I am not sure if it's related to the previous problem that was fixed in the past using the cull offset to 0.1.
    Only when the camera jumps back, the blocks ficker, check the attached video.

    Second bug, HDRP (unity 2020.3) shadows are somehow broken when GPUI is on. Shadows without GPUI:

    upload_2021-7-21_11-56-44.png

    shadows with GPUI and of course use custom shadow distance off and is shadow casting on:

    upload_2021-7-21_11-58-35.png

    the shadows are actually there, but they appear only when the camera is very close to the shadow caster:

    upload_2021-7-21_11-59-27.png

    shadow settings:

    upload_2021-7-21_11-59-50.png
     

    Attached Files:

    Last edited: Jul 21, 2021
  43. TheGamery

    TheGamery

    Joined:
    Oct 14, 2013
    Posts:
    94
    I keep getting this error flooding my console during play mode, any idea how to fix it?

    Code (CSharp):
    1. Graphics.CopyTexture called for entire mipmaps with different memory size (source (Depth) is 1621632 bytes and destination (Depth) is 1529792 bytes)
    2. UnityEngine.Graphics:CopyTexture (UnityEngine.Texture,int,int,UnityEngine.Texture,int,int)
    3. GPUInstancer.GPUInstancerHiZOcclusionGenerator:UpdateTextureWithComputeShader (int) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:188)
    4. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRendering (UnityEngine.Camera) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:176)
    5. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRenderingSRP (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:126)
    6. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    7.  
    Using Unity 2021.1.9f1, Windows Standalone (DX11), HDRP 11 with latest GPUI + Crowd Animations installed.

    Edit: Seems to be related to Crowd addon, fixed by removing and re-adding characters to the GPUI Crowd Manager.

    Edit2: It came back, I noticed it only happens when Scene view and Game view are open at same time.
     
    Last edited: Jul 24, 2021
  44. customphase

    customphase

    Joined:
    Aug 19, 2012
    Posts:
    246
    Were having a couple of problems with this asset in our project:

    1) It doesnt have multiscene support. Its sort of does have it when youre in edit mode, but as soon as you enter play mode it only renders objects from the same scene the manager game object is in.

    2) It doesnt use instancing, but instead renders every mesh with just a regular DrawMesh call. Were using a custom shader for most of the objects, maybe thats related? If so, then how do we go about adding support for your asset in our custom shader? It does support instancing already, but its not enough from what i see.

    upload_2021-7-21_2-9-38.png
     
  45. customphase

    customphase

    Joined:
    Aug 19, 2012
    Posts:
    246
    Just noticed that it generates a GPUInstancer version of a shader for you, tried using that shader instead, but it still doesnt work, still just a bunch of DrawMesh calls.
     
  46. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Hello, i'm trying to implement a way to reduce terrain detail density at runtime by a setting variable.
    In my script i changed the detailGpuiManager.terrainSettings.detailDensity to the referenced gpui detail manager and called GPUInstancerAPI.InitializeGPUInstancer(detailGpuiManager) to trigger a refresh.

    However it does not work. The script changes the global detail density value in the manager as i can see in the inspector, but the change is not visible. Is there a special method i have to call to correctly reinitialize gpui detail manager?

    Also changing the global density in the editor with scene camera simulation also does not affect the actual density of the instanced details. I noticed that by changing the parameter on the actual terrain and then resimulating the detail manager does produce a change in density. So i updated my script to also change the density on the scene terrain before reinitializing the manager. It still did not work
     
  47. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    Are there any plans to add simple 3D billboards for fly simulators and similar games?
     
  48. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi Sebastiano,

    As the related wiki suggests, the number 1, 2, 3 are levels as such:

    Occlusion Cull Accuracy: Defines the accuracy of occlusion culling. Higher values will result in more accurate culling with higher number of texture samples:

    1 => 5 samples (middle point and corner points)
    2 => 9 samples (adds 1/4 points)
    3 => 17 samples (adds 1/8 and 3/8 points)

    As for how occlusion culling works, you can read up here. In short, GPUI does not use occluders but uses the depth texture.

    This is cause by a limitation of the occlusion cull technique GPUI adopts as the actual occlusion test results being tested in the previous frame than current. To solve this during fast camera movements - if it becomes an issue like this - you can increase the Bounds Size Offset option on the prototype.

    With the settings you are showing, this indeed sounds strange. If you can email us a sample package showing this we can investigate the issue in detail.

    You can use the ShaderGraph variation node which can be found in the

    GPUInstancer/Extras/GPUI_ShaderGraph_v5.x_or_Later_Node


    package. This should be auto extracted if you are using the latest version of GPUI in HDRP. In any case, this package also includes a demo scene (GPUInstancer/Demos/ShaderGraphVariations).

    As for the flickering you have mentioned, if you are sure your ASE setup is per this documentation, you can email us further details about it, we can investigate the issue.

    Any newly added objects to a manager (wherever they are - either same scene or additive scenes) must be registered to a manager when instantiated. This can be done via the auto add/remove instances feature or done manually through the API. Other than that, GPUI does not require anything specific when used with additive scene loading.

    As for the "Draw Mesh" items in the Frame Debugger, that is normal when using DrawMeshInstancedIndirect calls. If you want to verify the amount of instances being sent to the GPU, you can use the GPUInstancerGUIInfo component on a (single) game object in your scene.

    You can use the UpdateDetailInstances API method to apply changes on your prototypes at runtime. You can take a look at the TerrainGenerator script that uses this method as an example - using it for changing density would be done the same way.

    We don't plan to add any new types of billboard generators in addition to the existing ones. However, you can currently use custom mesh/material combination for this - which you can use for example to add Amplify Impostors.
     
  49. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Ok i got it to work by using UpdateDeailInstances followed by InitializeGPUInstancer.
    However the script generates two errors when called at scene start (propably due to gpuidetail manager not being fully initialized).
    These are the errors that pop up:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. GPUInstancer.GPUInstancerDetailManager+<FillCellsDetailData>d__36.MoveNext () (at Assets/GPUInstancer/Scripts/GPUInstancerDetailManager.cs:967)
    3. UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <cfc1ad890650411e946cff2e6f276711>:0)
    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <695d1cc93cca45069c528c15c9fdd749>:0)
    5. GPUInstancer.GPUInstancerDetailManager+<MergeVisibilityBufferFromActiveCellsCoroutine>d__27.MoveNext () (at Assets/GPUInstancer/Scripts/GPUInstancerDetailManager.cs:744)
    6. UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <cfc1ad890650411e946cff2e6f276711>:0)
    7. UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    8. GPUInstancer.GPUInstancerDetailManager:StartCoroutineAlt(IEnumerator) (at Assets/GPUInstancer/Scripts/GPUInstancerDetailManager.cs:586)
    9. GPUInstancer.GPUInstancerDetailManager:UpdateSpatialPartitioningCells(GPUInstancerCameraData) (at Assets/GPUInstancer/Scripts/GPUInstancerDetailManager.cs:177)
    10. GPUInstancer.GPUInstancerManager:UpdateBuffers(GPUInstancerCameraData) (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:554)
    11. GPUInstancer.GPUInstancerManager:LateUpdate() (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:265)
     
  50. perholmes

    perholmes

    Joined:
    Dec 29, 2017
    Posts:
    296
    I was wondering if you would consider stochastic culling to make culling prettier.

    I'm suggesting a fuzzy culling distance, so that all objects don't disappear into a wall at the same time. You could simply assign a random number to each object or some hash, generating stable, random values within a Fuzzy Culling range set by a slider in the UI.

    If the range is 10, each instance gets a random number from -5 to 5, and this is added when culling is evaluated.

    Incidentally, I tried to edit this in the compute shader, but I couldn't get the GPUi shaders to recompile. What is the trick to getting shaders to recompile?
     
    Last edited: Jul 26, 2021