Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[RELEASED] GPU Instancer

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

  1. LouskRad

    LouskRad

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

    There should be an error message in the manager and/or in the console window related to this. The issue is most likely that GPUI cannot find the instanced version of the shaders.

    For example, if you have changed the location of the folders or your shader files, this would create the problem you mention after an update since the references could be lost to the auto-converted shaders.

    As for the issue you reported for 1.2.1, the error should not appear in later versions. The tree proxy and hi-z occlusion generator shaders are now added to your builds automatically even if you don't manually put them.
     
  2. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    No, the API methods use some Unity methods that prevent this (e.g. Graphics or Terrain methods).
     
  3. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    81
    Any ETA for Crowd animations to support mobile ? (the platformes that need this the most :) )
     
  4. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    69
    Is this the reason for the HDRP (6.9.0) terrain paint details not working? Everything is pink, but during run-time/play mode everything looks fine?

    HDRP terrain tree painting works in scene, but nothing is showing during run-time?

    Does it matter if I used the tree manager to do lots of grass/detail instead of detail painting or would it kill performance? Likewise if I only use prefabs and the prefab manager for everything?

    What GPU instancer managers should I be using when using the HDRP pipeline?
     
    Last edited: Sep 15, 2019
  5. 838nHex

    838nHex

    Joined:
    May 14, 2014
    Posts:
    9
    "The game objects are instantiated with the MeshRenderers turned of because GPUI takes over their rendering."
    how can I turn them on after instanciating to build the NavMesh and then turn them off for GPUI ?
     
  6. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    The following is from the forum post dedicated on Crowd Animations. At this point, we cannot give an ETA.

     
    amynox likes this.
  7. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    The reason why terrain details don't show in HDRP is because Unity does not still offer a working HDRP grass shader. That is, the details would look pink without GPUI too. However, when you run the scene GPUI takes over the rendering with the auto-created HDRP Lit shader and your details start showing correctly.

    The main difference between the Tree Manager and the Detail Manager is that the latter uses spatial partitioning techniques to lower GPU memory usage; you would not see a noticeable difference in performance unless you have millions of detail instances.

    You could also use the Prefab manager to the same effect with the Tree Manager in terms of performance. Also, you can take a look at the best practices wiki.
     
  8. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    You can disable GPUI Manager you are using to enable the MeshRenderers at any time. Enabling it again will turn the Mesh renderers off and render your registered instances with GPUI.
     
  9. 838nHex

    838nHex

    Joined:
    May 14, 2014
    Posts:
    9
    thanks I'll try
     
  10. 838nHex

    838nHex

    Joined:
    May 14, 2014
    Posts:
    9
    sadly this does not work as expected.
    the good thing is, now I can generate the navmesh after disable the GPUI Manager. But after GPUI Manager enabled the Mesh renderers behave random. I try to do GPUInstancerPrefabManager.UpdateTransformDataForInstance(GPUInstancerPrefab); what sometimes work sometimes not even with very close similar objects.
    enable disabel the GPUI Manager in Editor improves this behavior a bit but also not at 100%;
     
    Last edited: Sep 19, 2019
  11. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,525
    I just got this error. Not sure if this has been reported or if any solutions exist around this.
    On HDRP.

    Code (CSharp):
    1. Compute shader (CSTextureUtils): Property (source) at kernel index (0) has mismatching texture dimension (expected 2, got 5)
    2. UnityEngine.ComputeShader:Dispatch(Int32, Int32, Int32, Int32)
    3. GPUInstancer.GPUInstancerUtility:CopyTextureWithComputeShader(Texture, Texture, Int32, Int32, Int32, Boolean) (at Assets/InitialStuff/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:3207)
    4. GPUInstancer.GPUInstancerHiZOcclusionGenerator:UpdateTextureWithComputeShader(Int32) (at Assets/InitialStuff/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:232)
    5. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRendering(Camera) (at Assets/InitialStuff/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:221)
    6. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRenderingSRP(ScriptableRenderContext, Camera) (at Assets/InitialStuff/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:187)
     
  12. Black_Raptor

    Black_Raptor

    Joined:
    Nov 3, 2014
    Posts:
    99
    How ?
     
  13. DeltaPiSystems

    DeltaPiSystems

    Joined:
    Jul 26, 2019
    Posts:
    26
    Does this work in WebGL?
     
  14. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Can you please send us a sample project so we can see what the issue with your setup is.
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    This should be fixed in GPUI version 1.2.3. The issue was that Unity changed the format of the depth render texture that they use in the HDRP versions for Unity 2019.2.

    If you are still having this issue with GPUI v1.2.3, can you please tell us which Unity and HDRP versions you are using?
     
  16. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Unfotunately WebGL does not support compute shaders; so it doesn't.
     
  17. asdzxcv777

    asdzxcv777

    Joined:
    Jul 17, 2017
    Posts:
    28
    Code (CSharp):
    1. // Made with Amplify Shader Editor
    2. // Available at the Unity Asset Store - http://u3d.as/y3X
    3. Shader "SFShaders/segment shader"
    4. {
    5.     Properties
    6.     {
    7.     }
    8.  
    9.     SubShader
    10.     {
    11.         Tags{ "RenderType" = "Opaque"  "Queue" = "Geometry+0" }
    12.         Cull Back
    13.         CGPROGRAM
    14.         #pragma target 5.0
    15.         #include "UnityCG.cginc"
    16.         #include "Assets/GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc"
    17.         #pragma multi_compile_instancing
    18.         #pragma instancing_options procedural:setupGPUI
    19.         #pragma surface surf Standard keepalpha addshadow fullforwardshadows
    20.         struct Input
    21.         {
    22.             half filler;
    23.         };
    24.  
    25.         void surf(Input i , inout SurfaceOutputStandard o)
    26.         {
    27.  
    28.             o.Albedo = float3(1, 0, 0);
    29.  
    30.         }
    31.  
    32.         ENDCG
    33.     }
    34.         //Fallback "Diffuse"
    35.             CustomEditor "ASEMaterialInspector"
    36. }
    37.  

    This is my simple shader I am using with gpu instancer. The problem is the objects are being rendered black instead of red
     
  18. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Hi there,
    we have tested this, and this shader works as intended with GPUI:

    upload_2019-9-20_15-58-24.png

    The issue might be caused by a screen space effect on your camera, or any other external tools you might be using.
     
  19. asdzxcv777

    asdzxcv777

    Joined:
    Jul 17, 2017
    Posts:
    28
    I was using no gameobject workflow.
    DefineGameObjectAsPrefabPrototypeAtRuntime and InitializeWithMatrix4x4Array
    and the object was black
    After that I created a prefab with same material and added it to gpu instancer prefab manager and it started working both on the instances of prefab and the instances on no gameobject workflow
     
  20. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    161
    GPUI keeps track of the custom shaders and shader variants on the defined prototypes within GPUInstancerShaderBindings and GPUIShaderVariantCollection. If you use a no-gameobject workflow with no predefined prototypes these shaders and variants are not registered. In this case you can either once add these prefabs to the Prefab Manager to register them as you did, or right click on your material and select GPU Instancer -> Setup Material for GPUI
     
    asdzxcv777 likes this.
  21. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    143
    Yes, we removed all missing field from the Map Magic Data and it worked,

    GPUI is amazing!! Our grass looks so much better than before and the performance is really good.
    2019-09-15 03_20_20.jpg


    We just have now a issue with the Occlusion Culling, sometimes it's calculating the Bounds of the objects wrong, or at least I think that's the issue, here the Bug:
    Occlusion Culling1.gif
    Sometimes the Trees disappear even they should be in view and it's only when you move the camera.

    Also, the settings in the GPUI Map Magic Integration don't save the settings in our Project when we Import new Prototypes, is there a way to restore these settings or do we just have to uncheck all other Prototypes which are already Imported?

    Also, we added in GPUInstancerHiZOcclusionGenerator.cs 3 lines at line 218 just because we got problems with our water which does change the _CameraDepthTexture:
    Code (csharp):
    1.  
    2. if ( unityDepthTexture != null )
    3.                 if ( unityDepthTexture.name != "_CameraDepthTexture" )
    4.                     unityDepthTexture = null;
    5.  
    So maybe considering to adding it in future versions, on the same Frame it gets the _CameraDepthTexture again.

    Thanks for the Amazing tool, all the best flow.
     
    Last edited: Sep 22, 2019
  22. asdzxcv777

    asdzxcv777

    Joined:
    Jul 17, 2017
    Posts:
    28
    This should be added to the wiki page
     
  23. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    154
    Is there a way to make objects in the GPUInstancer pipeline show up when rendering a camera with RenderWithShader? I am using a replacement shader for thermal/IR vision and GPUInstancer to render trees, but I cannot get them to show up in the camera when the replacement shader is active.
     
  24. Safemilk

    Safemilk

    Joined:
    Dec 14, 2013
    Posts:
    16
    Hey sorry if this has already been answered, I'v been getting weird multi colored glowing ghost geo flashing at certain angles, all the shader conversion stuff seemed to work fine, but if I stand in a spot where everything that's GPU instanced is being occluded, I see huge transparent ghostly versions of that geo swiping around the screen.

    I can't do a screenshot right now, I'd need to get permission from my producer and make sure it's approved to post it, was just wondering if anyone else encountered this, or has a fix? Thanks in advance. I'll post a screenshot if I can later.
     
  25. cyborgpope

    cyborgpope

    Joined:
    May 16, 2019
    Posts:
    1
    Hi, I Picked this up today. it looks way better and runs faster than what I managed to crap out.

    Part of my game lets you cut grass and collect points. I added my own mower and have it "cutting".

    I want it to add a score every time it "cuts". The old solution I used "grassAdd.Grass += 1;" anytime the mower had a collision with the grass collider. I've been trying to add that to the GPUinstanceremover script but the best I can manage is having continuously count up regardless if it has been cut or not.

    Am I on the right track? Thanks.
     
  26. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    69
    The Tree Manager is not rendering during run-time with HDRP? I'm using Unity 2019.2.6f1 HDRP 6.9.0. Thanks!
     
  27. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Thank you for the feedback.

    The occlusion culling feature requires the _CameraDepthTexture to work, so if you modify this it could break. You can enable the debugger from the HiZOcclusionGenerator script that is added to your camera during play mode, which would overlay the texture that GPUI is using for its culling operations on the screen. The flickering issue looks like caused by the incorrect depth texture, and you can verify it from this debugger.
     
  28. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    You could try setting up your replacement shader to work with GPUI, and disable the Use Selected Camera Only option from your manager.
     
  29. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Hi there,
    it looks like a shader incompatibility. GPUI auto converts most shaders, but in some cases you might need to manually set the shader up. You can take a look at this wiki page to setup your shader manually for GPUI.
     
    Safemilk likes this.
  30. LouskRad

    LouskRad

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

    The remover script works on the GPU, so using it for calculating how many you have removed would not be ideal. On the other hand, GPUI does not remove the colliders on instanced objects, so your solution should still work if you use your old system and have the manager use the "Auto. Add/Remove feature".
     
  31. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Thank you for the feedback. We will look into what Unity has changed in the latest HDRP :)
     
  32. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    154
    This worked, thanks! However, I just realized the trees do not show up even when rendering normally. It seems to be because I am rendering the camera by calling Camera.Render while Camera.enabled is set to false (reason why is to manually control the framerate of the camera). My best guess is that draw calls submitted with DrawMeshInstancedIndirect do not show up when rendering with Camera.Render. I "solved" this by enabling the camera for a single frame whenever I want it to render instead of calling Camera.Render, but it might be worth noting this limitation in the documentation.
     
    Last edited: Sep 25, 2019
    LouskRad likes this.
  33. adhdchris

    adhdchris

    Joined:
    Nov 13, 2013
    Posts:
    45
    Hey guys, just purchased the asset and it's already doing wonders in our high polycount scene. However, when running a build on a pc without a dedicated gpu, it actually makes the performance way worse. Is there a way to detect whether the build is running on a machine with a capable graphics card or not in order to either enable or disable the Instancer managers?
     
  34. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    69
    Any news on when this will get fixed, as it's very much needed. Thanks!
     
  35. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    49
    Thanks for your reply. Alright so if I understand correctly, some scenes are not able to function in HDRP which means HDRP is not fully supported? If so, you should really make this clear on the asset store page, because it simply says the following:
    And so, the only limitation I was aware of (even after reading the documentation) is

    Could you state which features are not supported out of the box for HDRP?

    Anyway, I think GPUI can still be very useful for me and all the demo scenes look really great. The demo I am mainly interested in is the DetailInstancingDemo. I'm aware HDRP has issues with (or doesn't support) details on terrain. So what I'm interested in, is if there's a way I could recreate this scene for example by treating the details as Terrain Trees or maybe just as game objects and feeding them to GPUI?

    Thanks,

    Lenne
     
  36. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    49
    I believe I'm experiencing the same issue on

    Unity: 2019.1.14f
    HDRP: 5.7.2
     
  37. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    352
    I purchased your asset a year ago for a game I am working on, great piece of work. However I have a question; Recently Unity announced DOTS and I am wondering if there are benefits on using your asset over ECS. I am about to start implementing ECS, but before I go down that rabbit hole I thought I should ask if you could help cure my ignorance on the differences. (sorry about my ignorance)

    Thanks kindly, and have a wonderful weekend
     
  38. huntersteeger

    huntersteeger

    Joined:
    Dec 27, 2017
    Posts:
    18
    I'm interested in this asset, I know it does not directly work with Vegetation Studio, but I was wondering if I could use Vegetation Studio for my terrain and this asset for the map detail and props?
     
  39. Vartib

    Vartib

    Joined:
    Jun 14, 2012
    Posts:
    74
    I recently purchased this asset but am disappointed to find that it might not work for what I'm doing. For my project I need to populate terrain with thousands of trees, and the terrain will generally be viewed from a high vantage point. I was hoping to use the auto billboard generation to make this possible, but right now GPU Instancer only generates billboards for side views. I know this is how billboards generally work, but it limits what this asset can be used for.

    Is there currently any way to have GPU Instancer generate a top-down billboard? If not, is this something you would consider adding as an option? Would be a HUGE help for my project. Not sure how I'm going to achieve what I want to do otherwise since without billboarding the FPS drops to 5-10.

    Along with that, is it possible to change the distance at which billboards are created? The pop-in is really bad when a forest is viewed from the top. Since the quality of individual trees isn't super important it'd be nice to save on resources by using just billboards.

    Thanks in advance for your consideration :)

    EDIT: just discovered that the standard Unity terrain has options for changing the distance billboards are displayed at and also displays a top-down billboard. Would still be nice for GPU Instancer to support this!
     

    Attached Files:

    Last edited: Sep 29, 2019
  40. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    140
    Tree Manager doesn't work with baked shadows. Tried both IsShadowCasting on and off. You can see the error in the game view. Scene looks fine if I disable Tree Manager prior to starting the scene. bakedShadows.png bakedShadows2.png
     
  41. shi946

    shi946

    Joined:
    Jun 3, 2019
    Posts:
    6
    I'm new to using the GPU Instancer so pardon me if these questions make no sense. I've so far instanced 60 different runtime generated prefabs through code but I'm at 1 fps since many of those prefabs are buildings (from the Dark City 2 pack) with hundreds of thousands of gameObjects. Going off the runtime tutorial in the unitypackage and your video from:


    1. How do I handle runtime generating a bunch of building prefabs with nested gameObjects? Codewise, would I need loop through every building and add each wall/window to the instance prefab list and each instance of that wall/window (for multiple buildings) to the instance list?

    2. What if two different buildings have the same window? Does the instance prefab list need to be unique? Will GPU Instancer know to handle them in the same batch/similarly?

    2.5 What if the two windows have the same mesh but different materials (or v.v.)? Should I add both to the instance prefab list?

    3. Finally, what about nested gameObjects without any mesh filters/renderers (i.e. colliders or blank parent gameObjects of a bunch of walls, for example), will the program ignore them for batching?
     
  42. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    154
    Is it possible to change the LOD Bias Adjustment during runtime? Would be great to allow the user to pick a quality level. Setting lodBiasAdjustment from code doesn't seem to have any effect while the game is running.
     
    Last edited: Sep 30, 2019
  43. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Yes, since GPUI leverages the power of the GPU to free resources in the CPU, it would beat the purpose if you use it in a shared system with no dedicated GPU.

    The queries that you can make from Unity would be in the SystemInfo class but as far as I know there is no query that you can make to determine whether a platform has a dedicated GPU. You could try something like:

    if (SystemInfo.graphicsDeviceName.Contains("Intel") || SystemInfo.graphicsDeviceName.Contains("Integrated")

    to cover the mostly used integrated GPUs, but of course this would not cover every integrated GPU out there.
     
  44. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    We have tested the Tree Manager with Unity 2019.2.6f1 and HDRP 6.9.0 with trees that use the HDRP Lit shader and all seems to be working in order. Can you tell us what tree shader you are using?
     
  45. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    It is not the case that some HDRP scenes don't function with GPUI, rather, GPUI's demo scenes are not designed for HDRP (they don't have versions that have HDRP specific shaders).

    GPUI is designed to provide out of the box indirect instancing to provide performance, and this will work in HDRP scenes as well. However, GPUI also provides some custom tools for ease of use and visual quality, (e.g. the LOD color changer or the Foliage shader) which are designed for the Standard pipeline and these don't have additional HDRP versions (reason for this being Unity changing the HDRP shaders with each update and also not supporting indirect instancing with shadergraph yet).

    You can use the detail manager by using a custom HDRP foliage shader that is setup to use with GPUI. But again, Unity has not improved the shadergraph to allow for this setup so the shader must be written without it.
     
  46. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Hi there,
    GPUI is a rendering solution, as opposed to DOTS. Thus it would lower your draw calls and leverage the power of your GPU for rendering unrelated to whether you use DOTS or not. Please have in mind, however, if you are planning to use GPUI with DOTS, you need to use a no game object workflow since you do not have conventional GameObjects with DOTS.
     
    JamesWjRose likes this.
  47. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Hi there,
    Yes, VS and GPUI can't work on the same objects. However, you can use GPUI for your prefab instances and VS for your vegetation in the same scene.
     
    huntersteeger likes this.
  48. LouskRad

    LouskRad

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

    You can change the billboarding distance from the Billboard Settings. As for the top down billboards, GPUI has a 2D billboard generation system as you mentioned; however it also supports custom billboards, so you can either make your own billboards or use other tools (such as the Amplify Impostors) if you want more detailed billboards.
     
  49. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Hi there,
    Unity does not support indirect instancing with baked shadows. You can check GPUI's lighting limitations from here.
     
  50. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    602
    Hi there,
    you can check this wiki page to determine what you should define as a prototype to the Prefab Manager. The page also contains information on Nested Prefabs.

    For runtime added instances, you can use the Auto. Add/Remove instances feature, which does not require you to write any additional scripts. If you wish to register your instances from code, however, you can take a look at the AddRemoveInstancesDemo scene for an example.

    Also, GPUI checks the original prefab for the material, so the variations on the prefab instances will not be registered. For an example for material variations, you can check the ColorVariationsDemo scene.

    Finally, GPUI only checks the Mesh Renderers and LOD Groups on the prefabs, so all other components will be ignored. GPUI disables the renderers and takes over rendering, leaving all other components intact.