Search Unity

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

[RELEASED] GPU Instancer

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

  1. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    Hi thanks for the response, but using Impostor only as a billboard doesnt work either. Its just not rendered at all.

    upload_2021-3-9_18-6-1.png

    upload_2021-3-9_18-6-6.png

    upload_2021-3-9_18-6-11.png
     
  2. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    Btw in editor in latest hdrp the grass....is not rendered in editor mode :p

    upload_2021-3-9_18-38-54.png

    Strange, ingame it looks ok

    upload_2021-3-9_18-40-33.png

    Btw to this and above issue, just want to reitrate i am on HDRP 10.3.2 and Unity 2020.2 so i am aware there may be bugs :)
     
    Last edited: Mar 9, 2021
  3. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    If you can email us a sample project showing this, we can investigate the issue.

    As for HDRP grass, Unity still doesn't have an HDRP grass shader, so it's normal and not GPUI related. You can, however, use GPUI to simulate your details in the editor by using "Simulate at Scene Camera" from the detail manager.
     
  4. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    Thanks for response.

    Will try to cook an example project later after work, sadly the test project is 25 gigs so... :).
     
  5. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    I give up with Unity xD

    I started to prepare the test scene for You and guess what. It works, both cases. LOD 1 impostor + Custom billboard and only as a custom billboard. This is magic.

    Update
    Turned out I was not supposed to install Shader option GPUI for The Vegetation Engine. So thats the tip for ppl using GPUI + TVE :).

    Install only HDRP package for GPUI, HDRP support for Amplify Impostors, HDRP support for TVE and HDRP support for TVE Amplify Impostors. Dont touch the SHader hub in TVE.

    DO NOT TOUCH THIS

    upload_2021-3-10_16-7-9.png
     
    Last edited: Mar 10, 2021
    LouskRad and ftejada like this.
  6. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @LouskRad I don't believe the 1.4.4 update fixed my Graphics Copy error mate.
    I just finally got around to actually trying it. Going to AppData and deleting the entire folder for GPUI.

    Delete GPUI from project as well as MM integrations.
    Go to package manager and press refresh, re-download GPUI, import said files.
    Then go to MM2 Integration and import that and Shadergraph package. (for HDRP).

    Click on Tools > GPU Instancer > Integration > Add MM2 integration.
    Import only trees, not grass as I'm handling that elsewhere.

    Pres play and get this.. (unless this is a new error).


    Code (CSharp):
    1. Graphics.CopyTexture called for entire mipmaps with different memory size (source (Depth) is 1060332 bytes and destination (R32 SFloat) is 2120664 bytes)
    2. 0x00007ff78cc644ec (Unity) StackWalker::GetCurrentCallstack
    3. 0x00007ff78cc6c8c9 (Unity) StackWalker::ShowCallstack
    4. 0x00007ff78e13c75c (Unity) GetStacktrace
    5. 0x00007ff78f2258b3 (Unity) DebugStringToFile
    6. 0x00007ff78bfd8bd1 (Unity) CheckCopyTextureMipMemorySize
    7. 0x00007ff78bfd9c34 (Unity) CopyTexture
    8. 0x00007ff78cdb5394 (Unity) Graphics_CUSTOM_CopyTexture_Slice
    9. 0x0000025b4540084e (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Graphics:CopyTexture_Slice (UnityEngine.Texture,int,int,UnityEngine.Texture,int,int)
    10. 0x0000025b4540078b (Mono JIT Code) UnityEngine.Graphics:CopyTexture (UnityEngine.Texture,int,int,UnityEngine.Texture,int,int)
    11. 0x0000025b4a32248b (Mono JIT Code) [GPUInstancerHiZOcclusionGenerator.cs:262] GPUInstancer.GPUInstancerHiZOcclusionGenerator:UpdateTextureWithComputeShader (int)
    12. 0x0000025b4a20796b (Mono JIT Code) [GPUInstancerHiZOcclusionGenerator.cs:252] GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRendering (UnityEngine.Camera)
    13. 0x0000025b4a2075f3 (Mono JIT Code) [GPUInstancerHiZOcclusionGenerator.cs:197] GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRenderingSRP (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera)
    14. 0x0000025b4a2075ad (Mono JIT Code) UnityEngine.Rendering.RenderPipelineManager:EndCameraRendering (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera)
    15. 0x0000025b4a207523 (Mono JIT Code) UnityEngine.Rendering.RenderPipeline:EndCameraRendering (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera)
    16. 0x0000025b454659cb (Mono JIT Code) [HDRenderPipeline.cs:2249] UnityEngine.Rendering.HighDefinition.HDRenderPipeline:Render (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])
    17. 0x0000025b45459af9 (Mono JIT Code) UnityEngine.Rendering.RenderPipeline:InternalRender (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])
    18. 0x0000025b453ec2cb (Mono JIT Code) UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,System.Collections.Generic.List`1<UnityEngine.Camera/RenderRequest>,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)
    19. 0x0000025b453ec490 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_intptr_object_AtomicSafetyHandle (object,intptr,intptr,intptr)
    20. 0x00007ffc7381e480 (mono-2.0-bdwgc) [mini-runtime.c:2812] mono_jit_runtime_invoke
    21. 0x00007ffc737a2902 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    22. 0x00007ffc737ab95f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    23. 0x00007ff78cae0d64 (Unity) scripting_method_invoke
    24. 0x00007ff78cad96e5 (Unity) ScriptingInvocation::Invoke
    25. 0x00007ff78c261759 (Unity) ScriptableRenderContext::ExtractAndExecuteRenderPipeline
    26. 0x00007ff78bd7901f (Unity) RenderManager::RenderCamerasWithScriptableRenderLoop
    27. 0x00007ff78bd787d6 (Unity) RenderManager::RenderCameras
    28. 0x00007ff78d5f9722 (Unity) RepaintController::RenderPlayModeViewCameras
    29. 0x00007ff78df89fce (Unity) EditorGUIUtility::RenderPlayModeViewCamerasInternal
    30. 0x00007ff78e84f9e9 (Unity) EditorGUIUtility_CUSTOM_RenderPlayModeViewCamerasInternal_Injected
    31. 0x0000025b453eacb7 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.EditorGUIUtility:RenderPlayModeViewCamerasInternal_Injected (UnityEngine.RenderTexture,int,UnityEngine.Vector2&,bool,bool)
    32. 0x0000025b453eabf3 (Mono JIT Code) UnityEditor.EditorGUIUtility:RenderPlayModeViewCamerasInternal (UnityEngine.RenderTexture,int,UnityEngine.Vector2,bool,bool)
    33. 0x0000025b453e9933 (Mono JIT Code) UnityEditor.PlayModeView:RenderView (UnityEngine.Vector2,bool)
    34. 0x0000025b4430190b (Mono JIT Code) UnityEditor.GameView:OnGUI ()
    35. 0x0000025b442ef523 (Mono JIT Code) UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect,UnityEngine.Rect)
    36. 0x0000025b442ef2f3 (Mono JIT Code) UnityEditor.DockArea:DrawView (UnityEngine.Rect,UnityEngine.Rect)
    37. 0x0000025b442f4633 (Mono JIT Code) UnityEditor.DockArea:OldOnGUI ()
    38. 0x0000025b442d8a20 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
    39. 0x0000025b442d7ceb (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
    40. 0x0000025b44439f73 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoIMGUIRepaint ()
    41. 0x0000025b4443753b (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChainCommand:ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams,single,System.Exception&)
    42. 0x0000025b44435a6b (Mono JIT Code) UnityEngine.UIElements.UIR.UIRenderDevice:EvaluateChain (UnityEngine.UIElements.UIR.RenderChainCommand,UnityEngine.Material,UnityEngine.Material,UnityEngine.Texture,UnityEngine.Texture,UnityEngine.Texture,single,Unity.Collections.NativeSlice`1<UnityEngine.UIElements.UIR.Transform3x4>,Unity.Collections.NativeSlice`1<UnityEngine.Vector4>,UnityEngine.MaterialPropertyBlock,bool,System.Exception&)
    43. 0x0000025b44432913 (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChain:Render ()
    44. 0x0000025b443e0de3 (Mono JIT Code) UnityEngine.UIElements.UIRRepaintUpdater:Update ()
    45. 0x0000025b442b8f7e (Mono JIT Code) UnityEngine.UIElements.VisualTreeUpdater:UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase)
    46. 0x0000025b443e05bb (Mono JIT Code) UnityEngine.UIElements.Panel:UpdateForRepaint ()
    47. 0x0000025b443e0223 (Mono JIT Code) UnityEngine.UIElements.Panel:Repaint (UnityEngine.Event)
    48. 0x0000025b442b8847 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
    49. 0x0000025b442b859b (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
    50. 0x0000025b442b839f (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration:processEvent (int,intptr)
    51. 0x0000025b442b82db (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
    52. 0x0000025b442b813d (Mono JIT Code) UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
    53. 0x0000025b442b81ee (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr)
    54. 0x00007ffc7381e480 (mono-2.0-bdwgc) [mini-runtime.c:2812] mono_jit_runtime_invoke
    55. 0x00007ffc737a2902 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    56. 0x00007ffc737ab95f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    57. 0x00007ff78cae0d64 (Unity) scripting_method_invoke
    58. 0x00007ff78cad96e5 (Unity) ScriptingInvocation::Invoke
    59. 0x00007ff78cad25e5 (Unity) ScriptingInvocation::Invoke<void>
    60. 0x00007ff78b1a1b0d (Unity) Scripting::UnityEngine::GUIUtilityProxy::processEvent
    61. 0x00007ff78d6faf46 (Unity) GUIView::processRetainedMode
    62. 0x00007ff78e17e4de (Unity) GUIView::OnInputEvent
    63. 0x00007ff78d6fae38 (Unity) GUIView::processInputEvent
    64. 0x00007ff78e1752c2 (Unity) GUIView::DoPaint
    65. 0x00007ff78e1814fd (Unity) GUIView::RepaintAll
    66. 0x00007ff78d7e1231 (Unity) PlayerLoopController::UpdateScene
    67. 0x00007ff78d7decd6 (Unity) Application::TickTimer
    68. 0x00007ff78e145f51 (Unity) MainMessageLoop
    69. 0x00007ff78e14a001 (Unity) WinMain
    70. 0x00007ff78ffb9576 (Unity) __scrt_common_main_seh
    71. 0x00007ffcf70f7034 (KERNEL32) BaseThreadInitThunk
    72. 0x00007ffcf7982651 (ntdll) RtlUserThreadStart
     
  7. Mojo-Game-Studio

    Mojo-Game-Studio

    Joined:
    Sep 18, 2015
    Posts:
    111
    Hiya,any idea why I get this error when playing the app in the editor, also no instanced prefabs display

    NullReferenceException: Object reference not set to an instance of an object
    GPUInstancer.GPUInstancerUtility.DispatchCSInstancedVisibilityCalculation[T] (UnityEngine.ComputeShader visibilityComputeShader, System.Int32 instanceVisibilityComputeKernelId, T runtimeData, System.Boolean isShadow, System.Int32 lodShift, System.Int32 lodAppendIndex) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:559)
    GPUInstancer.GPUInstancerUtility.UpdateGPUBuffer[T] (UnityEngine.ComputeShader cameraComputeShader, System.Int32[] cameraComputeKernelIDs, UnityEngine.ComputeShader visibilityComputeShader, System.Int32[] instanceVisibilityComputeKernelIDs, T runtimeData, GPUInstancer.GPUInstancerCameraData cameraData, System.Boolean isManagerFrustumCulling, System.Boolean isManagerOcclusionCulling, System.Boolean showRenderedAmount, System.Boolean isInitial) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:360)
    GPUInstancer.GPUInstancerUtility.UpdateGPUBuffers[T] (UnityEngine.ComputeShader cameraComputeShader, System.Int32[] cameraComputeKernelIDs, UnityEngine.ComputeShader visibilityComputeShader, System.Int32[] instanceVisibilityComputeKernelIDs, System.Collections.Generic.List`1[T] runtimeDataList, GPUInstancer.GPUInstancerCameraData cameraData, System.Boolean isManagerFrustumCulling, System.Boolean isManagerOcclusionCulling, System.Boolean showRenderedAmount, System.Boolean isInitial) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:319)
    GPUInstancer.GPUInstancerManager.UpdateBuffers (GPUInstancer.GPUInstancerCameraData renderingCameraData) (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:556)
    GPUInstancer.GPUInstancerManager.LateUpdate () (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:265)
     
  8. LouskRad

    LouskRad

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

    if you are sure that you could update to 1.4.4 (which you can verify by checking the version on the manager), than this indeed should not happen. If you can send us a sample project showing this, we can look into it and help further.

    Hi there,

    This error message does not tell a lot unfortunately. I would need more information on how you are using GPUI when you get this error. You can send us a sample project using this guide and we can look into it.
     
  9. nitoh

    nitoh

    Joined:
    Mar 20, 2014
    Posts:
    30
    Hi,

    Is there a chance to get a callback or get status from an Instancer Prefab (or instanced prefab) if it is culled or not?

    My goal is to implement an object pooling solution with the help of the GPUI occlusion culling solution. I instance high number of low detail prefabs with gui, and want to object pool high detailed models on top if the not culled gpui prefabs.

    Thank you very much.
     
    StellarVeil likes this.
  10. Streamfall

    Streamfall

    Joined:
    Aug 8, 2011
    Posts:
    43
    Hi! Great product. I made a change to the code in order to get GPUI working with MM2's Biomes.
    GPUInstancerMapMagic2Integration.cs has :
    Code (CSharp):
    1. if (generator is IBiome)
    2.                 {
    3.                     IBiome biome = (IBiome)generator;
    4.                     FillListsWithGeneratorsAsset(biome.SubGraph);
    5.                 }
    I have made the addition :
    Code (CSharp):
    1.   if (generator is BiomesSet200)
    2.                 {
    3.                     BiomesSet200 b = (BiomesSet200) generator;
    4.                     foreach (var biomeLayer in b.layers)
    5.                     {
    6.                         IBiome biome = (IBiome)biomeLayer;
    7.                         FillListsWithGeneratorsAsset(biome.SubGraph);
    8.                     }
    9.                 }
    10.                
    11.                 // biome
    12.                 else if (generator is IBiome)
    13.                 {
    14.                     IBiome biome = (IBiome)generator;
    15.                     FillListsWithGeneratorsAsset(biome.SubGraph);
    16.                 }
     
  11. ScorphiusMultiplayer

    ScorphiusMultiplayer

    Joined:
    Nov 10, 2018
    Posts:
    66
    Hi @LouskRad

    I have a Dungeon in the scene whose prefabs are registered in the GPUI Prefab Manager.
    At runtime I clone the dugeon, so that I can run multiple instance of the dungeon.
    But in the cloned Dungeon the prefabs are not rendered ( are invisble)

    I followed the wiki article.
    "Please keep in mind that the Add/Remove Instances At Runtime option should be enabled in the prototype definition for this API methods to work. Also, Extra Buffer Size should have a high enough number to add all the prefab instances generated at runtime."

    But the new instanced prefabs are not rendered.
    Could you help on that ?
     
    Last edited: Mar 20, 2021
  12. LouskRad

    LouskRad

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

    Since the culling operations are executed in the GPU, it would require a readback to determine if specific instances are culled. This would cause a major slowdown, so it is not provided as an API method.

    If all you need is to show close-by prefabs in high detail, I would suggest using an LOD Group for them.

    Hi,
    and thanks.

    However, we will fix an issue related to the MM2 in the next update - which is based on this forum post. In our tests, it has fixed all the issues related to the new biome changes in MM2. However, if the package in that post does not work for you, please send us the graph that you are using this with so we can identify the issue.

    Hi there, it is indeed the correct wiki article on this subject. The issue you are having might be related to the way that you are cloning this dungeon. If you send us a simple sample project showing this issue, we can help you identify the problem.
     
    StellarVeil likes this.
  13. CyberneticWalrus

    CyberneticWalrus

    Joined:
    Jun 19, 2019
    Posts:
    2
    Hi,

    When building for ps4 I get a number of shader errors, all in the same style:

    Shader error in 'CSRuntimeModification': Program 'CSRemoveInsideBounds', 'NUM_THREADS' attribute is expected for the entry point at kernel CSRemoveInsideBounds at CSRuntimeModification.compute(30) (on ps4)
    (same error happens for number of different shaders and programs)
    Is there any setting I forgot about? I am on Unity 2020.2.3, hdrp 10

    And a small secondary question, I just noticed the DeterminePlatform function and it does not contain a case for PS5. Will this cause an issue if I would try top build for PS5 later?

    Thanks
    Pieter
     
  14. wechat_os_Qy0989W4msb7Ot5jx6_iGbPvk

    wechat_os_Qy0989W4msb7Ot5jx6_iGbPvk

    Joined:
    Nov 3, 2020
    Posts:
    10
    I used GPUI and Gaia pro in my project.There is a big problem in my project.I add GPUI Tree Manager in every scene,but when loading the next scene,the trees float off the ground.If anyone could solve my problem,reply me please.Tanks!
     
  15. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    What scripts do you have added to the trees?
     
  16. LouskRad

    LouskRad

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

    This might be because of a change in Unity's PS4 build pipeline.
    If so, it is possible that the keyword "NUM_THREADS" is being internally used somewhere in the pipeline.

    We will investigate the issue. However, for now, you might try mass replacing all the "NUM_THREADS" keywords in all the files under /GPUInstancer to "GPUI_THREADS" and see if it helps the build issue.

    As for the PS5 case, GPUI will default to the general settings and it should build fine as PS5 does not need special treatment as far as we know now.

    It sounds like a floating origin issue. If you need to define a floating origin, you can enable the Use Floating Origin option in the manager.

    If that does not help, please send us a support request using the guidelines here.
     
  17. wechat_os_Qy0989W4msb7Ot5jx6_iGbPvk

    wechat_os_Qy0989W4msb7Ot5jx6_iGbPvk

    Joined:
    Nov 3, 2020
    Posts:
    10
    I did not add script to it.The prefab only has LOD, Capsule Collider and Transform.
     
    julianr likes this.
  18. CyberneticWalrus

    CyberneticWalrus

    Joined:
    Jun 19, 2019
    Posts:
    2
    Replacing the kewords seems to have done the trick!
    Thanks!
     
    LouskRad likes this.
  19. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    difficult to say what it could be, might be worth checking the positioning of your LODs, if it's nothing related to this asset. If you have rigid bodies on, or its a billboard issue. Worth following up with support as previously posted in the event you can't think of anything else that could cause it.
     
  20. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi, I started to get this error:

    CSTextureUtils.compute: Kernel at index (0) is invalid
    UnityEngine.ComputeShader:Dispatch(Int32, Int32, Int32, Int32)
    GPUInstancer.GPUInstancerUtility:CopyTextureWithComputeShader(Texture, Texture, Int32, Int32, Int32, Boolean) (at Catastrophe - Multiplayer - SgtSetup/Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:3398)

    index 0 and 1 alternatively gives this error. Then, I have some errors added to this:

    CSInstancedCameraCalculationKernel.compute: Kernel at index (0) is invalid
    UnityEngine.ComputeShader:Dispatch(Int32, Int32, Int32, Int32)
    GPUInstancer.GPUInstancerUtility:DispatchCSInstancedCameraCalculation(ComputeShader, Int32[], GPUInstancerRuntimeData, GPUInstancerCameraData, Boolean, Boolean, Boolean) (at Catastrophe - Multiplayer - SgtSetup/Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:526

    CSTextureUtils.compute: Kernel at index (1) is invalid
    UnityEngine.ComputeShader:Dispatch(Int32, Int32, Int32, Int32)
    GPUInstancer.GPUInstancerUtility:ReduceTextureWithComputeShader(Texture, Texture, Int32) (at Catastrophe - Multiplayer - SgtSetup/Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:3416)

    CSInstancedRenderingVisibilityKernel.compute: Kernel at index (0) is invalid
    UnityEngine.ComputeShader:Dispatch(Int32, Int32, Int32, Int32)
    GPUInstancer.GPUInstancerUtility:DispatchCSInstancedVisibilityCalculation(ComputeShader, Int32, GPUInstancerRuntimeData, Boolean, Int32, Int32) (at Catastrophe - Multiplayer - SgtSetup/Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:564

    All of these come in runtime and repeatedly.

    Unity 2020.1.4, HDRP 8.2.0

    EDIT: I am on windows... Sorry for smileys, forum page did it. Now, i see that 3 of the .compute files in GPUInstancer/Resources/ folder can't include Include/PlatformDefines.compute file. So, whatever the problem is related to PlatformDefines.compute file. Hope this helps in identifying the problem.

    EDIT2: I checked the compute folder on the second project I posted for down, it didn't have any issues. It is a unity 2020.2.2 HDPR 10 project. Thinking that this project's compute folder files are corrupted, I copied the entire Compute folder of that project to this project which is HDRP 8. Errors have gone. Performance seems to be good. That project (below) continues to generate that error, though. But, this project is clean now. However, I am not sure I have done the right thing or the safe thing.
     
    Last edited: Apr 8, 2021
  21. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Also in another project I started to get

    Graphics.CopyTexture called for entire mipmaps with different memory size (source (R32 SFloat) is 5977272 bytes and destination (Depth) is 2988636 bytes)
    UnityEngine.Graphics:CopyTexture (UnityEngine.Texture,int,int,UnityEngine.Texture,int,int)
    GPUInstancer.GPUInstancerHiZOcclusionGenerator:UpdateTextureWithComputeShader (int) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:273)

    on windows. On mac it seems fine. This project is on Unity 2020.2.2, HPRP 10.2.2. Also, this is reducing editor performance.
     
  22. craigbriggs

    craigbriggs

    Joined:
    Nov 21, 2019
    Posts:
    1
    Hi,

    I accidentally clicked on "Generate Prototypes" in the Tree Manager and now only about half the trees in the current scene are listed. I am using version 1.4.4.

    I am also getting the following error message (not sure if it is related)

    NullReferenceException: Object reference not set to an instance of an object
    GPUInstancer.GPUInstancerUtility.DetermineTreePrototypeType (GPUInstancer.GPUInstancerPrototype prototype) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:1516)
    GPUInstancer.GPUInstancerUtility.AddTreeInstancePrototypeFromTerrainPrototype (UnityEngine.GameObject gameObject, System.Collections.Generic.List`1[T] treeInstancePrototypes, UnityEngine.TreePrototype terrainTreePrototype, System.Int32 treeIndex, GPUInstancer.GPUInstancerTerrainSettings terrainSettings) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:1426)
    GPUInstancer.GPUInstancerUtility.SetTreeInstancePrototypes (UnityEngine.GameObject gameObject, System.Collections.Generic.List`1[T] treeIntancePrototypes, UnityEngine.TreePrototype[] treePrototypes, GPUInstancer.GPUInstancerTerrainSettings terrainSettings, System.Boolean forceNew) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:1403)
    GPUInstancer.GPUInstancerTreeManager.GeneratePrototypes (System.Boolean forceNew) (at Assets/GPUInstancer/Scripts/GPUInstancerTreeManager.cs:64)
    GPUInstancer.GPUInstancerTreeManagerEditor.<DrawPrototypeBoxButtons>b__15_0 () (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerTreeManagerEditor.cs:351)
    GPUInstancer.GPUInstancerEditorConstants.DrawColoredButton (UnityEngine.GUIContent guiContent, UnityEngine.Color backgroundColor, UnityEngine.Color textColor, UnityEngine.FontStyle fontStyle, UnityEngine.Rect buttonRect, UnityEngine.Events.UnityAction clickAction, System.Boolean isRichText, System.Boolean dragDropEnabled, UnityEngine.Events.UnityAction`1[T0] dropAction, UnityEngine.GUIStyle style) (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerEditorConstants.cs:530)
    GPUInstancer.GPUInstancerTreeManagerEditor.DrawPrototypeBoxButtons () (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerTreeManagerEditor.cs:346)
    GPUInstancer.GPUInstancerManagerEditor.DrawGPUInstancerPrototypesBox () (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerManagerEditor.cs:358)
    GPUInstancer.GPUInstancerTreeManagerEditor.OnInspectorGUI () (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerTreeManagerEditor.cs:66)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <2f1c602eae0d45c293fff3e3aef759fa>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Cheers,

    Craig
     
  23. eggsamurai

    eggsamurai

    Joined:
    Oct 10, 2015
    Posts:
    110
    Any plans for motion vector support on crowd animation?
     
  24. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    119
    Hi there,

    I'm having an issue after upgrading from 2019.3 to 2020.3.3 All looks fine but there is an issue with the Graphics.CopyTexture API used for the culling.

    Stacktrace:
    Code (CSharp):
    1. Graphics.CopyTexture called for entire mipmaps with different memory size (source (Depth) is 4147200 bytes and destination (R32 SFloat) is 8294400 bytes)
    2. UnityEngine.Graphics:CopyTexture (UnityEngine.Texture,int,int,UnityEngine.Texture,int,int)
    3. GPUInstancer.GPUInstancerHiZOcclusionGenerator:UpdateTextureWithComputeShader (int) (at Assets/Third Party Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:261)
    4. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRendering (UnityEngine.Camera) (at Assets/Third Party Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:248)
    5. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRenderingSRP (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at Assets/Third Party Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:196)
    6. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    Version:
    upload_2021-4-9_17-55-15.png

    Unfortunately the project is too large to share. Any idea where to look?
     
  25. LouskRad

    LouskRad

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

    the compute shader folder would not change based on the HDRP version, so it should be safe. However, simply re-importing this folder would probably solve the issue if copying it worked.



    This is solved in a recent version of GPUI. Updating GPUI from the Asset Store to the latest version should fix the issue.

    We haven't yet tested CA with motion vectors, and this currently is not in our roadmap.

    Hi there,

    this seems to be because you have updated your Unity version, but not your HDRP version. Switching to the latest supported HDRP version should fix the issue.
     
  26. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    119
    Hi,

    Is that even possible? I believe Unity updates it automatically in any case.

    Anyhow, i double checked and we are on the latest version.

    upload_2021-4-11_18-32-38.png

    Regards,

    Lenne
     
  27. Skaltum

    Skaltum

    Joined:
    Nov 1, 2013
    Posts:
    28
    Hello,

    First of all, great product! I've made massive performance improvements using it to render large fields of solar panels.

    I'm trying to take screenshots of the game using
    Code (CSharp):
    1. ScreenCapture.CaptureScreenshotAsTexture
    .
    When I set the supersize parameter to higher than 1, the instanced objects are not rendered in the screenshot.

    Here is some reproduction code:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class TestScreenshot : MonoBehaviour
    4. {
    5.     [SerializeField]
    6.     private Texture2D _screenshotWithoutSuperSize;
    7.     [SerializeField]
    8.     private Texture2D _screenshotWithSuperSize;
    9.    
    10.     void Update()
    11.     {
    12.        
    13.         if (Input.GetKeyDown(KeyCode.Space))
    14.         {
    15.             //works
    16.             _screenshotWithoutSuperSize = ScreenCapture.CaptureScreenshotAsTexture(1);
    17.             //missing rendered instances
    18.             _screenshotWithSuperSize = ScreenCapture.CaptureScreenshotAsTexture(2);
    19.         }
    20.            
    21.     }
    22. }
    You can put it on a gameobject in an example scene, play, press space. In the inspector, the screenshot without supersize will be accurate. The screenshot with supersize will be missing the instanced objects.

    Is there a workaround / fix for this?

    Thanks in advance.
     
  28. GurhanH

    GurhanH

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

    The documentation of CaptureScreenshotAsTexture recommends to use this method after frame rendering has ended:
    To get a reliable output from this method you must make sure it is called once the frame rendering has ended, and not during the rendering process. A simple way of ensuring this is to call it from a coroutine that yields on WaitForEndOfFrame. If you call this method during the rendering process you will get unpredictable and undefined results.

    When I tried this way it worked fine. Here is the example:

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3.  
    4. public class TestScreenshot : MonoBehaviour
    5. {
    6.     [SerializeField]
    7.     private Texture2D _screenshotWithoutSuperSize;
    8.     [SerializeField]
    9.     private Texture2D _screenshotWithSuperSize;
    10.  
    11.     void Update()
    12.     {
    13.         if (Input.GetKeyDown(KeyCode.Space))
    14.         {
    15.             StartCoroutine(RecordFrame());
    16.         }
    17.     }
    18.  
    19.     IEnumerator RecordFrame()
    20.     {
    21.         yield return new WaitForEndOfFrame();
    22.  
    23.         //works
    24.         _screenshotWithoutSuperSize = ScreenCapture.CaptureScreenshotAsTexture(1);
    25.         //missing rendered instances
    26.         _screenshotWithSuperSize = ScreenCapture.CaptureScreenshotAsTexture(2);
    27.     }
    28. }
     
    Skaltum likes this.
  29. eggsamurai

    eggsamurai

    Joined:
    Oct 10, 2015
    Posts:
    110
    Motion vector is very very very import for taa and postprocess effects... i have to diy
     
  30. d11javierv

    d11javierv

    Joined:
    Nov 17, 2020
    Posts:
    1
    Hello!
    First off, thank you for supplying this product. It has been very useful.

    I have been reading this thread looking for information about changing instances' layer, and I didn't find anything but a post from 31th August 2019.

    I need to apply different screen space effects to different instances, such as highlights, outlines and so on. I was thinking of using different URP render features in order to achieve this, depending on the layers. It works well but my main problem now is to be able to change the instances' layer at run time.

    Do you have any advice or any feature to achieve this?
     
  31. athert

    athert

    Joined:
    Dec 31, 2012
    Posts:
    36
    Helloo.
    Im not sure if this question was asked before but i have bad experience with frustum culling. Everytime i move with camera a little more faster, it just didnt catch and you can see that objects are "behind" with render. I tried to change "Frustum Offset" but it didnt help at all at any value. Is there any other option how to fix this issue?
    Another question is if all changes in runtime are instant or you need to restart game mode.
     
  32. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hey there, and thanks.

    Since GPUI uses the DrawMeshInstancedIndirect API under the hood, the drawcall that is made for all the instances uses the same layer - so it is inherently not supported to have different layers on different instances of the same prototype.

    If the instances you want to use in a different layer are not many in numbers, one way to go about this would be to turn off instancing for the select instances from the GPUInstacer API and set their layers after. You can turn instancing back on after you set them to the original layer.

    Can you please try increasing the Occlusion Cull Offset value of the prototype settings on the manager to a very small number (such as 0.001 - 0.01) and see if this fixes the issue?
     
  33. Alex1337rus

    Alex1337rus

    Joined:
    Mar 30, 2016
    Posts:
    37
    Hello! I really like your asset, but i have probably stupid question.
    As I understand, you use frustum culling for absolutely all objects on the scene. Wouldn't that be a problem for the big scene? Is it possible to divide the scene into sectors and first cull the sectors and then cull objects inside these sectors? It seems like how vegetation studio works.
     
  34. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi,

    I have the errors seen in the screenshots in the attachments in the compute folder. This prevents me to instance The Vegetation Engine tree prefabs. I tried a re-import of GPUInstancer from asset store but the errors do not go away. Instancing works well in other assets. Unity 2020.2.2, HDPR 10.2.2, GPUInstancer 1.4.5.
     

    Attached Files:

    Ne0mega likes this.
  35. LouskRad

    LouskRad

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

    This is related to the difference between doing culling on the CPU and GPU. It is a rather long and complicated topic, but you can find detailed information on how GPUI works and why it does this on compute shaders in this wiki article.

    Hi there,

    Can you please right click on the /GPUInstancer folder and choose Reimport from the context menu and see if this helps?
     
    Ne0mega likes this.
  36. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi... Just saw your reply now. I was about to report that I solved the problem by replacing the compute file by another one in another project without any problems. If it occurs again, I will do what you have suggested and report back.
     
  37. appleid

    appleid

    Joined:
    Apr 30, 2015
    Posts:
    2
    Hello,
    I got this error after pressing the play button.

    I use Unity 2020.3.2f1, HDRP 10.4.0, GPUI v1.4.5

    Would you have any suggestions to solve this problem?

    Thank you.
     
  38. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    668
    @LouskRad

    Hello,

    The asset store says VR "single pass instanced not supported." Will this ever be supported? Thanks!
     
  39. ZerglebReal

    ZerglebReal

    Joined:
    Apr 27, 2021
    Posts:
    7
    Hi, I just downloaded this asset today and when I open the PrefabInstancingDemo scene and click play a few prefabs pop up but then the console gets flooded with this error. This is in an empty project 2019.4.20f

    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. GPUInstancer.GPUInstancerRuntimeData.IsLODShadowCasting (System.Int32 lodLevel) (at Assets/GPUInstancer/Scripts/Core/DataModel/GPUInstancerRuntimeData.cs:417)
    3. GPUInstancer.GPUInstancerUtility.GPUIDrawMeshInstancedIndirect[T] (System.Collections.Generic.List`1[T] runtimeDataList, UnityEngine.Bounds instancingBounds, GPUInstancer.GPUInstancerCameraData cameraData, System.Int32 layerMask, System.Boolean lightProbeDisabled) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:596)
    4. GPUInstancer.GPUInstancerManager.UpdateBuffers (GPUInstancer.GPUInstancerCameraData renderingCameraData) (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:563)
    5. GPUInstancer.GPUInstancerManager.LateUpdate () (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:265)
    Edit: I should mention the other demos seem to work for me (I didn't try ALL of them). The mobile version has the same error except it shows 0 prefabs instead of just a few. Instancing without a game object does work though.
     
  40. GurhanH

    GurhanH

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

    Can you make the following change and see if it solves the issue:
    GPUInstancerHiZOcclusionGenerator.cs file line 229

    from this:

    _tempDepthTextureForTex2DArray = new RenderTexture(unityDepthTexture.width, unityDepthTexture.height, 24, RenderTextureFormat.RFloat);

    to this:

    _tempDepthTextureForTex2DArray = new RenderTexture(unityDepthTexture.width, unityDepthTexture.height, 24, unityDepthTexture.graphicsFormat);

    Hi there,

    Single Pass Instanced does not work with DrawMeshInstancedIndirect API. So it is currently not possible for GPUI to support this rendering method.

    Hi there,

    Looks like we missed this on the latest update, we will fix the issue with the next update. For now, if you make the following change it should run without issues:
    GPUInstancerRuntimeData.cs file line 417

    from this:

    return prototype.shadowLODMap[lodIndex] < 8;

    to this:

    return prototype.isShadowCasting && prototype.shadowLODMap[lodIndex] < 8;
     
  41. appleid

    appleid

    Joined:
    Apr 30, 2015
    Posts:
    2

    It works!

    Thank you so much.
     
  42. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    really appreciate what is possible by GPUInstancer... and The Vegetation Engine... And, ofcourse, Space Graphics Toolkit... This is even a fraction of it...

     
    LouskRad likes this.
  43. pratt_timmy

    pratt_timmy

    Joined:
    Jun 30, 2019
    Posts:
    32
    Hey there.
    Recently picked up this asset and its' fantastic!

    Edit: Everything works excellent so far! I had a question but I deleted it...Turns out that I overlooked something pretty simple in my own methods. And the problem was completely unrelated to this awesome asset. A rogue script was causing the problem and was an easy fix.

    Thanks very much for providing this excellent product!
    Keep up the great work !!!
     
    Last edited: May 2, 2021
    LouskRad likes this.
  44. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Hi there, I'm considering GPUI, so please pardon my basic question.

    I currently have gameobjects in the scene and want to switch to GPUI for its benefits. Will I have to re-place my gameobjects using GPUI, or can GPUI convert my existing gameobjects in the scene?

    Also, do you have any tools or recommendations for spawning dense grass on terrain?
     
    Last edited: May 2, 2021
  45. oceandrivestudio

    oceandrivestudio

    Joined:
    Jan 11, 2021
    Posts:
    1
    Hello @LouskRad
    We use gpuinstance and gpuinstance for crowd well but we suffer from always changing of shader variant collection file. As far I researched, SetDefaultShaderVariants() in SetDefaultShaderVariantCollection() is always executed every reimport assets. Normally, It reorder shader variants in collection.

    (SetDefaultShaderVariants is called from GPUICrowdSettingsEditor.OnEnable)

    May I move "SetDefaultShaderVariants" into a brace so that it is only called when shaderVariantCollection is null?
     
  46. sepnax

    sepnax

    Joined:
    Jun 24, 2014
    Posts:
    6
    Is it good idea to try to use this for bullet holes, that are basically quads with transparent texture?
    Project is using HDRP and 2019.4.
     
  47. LouskRad

    LouskRad

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

    In most cases, you do not need to do anything other than adding the prefab to the manager as a prototype. GPUI turns off the mesh renderer at runtime and renders the instances of this prefab in your scene.

    You would need to take additional steps if you are overriding instances of your prefabs in the scene with materials changes, or renderers.

    You can take a look at this wiki page for information on best practices when using GPUI.

    You can turn of this behavior from the GPU Instancer Preferences if you wish.

    It is a good idea if you have a lot of bullet holes with the same mesh and material combination at a given time. That is, the criteria to consider is instance counts, whether you're rendering bullet hole quads or trees.
     
  48. Spudly1701

    Spudly1701

    Joined:
    Aug 25, 2013
    Posts:
    36
    Hi all,

    So, I'm trying to integrate GPUI into my multiplayer game, the problem I'm having is assigning the camera dynamically to each players prefab camera as they get instantiated.

    Has anyone else come across this and found a solution at all? Been driving me nuts for a couple of days. lol.

    Thanks
    Spud
     
  49. LouskRad

    LouskRad

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

    If you wish to switch cameras at runtime, you can call the SetCamera API method from your script right after you enable/instantiate your new camera.

    Alternatively, you can add the included GPUInstancerCameraHandler Component on your cameras to have GPUI automatically handle this for you.
     
  50. Spudly1701

    Spudly1701

    Joined:
    Aug 25, 2013
    Posts:
    36
    Interesting. I did actually try the Camerahandler script, but it didn't seem to do anything unfortunately. I shall try the SetCamera route though :)

    Thanks for the reply.
    Spud