Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] GPU Instancer

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

  1. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    641
    I see lightmaps ate not supported. But unity will gpu batch as long as the gpu instanced lrefabs share the same lightmap file. Couldnt that be the case here? With Bakery Ive control over what objets are mapled into same lightmap and the I do have the prefabs I whant to gpu instantiate in resources folder and they instantiate and get originals prefab lightmaping. Gpu instancing breaks for some but at least it somewhat works unlike without the script. I wonder if your asset would do a better job.
     
  2. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    The important bit is how many instances of the same prefabs you have in your scenes (rather then how many GOs in total you have). So you should define the repeating objects as prototypes to the Prefab Manager for effectively using GPUI. Whether they are static or not does not matter for GPUI.

    For additive scenes, and instances that are added in runtime in general, you can select the option "Enable Runtime Modifications" for these prototypes in the Prefab manager and also "Auto. Add/Remove Instances":

    upload_2018-11-25_21-43-49.png

    This will tell GPUI that you want to instantiate new instances at runtime (whether upon additive scene load or by script) and the system will track those instances and update itself. Alternatively, you can use the GPUInstancerAPI to do runtime addition/registration operations.

    GPUI's frustum and occlusion culling solutions work for all the instances of its prototypes even if they are generated at runtime - since they don't require baking. This is also why static meshes are not relevant to GPUI.

    As for GI, currently all realtime lighting is supported while baked lighting is not.
     
  3. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    The performance gain from GPU Instancing scales by the power of the GPU that it works on.

    The detail manager targets the average point by defaulting on texture details with 2 cross-quads and shadows. The default detail distance is taken directly from the terrain's detail distance. This average point increases performance on most target platforms - but by lowering and increasing settings, you can optimize between performance gain and increased visual quality in your targeted platform.

    You can click the "?" icon at the top of the managers to learn more about the manager settings.

    When you change the detail size settings on the manager, you need to click the "Apply Changes to Terrain" button to update the terrain. Otherwise the terrain will not reflect the changes but at runtime GPUI will use the changed settings. For more information on the detail manager, you can take a look at the detail tutorial video:

     
  4. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    GPU Instancing works by batching the same mesh/material combinations, so different meshes (or materials) will not work as prefab variations.

    Are you sure you need 500 different prototypes?

    GPU instancing works by sending mesh/material data to the GPU in a single draw call. This reduces the amount of batching to one even if there are hundreds or even thousands of the same mesh/material combination. This removes the bottleneck that occurs when sending mesh and material data from CPU to the GPU, and results in higher fps if there are many of the same mesh-material combinations. That is, GPU instancing helps in scenarios where you have many instances of the same game object.

    So in short, the idea here is to use as little prototypes as possible while having as many of their instances as possible to get the best out of GPUI. The system supports large amounts of prototypes but you should use them only if they all have large numbers of instances each.
     
    ftejada likes this.
  5. LouskRad

    LouskRad

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

    GPUI currently does not support lightmaps.
     
    TokyoWarfareProject likes this.
  6. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    83
    Hello there,
    I added one prefab with 1000 instances they are not changing mesh or moving but still GPUInstancePrefabManager.Update takes 6-8 ms in Update call. After disabling runtime modification call it goes away but I need to enabled the option as I sometimes I want to move any instances it will still take 6-8 ms Is there any way to reduce the performance hit ?
     
    Last edited: Nov 26, 2018
  7. Wintermute-

    Wintermute-

    Joined:
    Sep 5, 2017
    Posts:
    39
    Hello,
    I am using GPU Instancer and it is extremely helpful, I just have one question.I looked at the videos and documentation, but I might have missed something.

    I noticed that when I am in playmode, the original prefabs not the ones created by the GPU Instancer are still in the scene. Is there anyway to turn the gameobjects off on play with your Instancer? The game I am developing is for VR and unless I turn off the prefabs that I added to the prefab manger during runtime it does not show a good framerate. I did see the video that generates the instances while deleting the gameobjects, but I would like to know if instead of deleting them, they can turn off during play.
     
  8. AstralAngel

    AstralAngel

    Joined:
    Aug 6, 2014
    Posts:
    6
    Hello! Just bought it yesterday. First of all thank you. I have a couple questions about it.

    1) I can`t make a feature "Enable runtime modification" turned on.

    I`ve got instantiating objects, and they are a part of GPU Instancer prefab manager

    upload_2018-11-27_0-0-15.png

    There is no any effect for instantiated object.

    For object on start it works fine:
    upload_2018-11-27_0-0-56.png

    What can be the problem?



    2) GPU instancer decrease tris count but encrease Set Pass Calls

    In that case my FPS is falling from 400 to 60-70 how can I get it fixed?
    upload_2018-11-27_0-4-1.png
     
  9. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    101
    Using the PrefabsWithoutGameObjects script to render we are seeing poor performance on low end devices (integrated graphic machines) even when nothing is being drawn to the screen. Disabling the GPU Instancer prefab brings frame rate up from 20 to 30+ which is our target frame rate for this device.

    Currently we have 8 different objects of 500 instances per that are rendered with GPU Instancer. When profiling we see 16 draw calls from these objects even when they are not visible. Looking at the code, it looks to be because the matrix for each object's instances are just set to zero, meaning calculations still need to be done even if not rendered. I've attached the settings we currently are using.

    Do you have any recommendations on how to improve performance?

    gpuinstancersettings.png
     
  10. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Even if you have 1k instances, GPUI's update should not take 6-8ms. Are you using rigidbodies on these instances? it could be that the physics update is taking that long.

    Depending on your use case, to improve, you can use the GPUInstancerModificationCollider where you can enable/disable instancing (allowing for rigidbodies to resume) in a given trigger collider.
     
  11. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi there,
    Thank you for supporting GPUI.

    Currently there is no GUI tool for this, but you can use the GPUInstancerAPI to manage your instances for a no-game object workflow. For an example, you can take a look at this:

    https://www.gurbu.com/gpuinstancer/tutorials/nogameobject
     
    Wintermute- likes this.
  12. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91
    Hi there,
    I have a pre-sale question. Is it possible to use GPU instancer with multiple cameras? If yes, could you please let me know how to achieve that?
     
  13. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi there,
    And thank you.

    You will get the most out of GPUI with fewer prototypes, and more instances of them. For more information on this, you can take a look at: https://www.gurbu.com/gpuinstancer/tutorials/gpuinstancing

    From your screenshots, it looks like there are many prototypes of the same prefab (e.g. ST_Env_BackgroundEdge_03). If they are instances of the same prefab, there should not be more then one prototype for them.

    About "Enable runtime modification", it looks like it is on in your screenshot, what seems to be the problem? Are you seeing correct amount of registered instance counts in the manager?
     
  14. AstralAngel

    AstralAngel

    Joined:
    Aug 6, 2014
    Posts:
    6
    I was taken 2 screens. First is instantiated object without any GPUI perfomance, second is prefab wich was on scene before start.

    And it seems like auto bool field "realtime" is not working...
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi John,

    As you have noticed, zeroing-out the matrices does not get rid of draw calls, but effectively culls those instances. You could zero the buffer size for disabling the draw calls. Setting back the buffer size would resume the draw calls.

    As for lower end, integrated graphics devices - it is quite expected to see low performance on them since instancing would scale with the power of the GPU. Especially on devices where the GPU and CPU memory is shared, you would not get the desired performance increases from instancing since there is no dedicated GPU unit.
     
  16. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi there, and thank you for your interest.

    GPUI currently does all culling operations on a single camera, but it is possible to use multiple cameras if you do not use frustum and occlusion culling. We are, however, working on multiple camera support and it will be available in a future update.
     
  17. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Can you please send us the screenshot of the registered instances at runtime in both cases:

    unnamed.png

    I'm trying to understand you, can you explain it a bit clearer, what is the bool field "realtime"? Are you trying to add instances at runtime?
     
  18. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,105
    This is regarding Microsplat's terrain blending -- has anyone gotten this to work? @Alic ?
     
  19. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91
    hi,
    thank you for your fast reply. Basically I am not using 2 cameras at once (player switches between different fullscreen cameras at runtime) - therefore i would need the ability to use GPU Instancer if possible with occlusion culling as this would increase the performance a lot and that´s actually why I am interested in your asset.. would this be possible? If no, when do you plan to update the asset regarding that?
     
  20. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Oh, it's certainly possible and very easy to switch cameras at runtime. All you need to do is to call the GPUInstancerAPI.SetCamera(camera) method. This works with all culling functionality.
     
  21. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91
    awesome - just bought it :) I will let you know if I have any questions..
     
  22. MattiHietanen

    MattiHietanen

    Joined:
    Nov 24, 2018
    Posts:
    15
    1) Does you scripts use other threads?

    In the past GPUI has used for the shadow casters the result of HiZ culling and all objects withing the real time shadow range. This is not correct and not fast. If this is not fixed or changed, you get these results under several condtions.
     
  23. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Well this actually makes sense. We will add the option to cull shadows the same way as the prototypes in the next update. Culling shadows will result in more performance but less consistency - but it will be better for camera angles such as top down.
     
    Last edited: Nov 27, 2018
    MattiHietanen likes this.
  24. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    83
    I am not using rigid bodies on instances absolutely nothing they are not even moving profiler shows that Component.GetTransform takes 1/3rd total ms count.
    Edit : Img Link[https://imgur.com/a/Zf66xwP]

    Hello as you can see in the image for around 3000 instances Update method takes 6ms with Component.GetTransform takes 2ms and Object.op_Implicit another 2ms. I only enabled Auto transform component
     
    Last edited: Nov 27, 2018
  25. MTandi

    MTandi

    Joined:
    Aug 4, 2017
    Posts:
    8
    Hello! I'm getting following error in 2018.3.0b11 when attempting to build the project:

    'GPUInstancerUtility' does not contain a definition for 'RemoveComponentFromPrefab'




    Is this a known issue? And is there a workaround?
    I can see the conditional statement next to this line mentioning 2018.3, so I'm assuming it should work.
    Maybe 2018.3 not fully supported yet?
     
  26. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    112
    Hi, I just bought it and tested the examples. They're working perfectly, duplicating the framerate in most cases.
    Then I tried in a Gaia scene, with no other asset added, followed the quickstart guide and got a drop in the framerate from 110 to 37. If I make the detail distance something like 50 I get 70fps.
    What am I missing?
    Thanks.
    BTW I'm very happy with how the grass looks like. It seems to be more dense, detailed and integrated onto the ground than when I use the default shader.
    upload_2018-11-27_11-15-46.png
    upload_2018-11-27_11-16-32.png
     
  27. TheDream

    TheDream

    Joined:
    Nov 25, 2013
    Posts:
    24
    Hi, GPU Instancer is awesome! :)

    It simply fixes every issue we have with Unity's standard grass and trees and finally allows us to control how batching is managed on the dynamic objects of our games.

    I would like to use it on the Lightweight Rendering pipeline, but when I do so with the detail instancer, the grass is blinking in a strange way, (like if depth would be calculated differently at each frame).

    Is there a way to fix that?
     
  28. makerspender

    makerspender

    Joined:
    Aug 20, 2017
    Posts:
    9
    Hello, loving the performance boost this plugin provides MapMagic with out of the box, however when I use nodes that utilize the biomes, objects, trees and grass are not picked up by the integration. Do you have any idea if its possible to get GPUI to work with this biome feature of MapMagic?
     
    protopop likes this.
  29. LouskRad

    LouskRad

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

    We have made an improvement about this which we will add in the next update. The updated version will cache the transforms, thus better handling the transform change queries in the Update loop. If you can mail us at support@gurbu.com with your invoice, I can send you the pre-release version of this update.
     
  30. LouskRad

    LouskRad

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

    This is a known issue and we have fixed this for the upcoming update. You can simply change the following line in the GPUInstancerPrefabManager.cs:

    Line 324:
    #if UNITY_2018_3_OR_NEWER

    into:
    #if UNITY_2018_3_OR_NEWER && UNITY_EDITOR

    and this should fix the problem.
     
    MTandi likes this.
  31. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi there.

    The drop in FPS is certainly not normal, given your screenshots. With both the Tree Manager and the Detail Manager added to a similar scene like yours, the results we are getting are as follows:

    GPUI-GaiaSimpleON.JPG

    GPUI-GaiaSimpleOFF.JPG

    The performance/quality options are mainly detail distance, shadowing and cross-quads (and their billboarding distance) for terrain details. You can find an example usage of their settings in the DetailInstancingDemo scene, but even with the highest quality settings you should not be getting an FPS drop like this.

    Here are a few questions:
    - What GPU are you seeing this results in (your graphics card)?
    - What extra effects are you using in the scene (any post-processing or similar screen-space effects)?
    - What is your Unity version and OS?
    - Are you getting any errors in the console?

    Also, as far as I can understand from your screenshots, you are using a water plane in your scene. We have made some improvements to the way GPUI handles rendering when there are multiple cameras in the scene (e.g for post processing, or water reflections, or sky etc.) that could help fix your issue. These improvements will be live with the next update, but if you can send your invoice to support@gurbu.com, I can send you the pre-release update beforehand.
     
    Quique-Martinez likes this.
  32. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi there and thanks!

    We haven't seen any errors with LWRP as such, but if you can send the details of the shader you are using to us at support@gurbu.com we might be able to help you identify the problem.
     
  33. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi there.
    Thanks, and glad to hear you like it.

    Yes, biomes would not work out of the box currently. We will investigate this and let you know.
     
  34. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91
    hi there,
    I purchased your asset and tried your asteroid demo as mentioned here: https://www.gurbu.com/performance I removed the rigidbody components, particle effects, set shadows casting to off .. and I have only about 67 FPS with my NVIDIA GeForce GTX 1080 8GB (plz check the attached image https://ibb.co/260H2z0 ) - according to your benchmark the FPS should be a lot higher.. am I missing something? It would be great if you could help me here

     
  35. LouskRad

    LouskRad

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

    Did you change anything in the manager settings for that demo scene? e.g. enabling Auto-Update Transform Data?

    If you enabled this option, it wouldn't be the same with just rendering with GPUI. The transform updates would be taxing on the CPU and since there are 10k asteroids, you would be CPU bound in contrast.

    We have made some improvements on this feature which will be available in the next update (soon to be live) and it will give you less CPU cost, however it can never be the same when using transform updates (unless some threading technology such as ECS is used).
     
  36. ChinChiaYeh

    ChinChiaYeh

    Joined:
    Sep 14, 2016
    Posts:
    23
  37. mgwade528

    mgwade528

    Joined:
    Apr 24, 2017
    Posts:
    8
    hi there,
    i want to use tessellation shader,but using GPUI to convert shader has error.
    "'vertexDataFunc': output parameter 'v' not completely initialized at line 45 (on d3d11)"
    what can i do?is GPUI currently not supporting tessellation?
    hope to get your help,thx~
     
  38. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    112

    I7 3.6 Ghz with 16 GB GTX1050Ti. Unity 2018.2.0f2
    I get this warning
    No script asset for GameObjectSelectionItem. Check that the definition is in a file of the same name.
    The test scene duplicates the framerate.
    I started a bare project only with my Gaia terrain (no effects etc) and the GPU instancer. I tested in FullScreen
    Compared to your screenshots, I guess that the CPU main value is not behaving as expected. Also I have more shadow casters where you have less than half when using GPU instancer.
    I hope it can help.

    Before pressing play:
    upload_2018-11-28_10-21-44.png

    GPU instancer off
    upload_2018-11-28_10-22-21.png

    GPU Instancer On
    upload_2018-11-28_10-22-59.png
     

    Attached Files:

  39. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    83
    Hello,
    GPUInstancerAPI.DisableIntancingForInstance method is not working if parent position is changed.
    In my game there is one Parent gameobject with two childs where first child is being instanced by gpui and another object contains script which set its parent position to its position. Now even If I call DisableInstance method instance is not getting disabled, Only way to to disable instancing is by removing script from second child which access and set parents transform.
     
  40. TheDream

    TheDream

    Joined:
    Nov 25, 2013
    Posts:
    24

    Hi, thank you for your answer! :)

    I tried importing GPU Instancer with the default LW VR template.

    The terrain detail example wasn't working out of the box. (but it was with the 3D template)
    only the rocks were displaying, no vegetation.

    I changed the grass prototype material to Lightweight unlit and when it was set to transparent, the grass was displaying but blinking in a strange way. It wasn't blinking with opaque (cutout) mode but it was ugly (weird shape and strong aliasing).

    Do you have an example of a correct setup for terrain detail GPU Instancer on LW VR template?
     
  41. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    ChinChiaYeh likes this.
  42. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    57
    My terrain is a mesh so I cant use the detail manager to spawn grass. Is there a way to place the grass prefab on the mesh everywhere without placing hundreds of thousands of grass objects in the scene? I saw you mention a no game object workflow which sounds like a step in the right direction but Im not sure what to do. Am i supposed to attach the script found here https://www.gurbu.com/gpuinstancer/tutorials/nogameobject to the prefab of the object? Am I misunderstanding what no game object workflow means?
     
  43. LouskRad

    LouskRad

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

    Unity does not support GPU instancing and Tessellation at the same time. That is, your tessellation shader would not work correctly if you enable GPU instancing on your material as well.
     
  44. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91

    Hi,

    no, not at all - here is a screenshot of my settings: https://ibb.co/Hxnj3ZT - could it be caused by something else?
     
  45. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi there, can you mail us at support@gurbu.com with
    (a) a screenshot of your scene hierarchy,
    (b) a screenshot of your manager settings.
     
  46. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    If you can send this to us as a sample project, we can investigate it. (support@gurbu.com)
     
  47. LouskRad

    LouskRad

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

    Materials with transparency can result in that behavior. Since GPU instancing works by treating all instances as the same, the GPU draws one mesh multiple times. This will result in wrong draw orders while using transparency unless you manually implement a form of OIT approximation.

    The foliage shader currently does not have a LWRP version.
     
  48. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    You can either generate the positions of your grass prefabs from code, or use a tool to such as Polybrush to paint the prefabs on your mesh terrain.

    The no-game object workflow is currently an advanced feature - you need to generate the instance matrix data yourself and feed it to the GPUI API if you wish to go that way.
     
  49. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    91
    hi there,
    I just tested it by disabling GPUI and I have only about 20FPS (with an i7 4790K) at 10.000 asteroids..do you have any idea how to fix that?
     
  50. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    835
    Hi,

    your screenshot shows modified settings for the asteroid haze - but probably there are changes in the asteroid settings that effect performance as well. You can simply re-download the scene to your project from the asset store to see the original version.
     
unityunity