Search Unity

[RELEASED] GPU Instancer

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

  1. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    412
    It seems like GPUI does not work with Microsplats Terrain Blending but I see that this was a topic once with a possible fix:
    https://forum.unity.com/threads/released-gpu-instancer.529746/page-13#post-3975319

    Am I doing something wrong or does it need a special setup?

    It all seems to work fine with instancing, but just the blending is not present. I can see that GPUI did create a version of the blending shader.

    Many thanks
     
    Last edited: Dec 9, 2019
  2. LouskRad

    LouskRad

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

    Thank you for sending us the sample. The problem in your scene is that your camera is not tagged "MainCamera" but the manager is set to find the camera automatically. GPUI can't find the camera like this. You can either set your camera manually by unchecking the "Auto Select Camera" option or tag your camera as "MainCamera" to solve this issue.
     
    protopop likes this.
  3. LouskRad

    LouskRad

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

    You can use the Prefab Manager for this, and either enable the "Auto. Add/Remove Instances" option on the manager to let GPUI do this for you, or use the API to handle this.

    Please take a look at the wiki article in the F.A.Q for this.
     
  4. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    666
    GPUI disables all MeshRenderers on its instances and use its own rendering system to render them with the Indirect Instancing API. If you want enable a MeshRenderer, you need to use the API to disable instancing for that instance.
     
    UnityRocksAlt likes this.
  5. LouskRad

    LouskRad

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

    the multiple materials bug mentioned in that forum post has been fixed in a previous update. However, terrain blending probably would require instance based variations on the material's shader and would not work out of the box.
     
    iddqd likes this.
  6. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    412
    So this would need a change on your side or only on the Microsplat side? Thanks
     
  7. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,210
    Wow thank you.

    Reading this thread I’ve rarely seen a dev be so responsive and helpful. I really appreciate it and hope I can make the most of GPUI:)
     
    LouskRad likes this.
  8. Spiral-Organ

    Spiral-Organ

    Joined:
    Aug 20, 2015
    Posts:
    26
    It seems like NatureManufacturer's HDRP tree shaders are somehow not supported even though it converted properly? The trees and leaves all disappear on any shader except for ANGRYMESH winter pack shaders. Even Lit shaders have trees disappearing completely.

    Edit: Nvm it seems to just be LOD Crossfade that's making them invisible. I wonder how important that is...
     
    Last edited: Dec 10, 2019
  9. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    666
    I am not familiar with the details of Microsplat, but since the required changes are shader related, it most likely should be done on the shader asset's side. GPUI already has the required API to implement instance based material variations, which you can see an example usage of in this wiki page.
     
    iddqd likes this.
  10. LouskRad

    LouskRad

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

    GPUI's cross-fade support is designed to work with the cross fading solution that Unity offers. The cross fading feature of some shaders that use a custom implementation for this might therefore not work out of the box with GPUI; even though the shader itself would work without this feature.
     
  11. Jeryl

    Jeryl

    Joined:
    Sep 18, 2015
    Posts:
    13
    Hi,
    I am working on a city builder that will have a lot of buildings and NPCs on screen at all times.
    Your asset seem it will be really helpful! But I have a question before I purchase it.

    -In this kind of games, building have tiers that change their appearances (Shack, Small House, House, Big House, Mansion, etc.) but each tier also have variations on details (windows, doors, walls, etc). With such a variety of models, can I expect the asset to improve the performances (some details are baked into the material, but some are geometry related)?

    -
     
  12. LouskRad

    LouskRad

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

    in general, what matters for GPUI is mainly instance counts. There are various ways you can arrange your instances when their numbers are high to make the most out of GPUI. You can take a look at the best practices and terminology wiki pages for more information.
     
  13. combatsheep

    combatsheep

    Joined:
    Jan 30, 2015
    Posts:
    90
    Thanks, LouskRad.

    Finally, I purchased GPUI.;)
    I'll try it.
     
    LouskRad likes this.
  14. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91
    hi there,
    I hope someone can help me a bit..I am using Unity 2019.3.0f3 with the GPU Prefab Manager as well as the Tree manager and I unchecked Auto Select Camera and added my Camera to "use camera" at the prefab Manager, but I still get this error in the console:
    Main Camera cannot be found. GPU Instancer needs either an existing camera with the "Main Camera" tag on the scene to autoselect it, or a manually specified camera. If you add your camera at runtime, please use the "GPUInstancerAPI.SetCamera" API function.
    UnityEngine.Debug:LogWarning(Object)
    GPUInstancer.GPUInstancerManager:OnEnable() (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:193)

    My Trees are not visible when I hit Play and my Prefabs are not visible when I build the game and load the corresponding Level, but when I runtime switch the Level and go back to the Level with the GPU Instance, than my Prefabs are visible (trees are still not visible, though)

    I guess I need to instantiate the Camera at runtime somehow...
    It would be great if anyone know how to fix this

    EDIT:
    I also recieve this error:

    IndexOutOfRangeException: Index was outside the bounds of the array.
    GPUInstancer.GPUInstancerTreeManager+<ReplaceUnityTrees>d__8.MoveNext () (at Assets/GPUInstancer/Scripts/GPUInstancerTreeManager.cs:196)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <7d22f8e71133418c87c7b26ea181f3e3>:0)


    any idea?
     
    Last edited: Dec 15, 2019
  15. iMancha

    iMancha

    Joined:
    Sep 22, 2014
    Posts:
    12
    Hi @LouskRad

    Thanks for your hard work with adding URP support, I am experiencing an issue where all the models are invisible and only shadows are showing - do you perhaps know what could be causing this?

    EDIT: Most of the GPUI shaders are showing pink when they do load, especially terrain.
     
    Last edited: Dec 15, 2019
  16. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91
    Hi @LouskRad
    could you please take a look at the above mentioned errors?

    Fyi: I have also tried to add the GpuInstanceCameraHandler script to all of my cameras, but it's still not able to find the specified camera

    This issue is pretty much slowing down the project..I hope you have an advice how to solve that..
     
  17. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91
    one more info..

    there are some warings ...
    GarbageCollector disposing of ComputeBuffer allocated in...Assets\GPUInstancer\Scripts\GPUInstancerTreeManager.cs at line 185. Please use ComputeBuffer.Release() or .Dispose() to manually release the buffer.
    UnityEngine.ComputeBuffer:Finalize()
     
  18. TheFoundation

    TheFoundation

    Joined:
    Jan 29, 2014
    Posts:
    16
    I just purchased your asset. Simply amazing. Thank you very mutch @LouskRad.

    If anyone runs into a NullException while baking animations like me, then this might help:

    I purchased a popular model asset on the asset store, added it to the "GPUI Crowd Manager" and hit "Bake Animations". "GPU Instancer - Crowd Animations v 0.9.3" in Unity 2019.3.0f3 throws a NullException in GPUICrowdAnimationBaker line 178 and 195 if skinnedMeshRenderer.sharedMesh is null.
    This can happen if the mesh of the "Skinned Mesh Renderer" is not assigned or missing.
    Even if you modify the source and skip this renderer during baking then the baking will succeed but you will run into consequential errors later when running this setup.
    To fix this you have to go through the renderers in your prefab and either assign a mesh or delete it if the mesh reference is not set.
    Hope it helps someone.
     
    Last edited: Dec 18, 2019
    LouskRad likes this.
  19. LouskRad

    LouskRad

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

    If you have more than one GPUI manager (of any kind), you would need to set the camera as you did in the Prefab Manager for all your managers. That is, you need to do this in the Tree Manager as well.

    As for loading levels, you need to make sure the loaded level has the desired managers as well, either by serializing them in both scenes, or using a DontDestroyOnLoad script keeping the manager GameObject.

    If this does not help you, please email us a sample project showing the error so we can investigate it.
     
    combatsheep likes this.
  20. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    666
    Thank you for your feedback. We will look into providing a error message to help identify this in such cases.
     
  21. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91

    Hi,
    thanks a lot for your help.
    Meanwhile I figured out that I had to setup the camera for the tree manager as well, so gpu instancer works fine currently. I only get the following warnings in the console:

    GarbageCollector disposing of ComputeBuffer allocated in ..\Assets\GPUInstancer\Scripts\GPUInstancerTreeManager.cs at line 183. Please use ComputeBuffer.Release() or .Dispose() to manually release the buffer.
    UnityEngine.ComputeBuffer:Finalize()

    GarbageCollector disposing of ComputeBuffer allocated in ..\Assets\GPUInstancer\Scripts\GPUInstancerTreeManager.cs at line 185. Please use ComputeBuffer.Release() or .Dispose() to manually release the buffer.
    UnityEngine.ComputeBuffer:Finalize()

    GarbageCollector disposing of ComputeBuffer allocated in ..\Assets\GPUInstancer\Scripts\GPUInstancerTreeManager.cs at line 185. Please use ComputeBuffer.Release() or .Dispose() to manually release the buffer.
    UnityEngine.ComputeBuffer:Finalize()


    Could you please give me a hint, how to solve this?

    Many thanks
     
  22. Black_Raptor

    Black_Raptor

    Joined:
    Nov 3, 2014
    Posts:
    108
    Hi !

    I got a wierd visual glitch with GPU instancer & Tree manager :



    On my scene the red circle is the glitch and as you can see in my player game window it's visible in game ... I dont know what it is ... And how to fix that's
     
  23. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,340
    Hello, I just purchased the GPU Instancer today, and I've read some sections in the documents to try to get started, but I keep coming across the same problem.

    Whenever I add a "Prefab" to the Prefab Manager it seems to instance the Prefabs correctly -- the ones already in my scene. But when I hit Play (during runtime) all of the mesh renderers on my Prefabs remain disabled. In other words, the GPU Instancer doesn't seems to be turning them on during playtime.

    I noticed that once I set a Prefab in the Prefab Manager the mesh renderers will not be turned on during playtime unless I manually set the newly added prefab in the scene manually.

    Which means I'd have to go through hundreds of my gameobjects and reinsert them from the Prefab manually, and re-position all of them in my game again. I want to avoid this if possible.

    Is there a reason why the GPU Instancer system would not be turning on the renderers during playtime?

    Thanks for any help. :)



    **Edit for solution: Nevermind I think I figured it out, so I'll say it's solved. I had some child gameobjects (that were disabled) in my prefab with Legacy/Diffuse shaders on them. I deleted these child gameobjects since I didn't need them. And I got rid of the LOD component on the parent gameobject. This allowed the system to properly render my prefab again (at least it works now). I'm still not sure if it was the Legacy shaders not working with the system properly, or if it was because of the LOD component somehow.
     
    Last edited: Dec 23, 2019
  24. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,340
    I have another question though. Should I enable the "Static" flag/option on my prefabs/gameobjects?

    Is it better that I mark everything that can be static, as static? Or do prefabs get more performance without being static in the GPUI system? Does it break static batching if I use the static option along with your system?

    Thanks again for any info.
     
  25. marcell123455

    marcell123455

    Joined:
    Jun 18, 2014
    Posts:
    48
    @LouskRad
    Hi,

    Is there any option to use/run it on Android with only open GL 3.0 support? Maybe with some compromises?
    Thanks ;)
     
  26. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    71
    I have 256 terrains in my scene with a grass prefab painted on them. I add the GPUI Detail Manager (256 of them) and the editor then becomes unusable (1 FPS). This was tested on a HDRP scene, please help.
     
  27. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    391
    Hello, I have bought GPU Instancer for other things, and I think is really great and well done, but now I wonder if it could be used also for instancing mesh particles instead of prefab objects?.

    If you need I can send you the Invoice number

    I mean if there is any way either through the prefab manager or through scripting or API to be able to use the GPU Instancer asset for instancing a particle mesh?

    I want to use the https://assetstore.unity.com/packages/vfx/particles/spells/living-particles-105817

    It uses the Unity Particle system and in the Renderer part, it loads the cube Mesh that is going to be used for the instancing of that mesh, but is not an object in itself as in a prefab. So I wonder if GPU instancer can also be used to instance also a particle mesh.

    This living particles asset includes a Particle Grid Generator script that makes a grid with the mesh that is configured in the Particle system. I have configured to make a 40 x 500 grid, so it creates a 20.000 grid of cubes, where all are the same cube, so this is why I thought that maybe it could be used some kind of GPU instancing

    I have seen this https://docs.unity3d.com/Manual/Par...56.1986981277.1577613097-757559976.1524128558

    And also have enabled the enabled the GPU instancing in the custom shader that it has, but it seems that there is no gain in the performance, so this is why I am asking here to use GPU Instancer asset for this.

    I am using Unity 2019.2 and the target is for iOS using Metal and Android using Vulkan or OpenGL3.1

    Please, if you need any additional information, just tell me.

    Thanks very much for any help and congratulations for an awesome asset

    Wish you a happy new year and all the best for you and also that GPU Instancer gets even more popular and you sell a lot more.
     
    Last edited: Dec 29, 2019
  28. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    940
    Is there a way to make shader properties support variances when the shaders are made in Amplify, without having to manually edit the shaders?

    I did this, but naturally it doesn't add support to variance properties out of the box:
    https://wiki.gurbu.com/index.php?title=GPU_Instancer:FAQ#Amplify_Shader_Editor_directives

    Also, looks like there's a bug with converting shaders with amplify and instanced properties, here's what it converted into:

    Code (CSharp):
    1.  
    2.             UNITY_INSTANCING_BUFFER_START(GPUInstancer/shader_env_impostor_foliage_render)
    3.                 UNITY_DEFINE_INSTANCED_PROP(float4, _LeafColor)
    4. #define _LeafColor_arr GPUInstancer/shader_env_impostor_foliage_render
    5.             UNITY_INSTANCING_BUFFER_END(GPUInstancer/shader_env_impostor_foliage_render)
    6.  
    It hates the "/" symbol in "GPUInstancer/shader_env_impostor_foliage_render" buffer name, making an error.
     
    Last edited: Jan 3, 2020
  29. itadakiass

    itadakiass

    Joined:
    Nov 11, 2017
    Posts:
    6
    Hi, I am getting strange results while testing a simple scene (a terrain filled with grass). With GPUI turned on I have about 8FPS, but when I turn it off and let default terrain render grass, I have 50FPS:
    upload_2020-1-5_14-10-46.png

    I've read the "Best Practices" and I understand that GPUI is not always more perfomant than default unity terrain. But I don't understand why DetailInstancingDemo scene with everything disabled except grass is giving a completly different results: 60fps(default) vs 1000fps(GPUI). I even turned off all possible cullings in GPUI settings. What makes GPUI so perfomant in demo scene?

    My scene settings are:
    (GPUI Detail Manager has default settings, except grass quads are turned off for a fair comparison)
    upload_2020-1-5_14-9-24.png

    My setup: Windows 10, Unity 2019.3.0f3, Geforce GTX 1060, i5-7500 CPU

    UPDATE: Just tested on 2019.2.17f with the same results

    UPDATE2: Tried same setup, but with TreeCreator trees and TreeManager. In such case GPUI performs a bit better. I disabled billboards for both GPUI and default terrain renderer. The difference was 20fps (GPUI) vs 15fps (default) for 10k trees. That does not make any sense, because demo scene with 30k trees works fine: 700fps GPUI vs 70fps default

    UPDATE3: Some other tests I made: 10k gameobjects in scene (Tree Creator trees with unity's standard optimized tree shader with Enable Instancing turned on) have the same perfomance as GPUI prefab manager trees:
    upload_2020-1-4_18-52-44.png

    When no realtime shadows are used, GPUI performs x2 slower in comparison to just 10k placed gameobjects (GPUI shadows turned off in Prefab Manager)

    UPDATE4: While testing the scene with trees and no realtime lighting I decided to take a look into profiler window. Here is profiler log:
    https://mega.nz/#!EyhCTCaT!ueRHZOWcDCMNCLJYYTDDpmqqTEOD3f1BJVAtmIKOaQU

    First 200 frames I have GPUI prefab manager turned off. CPU and GPU are both rendering. After 202 frame I turned GPUI on and you can see that CPU is mostly idle with some "waiting for GPU" spikes. GPU on the other hand has a lot of load in "other" group. And for some reason it's Camera.RenderSkybox and RenderTexture.SetActive taking most of the gpu time. Can you please explain this? This is happening only when GPUI is turned on.
     
    Last edited: Jan 5, 2020
  30. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    940
    I seem to be getting shadow popping, which is odd, since I'm not culling shadows. When I disable frustum culling, the shadow pop stops.

    I'm also getting an incredibly odd bug, where specific trees don't cast shadows at their location, but instead the camera's location(?). I have no idea what causes this. I tried enabling useOriginalShaderForShadows, but it didn't do anything.

    Speaking of shadows, is there a way to define a custom shadow mesh for a LOD? Not by referencing another LOD's mesh, but having a mesh dedicated to a shadow?
     
    Last edited: Jan 4, 2020
  31. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    940
    Marking your prefabs as static should have no effect on GPUI :)
     
    Last edited: Jan 5, 2020
    LouskRad and Velo222 like this.
  32. LouskRad

    LouskRad

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

    This could either be cause by a previous error you get in your project, or because of a modification of the terrain at runtime and during the Tree Manager initialization (e.g. adding a tree to the terrain).

    If the former is the case, you need to fix that error first. If the latter, you need to make the runtime modifications on the terrain first and after that enable your Tree Manager.
     
  33. LouskRad

    LouskRad

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

    this looks like a shader error. Please take a look at this wiki F.A.Q to solve this issue.
     
  34. LouskRad

    LouskRad

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

    unfortunately GLES 3.0 does not support compute shaders, so it is not possible to use GPUI on that API.
     
  35. LouskRad

    LouskRad

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

    you can check the profiler to identify what is taking up your resources, and if you can provide some data regarding this, we can help you with some pointers.
     
  36. LouskRad

    LouskRad

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

    GPUI can not replace the Unity particle system. It is designed to work either on mesh renderers or matrices through the usage of its API. Currently, the only way to use GPUI with a particle system is to write your own (e.g. using custom compute shaders).
     
    SpaceRay likes this.
  37. LouskRad

    LouskRad

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

    Since GPUI uses its own instanced rendering system, it does not work with instanced properties. For using it with instance based material variations, you can take a look at this wiki article and the included ColorVariationsDemo scene as an example.

    However, using this with Amplify Shader Editor currently is not possible out of the box since ASE does not support StructuredBuffers, so you need to edit the generated shader manually for this.
     
  38. LouskRad

    LouskRad

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

    GPU Instancer works by leveraging the GPU for its operations. This is why you will always see its operations on the GPU side (as "Waiting for GPU") when you have nothing running on the CPU side.

    The main reason why you get those results in your tests is mainly because you are being GPU bound. The Best Practices wiki and the Terminology pages are designed to give you information on why this is the case, and how you can avoid this by learning more about GPU Instancing in general.

    For example, the Detail Demo Scene performs better because it is closer to a realistic game scenario (with scripts running, game objects around to make use of culling features, and a reasonable amount of grass instances - as opposed to 9 million, etc.)
     
  39. LouskRad

    LouskRad

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

    for the shadow popping issue, you might have enabled Culling for Shadows in your manager. This might cause that shadow poping issue in some cases.

    The shadow over camera issue is most likely caused by the shadow pass of the tree's shader not having the instancing setup defined. You can take a look at this article to see how you can fix it.

    As for a custom mesh for shadows, this currently is not supported.
     
  40. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    940
    I don't see any field for culling for shadows on the manager (Note I'm not using the built in editor), but I do see it on the individual foliage prototypes. I've made sure the prototypes don't have "cullShadows" set to True.

    EDIT: Figured it out, I didn't set hasShadowCasterBuffer to true.

    Hm. I'm not sure what I've done wrong, cause this is the shader:
    Code (csharp):
    1. Shader "GPUInstancer/Ardenfall/Simple Diffuse"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Color", Color) = (1,1,1,1)
    6.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
    7.         _Glossiness ("Smoothness", Range(0,1)) = 0.0
    8.         _Metallic ("Metallic", Range(0,1)) = 0.0
    9.     }
    10.     SubShader
    11.     {
    12.         Tags { "RenderType"="Opaque" }
    13.         LOD 300
    14.  
    15.         CGPROGRAM
    16. #include "UnityCG.cginc"
    17. #include "./../../../Plugins/GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc"
    18. #pragma instancing_options procedural:setupGPUI
    19. #pragma multi_compile_instancing
    20.          
    21.         // Physically based Standard lighting model, and enable shadows on all light types
    22.         #pragma surface surf Standard fullforwardshadows dithercrossfade
    23.  
    24.         // Use shader model 2.0 target, to get cheaper looking lighting
    25.         #pragma target 3.0
    26.  
    27.         sampler2D _MainTex;
    28.  
    29.         struct Input
    30.        {
    31.            float4 screenPos;
    32.             float2 uv_MainTex;
    33.         };
    34.  
    35.         half _Glossiness;
    36.         half _Metallic;
    37.         fixed4 _Color;
    38.  
    39.         void surf (Input IN, inout SurfaceOutputStandard o)
    40.         {
    41.             // Albedo comes from a texture tinted by color
    42.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    43.             o.Albedo = c.rgb;
    44.             // Metallic and smoothness come from slider variables
    45.             o.Metallic = _Metallic;
    46.             o.Smoothness = _Glossiness;
    47.             o.Alpha = c.a;
    48.         }
    49.         ENDCG
    50.     }
    51.     FallBack "Diffuse"
    52. }
    53.  
     
    Last edited: Jan 10, 2020
  41. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    412
    Regarding Detailmanager:
    If I were to convert from a regular terrain to a mesh terrain and I would use the PrefabManager for Billboard Grass, so let's say I take care of creating quads of the billboard grass (with the GPUI Vegetation Shader) and take care of placing them with the no-gameobject workflow. Would I get the same visual results and performance as when using the Detailmanager for the grass or does the Detailmanager have some advantages?

    On a sidenote: Do you have something planned or in the works for using the Detailmanager or a mesh terrain?

    Thank you!
     
    Last edited: Jan 13, 2020
  42. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    172
    Is there something else that needs to be done to enable the floating origin feature, other than setting the toggle and reference transform? My scene Renderers registered in the manager are drawn as if the current origin == original origin, meaning they pop around whenever it shifts.
     
  43. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    666
    Hi Josh,

    your shader is a surface shader, so you can add the keyword addshadow to its pragma to make it generate a shadow pass:

    #pragma surface surf Standard fullforwardshadows dithercrossfade addshadow

    without this, the shader is using the shadow pass from its defined fallback shader (Diffuse) which is not setup for GPUI.
     
    joshcamas likes this.
  44. LouskRad

    LouskRad

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

    in terms of rendering performance, there would not be a noticeable difference. However, if your terrain is a large one, it might be a good idea to implement a partitioning system to save up some memory (the detail manager implements one).

    A detail manager for mesh terrains is currently not in our to-do list.
     
    iddqd likes this.
  45. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    666
    Hi Fewes,

    The floating origin toggle and the reference transform should be all you need. If you are having issues with this, please send us a screenshot of the manager. A video of the issue would also help.
     
  46. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    172
    Sure thing:
    Before the floating origin is activated (the buildings are rendered with GPUInstancer)
    After the floating origin is activated.
    The settings on the manager.
    The prefab prototype settings.

    The "Environment" transform is located at the root in the scene and I have confirmed this is moved when the floating origin is shifted. I should mention I have tried it without the floating origin checkmark enabled, and the result is the same.

    Additionally (but not related to the floating origin), I get an error when trying to add multiple prefab prototypes to the manager. I can get around this by adding them one-by-one, but it is quite the pain for adding many prefabs.
    Here's the error output:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. GPUInstancer.GPUInstancerUtility.DetermineTreePrototypeType (GPUInstancer.GPUInstancerPrototype prototype) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:1464)
    3. GPUInstancer.GPUInstancerUtility.GeneratePrefabPrototype (UnityEngine.GameObject go, System.Boolean forceNew) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:1271)
    4. GPUInstancer.GPUInstancerUtility.SetPrefabInstancePrototypes (UnityEngine.GameObject gameObject, System.Collections.Generic.List`1[T] prototypeList, System.Collections.Generic.List`1[T] prefabList, System.Boolean forceNew) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:1225)
    5. GPUInstancer.GPUInstancerPrefabManager.GeneratePrototypes (System.Boolean forceNew) (at Assets/GPUInstancer/Scripts/GPUInstancerPrefabManager.cs:115)
    6. GPUInstancer.GPUInstancerPrefabManagerEditor.AddPickerObject (GPUInstancer.GPUInstancerPrefabManager _prefabManager, UnityEngine.Object pickerObject, GPUInstancer.GPUInstancerPrototype overridePrototype) (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerPrefabManagerEditor.cs:203)
    7. GPUInstancer.GPUInstancerPrefabManagerEditor.AddPickerObject (UnityEngine.Object pickerObject, GPUInstancer.GPUInstancerPrototype overridePrototype) (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerPrefabManagerEditor.cs:74)
    8. GPUInstancer.GPUInstancerMultiAddWindow+<>c.<OnGUI>b__3_0 (UnityEngine.Object o) (at Assets/GPUInstancer/Scripts/Editor/Tools/GPUInstancerMultiAddWindow.cs:51)
    9. 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:562)
    10. GPUInstancer.GPUInstancerMultiAddWindow.OnGUI () (at Assets/GPUInstancer/Scripts/Editor/Tools/GPUInstancerMultiAddWindow.cs:40)
    11. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
    12. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    13. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
    14. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
    15. UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <3b74787e58694cdda2c241162159b3b7>:0)
    16. UnityEditor.HostView.Invoke (System.String methodName) (at <3b74787e58694cdda2c241162159b3b7>:0)
    17. UnityEditor.HostView.OldOnGUI () (at <3b74787e58694cdda2c241162159b3b7>:0)
    18. UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Boolean canAffectFocus) (at <3b395df51d304a2aba4944c11905c08f>:0)
    19. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean canAffectFocus) (at <3b395df51d304a2aba4944c11905c08f>:0)
    20. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <3b395df51d304a2aba4944c11905c08f>:0)
    21. UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <3b395df51d304a2aba4944c11905c08f>:0)
    22. UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <3b395df51d304a2aba4944c11905c08f>:0)
    23. UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at <3b395df51d304a2aba4944c11905c08f>:0)
    24. UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3b395df51d304a2aba4944c11905c08f>:0)
    25. UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3b395df51d304a2aba4944c11905c08f>:0)
    26. UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <3b395df51d304a2aba4944c11905c08f>:0)
    27. UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <3b395df51d304a2aba4944c11905c08f>:0)
    28. UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <3b395df51d304a2aba4944c11905c08f>:0)
    29. UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <3b395df51d304a2aba4944c11905c08f>:0)
    30. UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <59837000ebf54955a9cb1d31caa86097>:0)
    31.  
    I am using the latest version of GPU Instancer. Thanks!
     
    Last edited: Jan 13, 2020
  47. AsicsoN

    AsicsoN

    Joined:
    May 28, 2019
    Posts:
    1
    Is occlusion culling should work fine in hdrp 6.9.2 (unity 2019.2.12) with GPUI? If yes maybe you have ideas why it isn't in my case? I'm using Nature Manufacture vegetation packs. Frustum culling works and depth texture renders in camera debugger.
     
  48. jlreymendez

    jlreymendez

    Joined:
    Dec 11, 2012
    Posts:
    4
    Hi LouskRad, I'm using 2019.3.0f3 with Asset Database v2 and I am experiencing the same hang on import. If I use the Asset Database v1 it works just fine. Have you experience this with the new asset database version or unity 2019.3?

    After seeing the Editor logs, it looks like the import process enters an infinite loop trying to import the same file over and over again.
     
  49. jlreymendez

    jlreymendez

    Joined:
    Dec 11, 2012
    Posts:
    4
    Update: I tried unity 2019.3.0f5 and it still hangs on my project, but using an empty project with just GPUI doesn't cause the issue. So I think the problem is coming from either unity or a mixed of packages I use. If I delete GPUI from my project the import ends correctly.
     
  50. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    221
    Hello. i am getting an error when i updated my project to unity 2019.2

    Shader error in 'GPUInstancer/HDRP/Lit': failed to open source file: 'Packages/com.unity.render-pipelines.core/ShaderLibrary/Wind.hlsl' at line 316 (on d3d11)

    Compiling Vertex program with UNITY_PASS_SHADOWCASTER PROCEDURAL_INSTANCING_ON
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR

    I have tried updating the asset however without luck can you help?
     
unityunity