Search Unity

[RELEASED] GPU Instancer

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

  1. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi chingwa, and thanks!

    GPUI Tree and Detail managers were designed with the idea that each manager would be responsible for a single terrain. This results in managers that are not aware of each other, so even if there are shared prototypes in different terrains, the managers make separate drawcalls for them.

    Therefore you would indeed get a better result (in terms of rendering) if you have prefabs defined in the prefab manager instead of terrain prototypes. And even better results if you use a no-game object workflow (but you would have to manage your colliders).

    Currently, an optimization for "multiple terrains", along with various other features which will redefine how GPUI handles Unity terrains is indeed among our plans. However, these require fundamental changes to the core GPUI code as far as detail and tree instancing goes and thus will require a relatively major update - potentially one in which we will deprecate the Detail and Tree Managers and GPUI will use a single manager to handle everything related to the Unity terrain(s). So at this point I cannot give you concrete information on when and in what form these changes will be implemented.
     
    chingwa likes this.
  2. LouskRad

    LouskRad

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

    The reason why you had to add a prefab to the prefab manager once each time you created a new shader is beacuse two things happen when you add a prefab to a manager:

    (1) GPUI creates a new, compatible version of this shader with the _GPUI suffix,
    (2) The shader is added to a ShaderVariantsCollection to be added to the build.

    With version 1.1.3, we have added a manual shader conversion tool which you can access by right clicking on the original shader file. This takes care of (1) without you having to add a prefab that uses this shader to the manager. You can use this from the context menu item GPUInstancer -> Setup Shader for GPUI.

    In the next update, we will also add a tool that sets up a material for GPUI - which will take care of both (1) and (2). GPUI will assume you will have this material in your build, and take care of the ShaderVariantsCollection as well without you having to add the prefab to a manager. You will be able to use this from the context menu item GPUInstancer -> Setup Material for GPUI.

    Please note that you can currently use the Setup Shader for GPUI command to generate a compatible shader and use this generated shader on your original prefabs' materials for the same effect.
     
    sebas77 likes this.
  3. LouskRad

    LouskRad

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

    the ColorVariationsDemo example was designed for use with DirectX 11 supporting platforms. You can find in the attached package a version of this shader that will work with all platforms. We will change the current shader with this one in the next update.
     

    Attached Files:

  4. LouskRad

    LouskRad

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

    GPUI Detail and Tree Managers are terrain based, and indeed if you use the same terrain in multiple scenes, GPUI expects the terrain to be the same. You can, however, achieve multiple settings for a single terrain from code by using the GPUInstancerAPI. You can take a look at the AddModifyTerrainsRuntimeDemo scene for an example usage of this.

    Older Unity versions have issues with GPU instancing and compute shaders - which were not fixed yet in versions before 5.6.5.
     
  5. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    The prefab manager uses the shader properties on the original material as they are. So for a tree using a custom shader, the wind would perform as it normally would when the prefab instance is put to the scene without GPUI.

    However, if you are using a Tree Creator tree, you will need to set the "_Wind" global vector. You can take a look at this wiki document to see how you can do this.
     
  6. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Thank you for the feedback. It looks like this might be caused by the foliage shader setting the mesh normals to y-up. We will look into this, and include any necessary changes/fixes to the shader in a future update.
     
  7. sebas77

    sebas77

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

    I am going to check the examples tomorrow (need to leave the office now), but if you are so kind to reply before I start to work tomorrow it would be great too.

    for the gameobjectless scenario is
    DefineGameObjectAsPrefabPrototypeAtRuntime still the way to go? I am saying this because when I run this in the editor it still tries to add a component in the gameobject prefab, which I suppose is the GPUInstancerPrefab. Sorry if I am still confused about this stuff :(
     
  8. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    52
    Works like a charm. Many thanks @LouskRad !
    To explain this, I am flattening resources into a texatlas (or a buffer which) have variable length per instance. For those only a direct .settexture() or setbuffer() makes sense.
     
    Last edited: Jun 3, 2019
    LouskRad likes this.
  9. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    When using a no-gameobject workflow, the best practice would be to have a Prefab Manager in your scene with your desired prefabs defined on it as prototypes. You can check the Best Practices wiki article on this, and examine the PrefabsWithoutGameObjects example demo scene for reference.

    You can still use DefineGameObjectAsPrefabPrototypeAtRuntime if you wish: It was designed for use with procedurally created GameObjects at runtime (where you don't have any prefabs), although it would work with a prefab as well. If you use it with an existing prefab, it would add the GPUInstancerPrefab script on the prefab. It would add it to the precedural object too. For an example usage of this in a procedurally created GameObject scenario, you can take a look at the AddRuntimeCreatedGameObjectsDemo example scene.
     
  10. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    OK I think it's actually better if we put the prefabs in the prefab manager, but wouldn't this step add the gpu instancer prefab monobehaviour anyway? I think using this path it should be needed, however some of our code rely on knowing the GPUInstancerPrefabPrototype which in this way it seems I can't get hold of. I have to admit, I am confused

    P.S.: your example assumes I can drag and drop it in a monobehavior, but we don't use monobehaviours

    P.P.S.: got it I can get it from the GPUInstancerPrefab
     
    Last edited: Jun 4, 2019
  11. LouskRad

    LouskRad

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

    We're excited to announce that the Crowd Animations extension BETA version has been released on the Asset Store.
     
    838nHex, Bamfax and sebas77 like this.
  12. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Sorry I have no good news,

    still banging my head on random errors (but I am sure it's because I am still misunderstanding something). So it worked for a while (waaat) and then suddenly stop to work again, now I get random errors:

    Can not find runtime data for prototype: Axle_1. Please check if the prototype was added to the Manager and the initialize method was called.
    UnityEngine.Debug:LogError(Object)
    GPUInstancer.GPUInstancerManager:GetRuntimeData(GPUInstancerPrototype, Boolean) (at Assets/Code/Libraries/GPUInstancer/Client/Scripts/Core/Contract/GPUInstancerManager.cs:802)

    and the shaders look broken in the gpui prefab manager:

    upload_2019-6-4_16-15-49.png

    no clue what's going on.

    also since I moved away from the "procedural" approach, but still using the "gameobject less approach with prefabs" woudl I need to use these options (not used so far)

    upload_2019-6-4_16-24-39.png

    I guess I don't need to.

    BTW in case it's still not clear what I am doing: I use prefabs, but I don't want gameobjects at run-time. However there are exceptions to this rule and some times we need to create gameobjects for prefabs that are usually managed by GPUI. Now since these prefabs are registered, GPUI try to instantiate them, but I don't want this to happen :(

    on these gameobjects that must not be instantiated by GPUI this is what I see:

    upload_2019-6-4_16-32-9.png
     
    Last edited: Jun 4, 2019
  13. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    163
    Thank you! This is perfect :)
     
    LouskRad likes this.
  14. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    I am not sure what you are exactly doing, but if you are confused on what to do, I strongly suggest watching the Prefab Manager tutorial video and reading the wiki documentations on setting up the Prefab Manager and using a no game object workflow with it.

    Here is what you can do to start from scratch (in this order):

    - Remove (all) the GPUI Managers from your scene.
    - Delete the GPUInstancer/PrototypeData folder from your project.
    - Delete the GPUInstancer/Resources/Settings folder from your project.

    You are now in effect starting from scratch.

    - Add a Prefab Manager from Tools -> GPU Instancer -> Add Prefab Manager
    - Add the prefabs that you wish to use with GPUI to the prefab manager by using the Add button (or drag/drop on it).
    - Do not delete any generated files or added components.

    You now have a manager setup to use your prototypes.

    For using this manager with a no-game object workflow, all you need is the InitializeWithMatrix4x4Array and the UpdateVisibilityBufferWithMatrix4x4Array methods, as described in the wiki article.

    Edit:
    Since you edited your post while I was writing this, here is additional information related to your edit:

    You cannot use a prefab as a GPUI prototype and not as a GPUI prototype at the same time. If you wish to do that, you could make them separate prefabs and define the one you use for GPUI to the manager.

    P.S. Please write further questions related to your project via email. This will help us keep track of your question history related to your project.
     
    sebas77 likes this.
  15. Whitebrim

    Whitebrim

    Joined:
    Jul 11, 2017
    Posts:
    17
    Looks like it doesn't work with skinned mesh renderer. Or am I wrong?
    upload_2019-6-4_20-25-20.png upload_2019-6-4_20-26-10.png
     
  16. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi there,
    You are right. Skinned Meshes require additional GPU Skinning techniques in addition to GPU instancing. We have recently provided support for skinned mesh renderers in the form of an extension asset: GPU Instancer - Crowd Animations
     
  17. nova234

    nova234

    Joined:
    Feb 19, 2018
    Posts:
    17
    Can i bake the light ( forward rendering ) for the instances or cant i use your plugin with baked light ? Because i want to buy it and after i saw it by a friend and everything was baked with light exclude the instance objects. It lookes wierd after i hit the play button, because the half of scene was with great baked shadows and the other half has no shadows.
     
  18. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433

    Cool i'll check out that demo, for the 5.6.0 question, it does seem to work fine in 5.6.3 but in 5.6.0 i get an import error of the camera preview, i tinkered with fixing it but couldn't seem to find the right replacement.

    Any thoughts on this would be appreciated, i'm sure if that one error is fixed it should work like it does in 5.6.3

    EDIT: Alright so i was able to customize each scene with a custom script that sets the values i want on start with a small buff. So far works like a charm, thanks for the tip.
     
    Last edited: Jun 6, 2019
  19. LouskRad

    LouskRad

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

    GPUI indeed does not support baked lightmaps on the instances that it is rendering.
     
  20. LouskRad

    LouskRad

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

    Please take a look at the 53rd item from the changelog of 5.6.3:

    "Graphics: Fixed an issue where a ComputeBuffer applied to a Material Block doesn't take effect when drawing via DrawMesh*Indirect."

    Even if you fix editor errors, GPUI would not run stable with 5.6.0.
     
  21. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    So basically i have to upgrade to 5.6.3 then, guess i'll see how that goes but definitely ideal to keep it in 5.6.0

    Also, i'm noticing some discrepancies with the custom terrain settings, the settings never change but the display seems to, each time i open the project.

    For instance i setup some grass in a specific way last night, saved the scene/project and closed, ran it again today and it looks different, so i closed the project, re-opened and it looks different again.

    Not sure what is up with that as it should technically render the same way every time right?
     
  22. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Well, GPU Instancer supports only 5.6.5 and above, so I can only say that you need to upgrade to that minimum version.
     
  23. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    Seems to work fine in 5.6.3 for me :3
     
  24. Raul_T

    Raul_T

    Joined:
    Jan 10, 2015
    Posts:
    363
    Hello, we are using GPU Instancer in our open world scene, and I was wondering if there are still any advantages of combining smaller assets' textures into texture atlases with a single material as we still don't understand exactly how instancing is handled inside the plugin.

    For example our 3d artist authored a set of 16 rocks that share the same texture set on a 4x4 atlas in a 4k texture and use 1 material for all of them. So the question is, would GPU Instancer still benefit from "batching" multiple game objects into a single material like unity's built in batcher does?

    Asking because we've seen that GPU Instancer handles batching based on prototypes rather than materials and we are not sure if in our use case using GPU Instancer would actually result in more drawcalls.

    Thanks.
     
  25. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    52
    Objects which share the same material and same mesh can be batched together. For the DMII API an object is defined by its specific mesh and its specific material. This DMII "object" can then be drawn as often as desired using just a single drawcall.

    The biggest gain (performance-wise) would be achieved in a scenario where a low-poly object needs to be drawn quite often (hundreds / thousands or more instances).

    Instancing properties of a DMII object works somewhat different compared to unity standard methods, e.g. MPBs. Instancing is based on any shader properties that are feasible to push into and handle inside the shader. A TextureAtlas would work well, if the rock shader handles which atlas UVs are used on which rock instance. E.g. the shader could do a simple instanceId % 16 = uvToUse.
     
    Last edited: Jun 11, 2019
    Raul_T and LouskRad like this.
  26. farzaan090

    farzaan090

    Joined:
    Jul 23, 2018
    Posts:
    15
    I am using a Tree Creator tree however, if there is no wind in my scene, the tree stands still. But if I add wind to the scene (prior to runtime), the tree acts extremely wonky. Very different than the same tree with the same wind but not using GPUI.

    I attempted to set the wind with the script you linked but it had no effect at all on the trees so maybe I am not using it correctly. I am testing it by just running Shader.SetGlobalVector("_Wind", GPUInstancerManager.GetWindVector()); at start or upon pressing a test key but it has no effect.
     
    Last edited: Jun 13, 2019
  27. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    259
    Is it possible to write a custom compute shader which outputs positions/rotations/etc. to a structured buffer for GPUInstancer to use? I know about dynamically changing the instance list via C#, but I'd like to keep it on the GPU if possible.
    I'm currently implementing a system which uses terrain height map textures and a compute shader, along with DrawMeshInstancedIndirect to draw detail meshes around the camera, but since GPUInstancer has an awesome pipeline for drawing instanced meshes already, I'd love to use it instead, if possible. Thanks!
     
    Last edited: Jun 14, 2019
  28. alexr1221

    alexr1221

    Joined:
    Mar 5, 2016
    Posts:
    70
    Hello,

    What do you think of adding grass cascades to the optimizations possibilities? It would improve performances but would also be beneficial on the art side, since it would show the grass smoothly instead of having a strong line.

    [Picture]

     
    Last edited: Jun 15, 2019
    chingwa, iddqd and RomBinDaHouse like this.
  29. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Great idea, hope it's possible.
     
    alexr1221 likes this.
  30. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Or perhaps having the grass shader do stochastic fading the further it gets into the distance...?
    (or both)
     
    GurhanH and alexr1221 like this.
  31. miklelottesen

    miklelottesen

    Joined:
    Mar 7, 2015
    Posts:
    19
    ** UPDATE **
    It turns out that the crash was caused by some old asset that I wasn't even really using, so I removed it and the crash is gone - it now instantiates the vegetation like it did before. However, I still get the previously mentioned errors and all the GPUInstancerPrefabs seem to be instantiated like regular prefabs.

    ** FINAL UPDATE **
    I did some digging, and found out that the issue lies with the initial shader binding error - I'm using SpeedTree 8 trees, and in GPUInstancerShaderBindings.cs it looks for the shader GPUInstancer/Nature/SPDTree8. However, upon further inspection it appears that this shader is nowhere to be found - there's an SPDTree shader, but the shader for SpeedTree 8 seems to be completely missing from the imported asset files.

    ** Original post: **

    Hi

    I just bought the asset today, and I've had some trouble integrating it into my project.


    My project is a 3D first-person game that consists of a huge 100% generated world, so the scene is completely empty to begin with and the terrain and vegetation is spawned at runtime, and is updated as the player moves.

    The generation system is quite complex, but in a nutshell, every time new chunks are needed, it first generates and instantiates terrain tiles in each chunk, then it procedurally instantiates vegetation prefabs picked randomly from a list inside a set of smaller chunks, on top of the terrain (and at the same time handles removal of terrain vegetation in old chunks).

    There are around 40k vegetation instances around the player at all times (hence the interest in this asset, as I wouldn't mind increasing that number) with thousands being spawned every time a new set of chunks are generated, so every part of the aforementioned process is spread across multiple frames.


    After importing the GPU Instancer into my project, I did the following:
    • Added the GPUInstancerManager to the scene
    • Added all prefabs from my spawning system's prefab list to the manager (enabled add/remove at runtime for all of them)
    • Changed the prefab list's type from <GameObject> to <GPUInstancerPrefab> in my spawning system
    • Changed GameObject.Instantiate to GPUInstancerPrefab.Instantiate
    • Made sure to call the initialize method on Awake (I've also tried without doing that)

    And when I hit Play, an error appears in the console:

    Code (csharp):
    1. Uploading Crash Report
    2. ArgumentNullException: Value cannot be null.
    3. Parameter name: shader
    4.   at (wrapper managed-to-native) UnityEngine.Material.CreateWithShader(UnityEngine.Material,UnityEngine.Shader)
    5.   at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00009] in C:\buildslave\unity\build\Runtime\Export\Shaders\Shader.bindings.cs:118
    6.   at GPUInstancer.GPUInstancerShaderBindings.GetInstancedMaterial (UnityEngine.Material originalMaterial, System.String extensionCode) [0x00077] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\Core\DataModel\GPUInstancerShaderBindings.cs:130
    7.   at GPUInstancer.GPUInstancerRuntimeData.CreateRenderersFromMeshRenderers (System.Int32 lod, GPUInstancer.GPUInstancerPrototype prototype) [0x0013a] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\Core\DataModel\GPUInstancerRuntimeData.cs:372
    8.   at GPUInstancer.GPUInstancerRuntimeData.CreateRenderersFromGameObject (GPUInstancer.GPUInstancerPrototype prototype) [0x000aa] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\Core\DataModel\GPUInstancerRuntimeData.cs:246
    9.   at GPUInstancer.GPUInstancerPrefabManager.InitializeRuntimeDataForPrefabPrototype (GPUInstancer.GPUInstancerPrefabPrototype p, System.Int32 additionalBufferSize) [0x00036] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\GPUInstancerPrefabManager.cs:237
    10.   at GPUInstancer.GPUInstancerPrefabManager.InitializeRuntimeDataRegisteredPrefabs (System.Int32 additionalBufferSize) [0x0007f] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\GPUInstancerPrefabManager.cs:227
    11.   at GPUInstancer.GPUInstancerPrefabManager.InitializeRuntimeDataAndBuffers (System.Boolean forceNew) [0x001b5] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\GPUInstancerPrefabManager.cs:183
    12.   at GPUInstancer.GPUInstancerManager.OnEnable () [0x000ef] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\Core\Contract\GPUInstancerManager.cs:202
    13. (Filename: Assets/GPUInstancer/Scripts/Core/DataModel/GPUInstancerShaderBindings.cs Line: 130)
    The game runs for a bit as the terrains load, then Unity crashes so bad that Ctrl+Alt+Del is necessary (sometimes even a hard reboot). As for the log, this seems to happen for every vegetation instance:

    Code (csharp):
    1. Can not find runtime data for prototype: Bamboo. Please check if the prototype was added to the Manager and the initialize method was called.
    2. UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
    3. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    4. UnityEngine.Logger:Log(LogType, Object)
    5. UnityEngine.Debug:LogError(Object)
    6. GPUInstancer.GPUInstancerManager:GetRuntimeData(GPUInstancerPrototype, Boolean) (at Assets\GPUInstancer\Scripts\Core\Contract\GPUInstancerManager.cs:802)
    7. GPUInstancer.GPUInstancerPrefabManager:AddPrefabInstance(GPUInstancerPrefab, Boolean) (at Assets\GPUInstancer\Scripts\GPUInstancerPrefabManager.cs:502)
    8. GPUInstancer.GPUInstancerPrefabRuntimeHandler:Start() (at Assets\GPUInstancer\Scripts\GPUInstancerPrefabRuntimeHandler.cs:43)
    9. (Filename: Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs Line: 802)
    I've watched the tutorial video on runtime instantiation, checked out the relevant demos and the API documentation, but clearly there's something I'm missing. What am I doing wrong?

    Edit: Btw, I'm using Unity 2019.2.0b5. I know it's far from optimal, but it was necessary to fix a bug that made the editor unusable.
     
    Last edited: Jun 16, 2019
  32. Quested

    Quested

    Joined:
    May 23, 2013
    Posts:
    13
    Hey, yesterday I found a contact formula on your website and dropped you an message through it, but didn't got any confirmation e-mail, so I thought I would try it here again. I'm looking for a way to have the player interact with foliage/trees from Unitys terrain system(using custom colliders + components). As all colliders except capsule colliders as well as all components seem to be ignored when using the normal Unity terrain without any modifications. Looking through the documentation and the videos I found I'm not sure if this can either be achieved by using the Tree Manager or the Prefab Manager or not at all. I have not yet bought the asset and would like in beforehand if this is indeed the case.

    I will mention it here one more time again, as I would really like to see it, why is there no Discord server for this asset? Every major asset has a Discord server nowadays for easier and faster help, both from the developer, but also from the community itself. We have a pretty big project and would like to know in beforehand that we can get expect help if there are any issues, not just with multiple days delay.

    Best Regards,
    Niklas
     
  33. Bamfax

    Bamfax

    Joined:
    Jun 12, 2016
    Posts:
    52
    I for my part am very happy with the support here. Answers are always spot on. Support is extensive considering all options from demos, to wiki, faqs, best practices at last but not least the forum here. All in all this is a knowledge base accompanying this app which offers a very straight forward way to find the respective solution in very little time.
     
    GurhanH and Akshara like this.
  34. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    I like forums much more than discord, personally. I can handle a delay in response, and it's unrealistic to expect all asset developers to run a discord server.
     
    Last edited: Jun 16, 2019
    GurhanH, Bamfax and Akshara like this.
  35. GurhanH

    GurhanH

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

    We were not able to recreate this issue in our tests. Can you please email us a sample project showing this issue so that we can investigate?
     
  36. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Hi there and thanks!

    There is a demo called CustomComputeShader within the package that exemplifies such a use case. You can use it as a reference to implement your own custom compute shaders and to read/write from GPUI buffers.
     
  37. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Hi there and thanks for the feedback.

    We will look into this for texture type detail prototypes. But for now if you need more LOD levels you can do this by creating a prefab with an LOD group component and add the desired cascades as LOD levels. Also you can easily replace your texture detail prototypes with this prefab (without the need to repaint) from the manager using the Edit button.

    For GPUI there is no difference in terms of rendering performance between a texture detail prototype or a prefab detail prototype with a mesh renderer of quads and a material with Foliage shader.

    However, you need to consider that each LOD level will result in new draw calls. So increasing number of LOD levels might not always affect the performance for the better.
     
  38. GurhanH

    GurhanH

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

    The GPUI supported version of the SpeedTree 8 shader is included as an extra unity package. Normally when GPUI used with a SpeedTree8 prefab, this package is automatically imported to your project. But if for some errors this process is disrupted, you can manually import this shader package from GPUInstancer/Extras/GPUI_SpeedTree8_Support. This will create the shader in this location:
    GPUInstancer/Shaders/Nature/SPDTree8_GPUI.shader.

    Please let us know if this does not solve your problem.
     
  39. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Hi there,
    Thank you for the feedback. We will look into adding a confirmation email to the contact form to dispel any future confusions. We have replied to your mail about your use case.

    As for the Discord server, the system of support differs for each publisher/company. We decided to use the forums and email only after careful consideration. We believe that giving support this way allows us to analyze your questions in detail and give targeted answers to resolve your problems. The forums also provide an environment where the community can share their own experiences and/or help others - and we prefer the forums over a discord-like environment for this because we wish to use the time that would be spent on moderating such an environment to improve GPUI. In any case, our main strategy is to create a knowledge-base with solutions to common pitfalls, best practices, and information in general so that our users can use GPUI with a solid understanding of what it does - as opposed to answering user specific questions on the fly.
     
    Akshara likes this.
  40. Black_Raptor

    Black_Raptor

    Joined:
    Nov 3, 2014
    Posts:
    181
    Hi !

    I use this asset on PC, but i recently bought an Oculus Quest, and i see you mention GPU Instancer work on Vulkan, do you think he will worth to use GPU Instancer on oculus Quest ? In regard of the hardawre, he have an Snap Dragon 835 with Adreno 540 GPU is it enough for instantiate some vegetation ? On what hardware did you make your test ?
     
  41. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    259
    I got this set up and running now (it was very easy with how clean the compute shader was). Thank you very much!
     
    GurhanH likes this.
  42. Mozq8

    Mozq8

    Joined:
    Dec 30, 2016
    Posts:
    61
    Greetings, I am planning to include this plugin to production.
    Got a couple of questions.
    1) Does this asset works with mobile devices? I mean occlusion culling and etc
    2) Is it possible to use this asset with AR, particulary ARCore and ARkit plugin or maybe AR Foundation?

    I am just trying to get more info before buying this asset.
    Thanks!
     
    Lars-Steenhoff likes this.
  43. miklelottesen

    miklelottesen

    Joined:
    Mar 7, 2015
    Posts:
    19
    Thanks for the reply. Yup, that solved the problem! Guess I should've checked out the imported files..

    However, there are a couple of issues with the instanced SpeedTrees:
    • They don't seem to support wind at all
    • For some reason, it seems that all LOD levels, including billboards, are displayed simultaneously, regardless of the distance to the tree and its size on the screen
    I'm assuming that these issues has something to do with them being handled by the prefab manager and not the tree manager (I've never used (and will never use) the Unity terrain's built-in tree and detail features, as I prefer to handle them on my own). But how can it be fixed?
     
  44. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Hi there,
    We haven't tested GPUI with the new Oculus Quest. The specs you have mentioned are in the same range with some of the Android mobile devices - I would thus expect a similar performance with them. However, I do not know if there are any other technical limitations that would apply.

    Please let us know of the result if you decide to test GPUI with this device.
     
  45. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Hi there,
    and thank you for your interest in GPUI.

    The occlusion culling feature is supported in mobile platforms for the built-in render pipeline.

    As for ARCore and Arkit plugins, we have not tested GPUI with these, so I cannot give you any concrete information at this point.
     
  46. GurhanH

    GurhanH

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

    This could most likely be caused by a non-standard LOD Group usage with the SpeedTree model. GPUI expects the LODGroup to be on the parent object and child renderers under the parent (as it is exported from the SpeedTree modeller). If you could send us some information on how you set up your SpeedTree prefab, we can help you identify the problem.
     
  47. miklelottesen

    miklelottesen

    Joined:
    Mar 7, 2015
    Posts:
    19
    From your reply, I think I can already identify the problem. The prefab manager wouldn't allow me to add the prefabs that SpeedTree 8 exports (the .st files), telling me to wrap them into a prefab, so I did just that: created an empty GO in the scene, added an .st prefab as a child and then saved the empty GO with the .st child as a new prefab - if I understand correctly, I should have added the .st prefab DIRECTLY to the scene and saved THAT as a separate prefab, right?

    So instead of:
    • Prefab
      • Parent (with LODGroup comp.)
        • LOD0
        • LOD1
        • etc.
    ..it should be:
    • Parent (with LODGroup comp.)
      • LOD0
      • LOD1
      • etc.
    ..???

    Most of my SpeedTrees are used as-is, without any modifications, so I'll try testing one of these trees with the "correct" approach, as outlined above, and see if it works.

    However, some of the trees I've modified a bit - because I want some trees to be climbable and therefore use a custom mesh collider, I export these trees without colliders (along with a mesh to use as collider), then (in Unity) wrap the exported .st prefab into a parent prefab, that has the mesh collider, á la:
    • GameObject (with mesh collider)
      • Parent (with LODGroup comp.)
        • LOD0
        • LOD1
        • etc
    I guess it would be possible to omit the wrapping prefab, like with the previous cases, and attach the collider to the parent with the LODGroup comp. However, I have a single tree that is actually a SpeedTree split in 2, then joined, like thus:
    • GameObject (with mesh collider)
      • Parent (part 1) (w/ LODGroup)
        • LOD0
        • LOD1
        • etc
      • Parent (part 2) (w/ LODGroup)
        • LOD0
        • LOD1
        • etc
    Would it work if I set it up like this:
    • Parent (w/ LOGGroup)
      • LOD0 (empty GO)
        • LOD0 (from part 1)
        • LOD0 (from part 2)
      • LOD1 (empty GO)
        • LOD1 (from part 1)
        • LOD1 (from part 2)
      • etc
    ???
     
  48. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    538
    Exactly.

    Yes it would work with this setup.

    By design GPUI prototypes can have only one LOD Group component which has to be on the parent GO of the prefab. Main reason of this is that GPUI does the LOD calculations on the GPU and the compute shaders and buffers are designed according to this. Managing multiple LOD groups within child GOs would create infinite possibilities which would be very hard to manage in the GPU with predefined structures.
     
  49. miklelottesen

    miklelottesen

    Joined:
    Mar 7, 2015
    Posts:
    19
    Just tested it, and can confirm that it works! Both in regards to wind and LODs. I'll treat the rest of my trees similarly, and consider this matter as closed!

    It makes a lot of sense why it's designed like this - I've worked extensively with compute shaders myself at a less intermediate level, so I can easily imagine how utterly complex advanced stuff like managed GPU instancing would become!! So having it easily available like this is absolutely a godsend. Once I've gotten it completely integrated, you can expect a positive review on the asset store :)

    Thanks for the support!
     
    GurhanH likes this.
  50. miklelottesen

    miklelottesen

    Joined:
    Mar 7, 2015
    Posts:
    19
    Ah, it seems that I have already run into another snag. A pair of them, in fact.

    Firstly, there seem to be some lighting issues - or rather, shadow issues. In my project, I'm generating a jungle around the player, consisting of huge, dense trees. The player is constantly surrounded by several layers of thick trunks, branches and canopy in all directions, but occasionally spots of sunlight make it through. However, depending on the camera's position and look direction, the shadows change between letting the sunlight correctly through, letting it partially through and not letting any light through, leaving everything covered in shadows (which is the case most of the time). What could be causing that?

    Update: After I fixed the culling issues (see the bottom of the post), I tried once again to disable "Use culling for shadows" and this time it worked! It seems like culling generally works quite unpredictably when in LWRP mode, at least if LWRP isn't actually used, like in my case.

    Secondly, I ran into some issues when attempting to build the project:

    Code (CSharp):
    1. Shader error in 'GPUInstancer/Nature/SPDTree8': undeclared identifier '_DitherMaskLOD2D' at Assets/GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc(56) (on d3d11)
    2.  
    3. Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL LOD_FADE_CROSSFADE PROCEDURAL_INSTANCING_ON _WINDQUALITY_NONE
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF3 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_HARDWARE_TIER1 UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
    Code (CSharp):
    1. Shader error in 'GPUInstancer/Billboard/2DRendererTree': undeclared identifier '_DitherMaskLOD2D' at Assets/GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc(56) (on d3d11)
    2.  
    3. Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL LOD_FADE_CROSSFADE PROCEDURAL_INSTANCING_ON
    4. 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_HARDWARE_TIER3 UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
    Lastly, just a question about performance. Would it be reasonable to expect GPUI to handle 500k SpeedTrees without any problems? Thousands of them are trees with a general tri count in the 20k-50k range, but most of them are small grass patches with a tri count in the 1000's being instantiated as no-GameObject instances.

    Thank you for your time :)

    Edit: Again, I'm using Unity 2019.2.0b5 - don't know if that could be responsible for some of the issues..

    Also, occlusion culling doesn't seem to work. The generator doesn't get added to the camera, and adding it manually has no effect.

    Update: I inspected the code that adds the occlusion generator to the camera, and found out that it only adds it if LWRP and HDRP are disabled. Coincidentally, I had the LWRP package enabled, although I wasn't using it. Disabling it and reloading the packages in the GPUI settings solved the issue.
     
    Last edited: Jun 21, 2019