Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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:
    231
    You can add new prefab instances as well as removing existing prefab instances through our API. For an example, you can take a look at the AddRemoveInstancesDemo scene.
     
  2. domportera

    domportera

    Joined:
    Sep 12, 2013
    Posts:
    7
    I'm having a strange issue using this for VR (non-VR worked great!). When I apply this to my terrain as in the beginning of this tutorial, my performance actually drops from the typical 90-100fps to about 48fps. I've tried disabling shadows and cross-quads but that hasn't helped. Any idea why I might be getting worse performance?
     
  3. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    669
    I checked the tutorial video which you mentioned that instantiated instances will be removed of its rigidbody component.
    But my items has a base code that requires rigidbody. Is this removing function only in your instantiating script or its a universal function whenever an instance is added in the prefab manager?
    BTW, I have my own instantiating scripts to create items in the scene dynamically.
     
  4. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    If your prefab has a rigidbody component on it, the corresponding prototype in the prefab manager will show you an option to "Start With Rigidbody". We mentioned this option in that video but did not use it. This option will allow you to have your prefab instances start with their rigidbody on. This also means that they will start off not being instanced. As their rigidbodies' start sleeping (i.e. the objects are becoming stationary), GPUI will be turning on instancing on them.

    Please note that GPUI does not implement physics for the instanced objects. So the way GPUI allows for prefab instances with rigidbodies is by disabling instancing on the prototype instances that you want to use rigidbodies on at a certain area, or in the case that this option is on - also at start until the objects get to a sleeping state. Thus if your scripts require a continuous use of the rigidbody component, and if the objects will never get to a sleeping rigidbody state because of this, instancing will not turn on them. But if you modify your scripts to work on rigidbodies only when there is a rigidbody component on the gameobject (i.e. when the instance enters the modification collider), you can keep using rigidbodies for them when they are inside the area where instancing is turned off.
     
  5. LouskRad

    LouskRad

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

    You should see increase in fps while using the Detail Manager (as you do in non-VR) in VR too; especially where shadows and cross-quads are off. We will need a little more information to identify what seems to be the problem though.

    - What is the VR device? are you using single-pass or multi-pass mode?
    - How is your VR set up? Are you using a plugin for VR?
    - Do you have additional cameras in the VR version?
    - What is your lighting setup (how many lights and what kind) and rendering path (forward, deferred)?
    - How many terrains do you have, and how many prototypes are you defining?
    - Are you seeing a drop in performance without using GPUI as well?

    If you wish, you can also mail us at support@gurbu.com with the details.
     
  6. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    669
    Hi,
    We don't need items always be calculated as rigidbody. We have our own script to manage that, by ticking the isKinematic after the gameobject gets stationary.
    But this operation always requires a rigidbody component on the gameobject, and we also have some presets on their rigidbodies, like the mass, drag etc. We don't want to remove the component then add it again, just disable the physics calculation by making it kinematic.
    What I meant in the last post is that do I have to remove the rigidbody component in order to use GPUI or I only need to set the object stationary then GPUI will take care of it.
     
  7. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Well, you don't have to remove the rigidbody components on your prefabs, but GPUI removes those components when the rigidbody starts sleeping indeed. This is because we observed that the rigidbody component slows down performance even though set to kinematic. GPUI keeps track of the rigidbody properties of its prefabs and adds the exact same rigidbody component when rigidbodies are put back on. This was a faster approach then setting kinematic in our tests.

    However, we plan to integrate a new feature about this in a future update - where GPUI will instance your prefabs without actually removing your rigidbodies. But if you currently need to keep the rigidbodies on your GPUI prefab instances and set them kinematic manually, this is very easy to change. You can send us an email at support@gurbu.com and we can explain which lines of code you need to change for this.
     
  8. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    669
    If the properties are recorded and can be restored when needed, I can disable the requirement of rigidbody on my base item script and let GPUI handle it. :)
     
    LouskRad likes this.
  9. johnsmithdev

    johnsmithdev

    Joined:
    Dec 1, 2012
    Posts:
    2
    Hi,

    Firstly, a great asset. I bought it a week ago and I was trying to build on IOS and I noticed that it is not working on the IOS build. It seems the GPU instancer prefab just makes my prefabs disappear.

    The description on the asset says requirements "- Metal (iOS)" Which is what we are using but there seems to be an issue. Can you please help me out on this matter.

    Highly appreciate your time and looking forward to your response.
     
  10. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Hi there, and thanks a lot!

    We will need some more information to identify the problem. Can you mail us at support@gurbu.com with answers to the following questions so that we can solve this together?

    (1) Are you actually taking a build and seeing the problem in an iOS device or are you seeing it in the Xcode Simulator?
    (2) If you're testing on the simulator, what are your settings for the simulator, and did you enable Metal API and select GPU device as written in this link: https://docs.unity3d.com/Manual/Metal.html?
    (3) If you are testing a build directly on a mobile device, what is its model?
    (4) What Unity version are you using?
    (5) In the Unity Editor, are you certain that you have Metal API selected in your player settings for your primary Graphics API?
     
  11. johnsmithdev

    johnsmithdev

    Joined:
    Dec 1, 2012
    Posts:
    2

    Hi LouskRad,

    I have just sent an email to support@gurbu.com.

    Hopefully we can find a solution soon!

    Thanks.
     
  12. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    349
    Hi there,

    I'm trying to use GPU Instancer with a forest. Whenever my trees get culled the shadows become blotches on the ground instead of using the transparency I have on the leaves... I set the Frustum offset to the maximum of 0.5 on the object but it's still not enough for me not to be able to see the shadow transition. Is it possible to have bigger offset? Or will I lose too much performance for having the trees never get culled?
     
  13. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Hi Daniel,

    Currently GPUI uses the same "shadowsonly" shader for the buffer that is responsible for the instances that are outside the view frustum. This shader is responsible for all materials, and what you are seeing is it's not rendering your custom shader properly. You can take a look at this shader:

    GPUInstancer\Resources\Shaders\ShadowsOnly_GPUI.shader

    In the next update (which we will submit quite soon) we will introduce an option to use the original shader for a shadows only pass for the instances that fall outside the view frustum. This will not be the default behavior since this will mean that the original shader with all its potential complexity will execute and this is unnecessary for most cases.

    At this point, you can either wait for the next update to use this option, or if you don't want to wait for the update to arrive at the Asset Store, you can mail us at support@gurbu.com and we can prepare and send you a fix package for this.
     
  14. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    349
    Thanks :D Will definitely email you about it. I think having the shader doing its extra stuff is worth it to get the shadows looking good and not popping.

    I had another problem, I mess around with my meshes sometimes and my prototype loses the reference apparently. It was throwing me null errors on :
    Code (CSharp):
    1.   for (int i = 0; i < runtimeData.instanceLODs.Count; i++)
    2.                     {
    3.                         for (int j = 0; j < runtimeData.instanceLODs[i].renderers.Count; j++)
    4.                         {
    5.                             totalSubMeshCount += runtimeData.instanceLODs[i].renderers[j].mesh.subMeshCount;
    6.                         }
    7.                     }
    I couldn't delete my prototype to readd which was what I did last times I had similar problems. I ended up wrapping the whole thing into a try catch and it let me delete it. For an update might be good to do some try catches to handle the errors more gracefully.
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Can you explain a little more the case in which you get the exception? Are you modifying your meshes or prefabs at runtime?

    The code block you show should run only at the prototype initialization stage, and the null reference exception should not happen unless the mesh is destroyed before initialization at runtime. Catching the exception would not help with rendering the prototype properly.

    Also, since GPUI checks the original prefab for prototype details, your changes to the prefab should also reflect without you deleting and re-adding the prototypes.

    If you could tell us the way you manipulate the meshes, we could perhaps provide a proper solution to work better in your case.
     
  16. LouskRad

    LouskRad

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

    We have just submitted the 0.8.1 version update to the Asset Store. The update should go live once the Asset Store team finishes their reviews.

    This update includes various new features, changes and fixes. Two of the new major features include Occlusion Culling and the Map Magic Integration. We have demonstrated these features in the following video:



    For a full list of changes, you can take a look at:
    http://www.gurbu.com/changelog

    We hope you enjoy the new version.
     
  17. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    161
    Is the source code included?
     
  18. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Yes, the full source code is included.
     
  19. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,736
    Screenshot 2018-06-30 at 00.48.58.png I wish there was some way to stamp the colors of the grass into the terrain automatically, so the transition from grass object texture to terrain texture is more seamless at far distances.

    as can be seen in the video demo the transition is very much visible at large distances.
     
  20. LouskRad

    LouskRad

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

    The contrast in that video is intentional, with the purpose of making it as visible as possible in the video :) But yes, it is a better design strategy to have color synchronization with your grass meshes, so that you don't end up with concrete lines of visibility borders like those in that picture. However, since GPUI doesn't get involved with terrain textures at all, it is not in our roadmap to offer a feature to automate such a process.
     
  21. CraftingPixelLab

    CraftingPixelLab

    Joined:
    Jan 12, 2013
    Posts:
    182
    Amazing. will there be integration with world creator? I bought and I am loving this asset. Thank you for the excellent work.
     
  22. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Thanks a lot!

    We will be making integrations with various assets, but World Creator hasn't been in our radar so far. As far as I know, it is not open source so it might require cooperation on their part as well. In any case, it's currently not in our road map.
     
  23. Tasmeem

    Tasmeem

    Joined:
    Jan 14, 2010
    Posts:
    111
    Great work on the update.

    Is Instanced Skinner Mesh Renderer next on your road map? I think this is the only hope of seeing large crowds of characters in unity.
     
    Neviah likes this.
  24. markashburner

    markashburner

    Joined:
    Aug 14, 2015
    Posts:
    145
    Yes and is Speedtree integration next on your roadmap?
     
    Neviah likes this.
  25. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231

    Hey there :)

    As far as major feature updates go, SpeedTree support will come first and skinned mesh support will come later on. But we will be launching various other improvements and minor feature updates in between.
     
  26. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    v0.8.1 update is live everyone. You can download and start using the new features.
     
  27. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    349
    Code (CSharp):
    1. Shader error in 'GPUInstancer/HiZOcclusionDebugger': D3D9 does not support separate Texture+SamplerState HLSL syntax (on texture sampler_MainTex+_MainTex) (on d3d9)
    2.  
    3. Compiling Fragment program
    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_COLORSPACE_GAMMA
    5.  
    Getting a shader error when trying to build :(
     
  28. LouskRad

    LouskRad

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

    Looks like you're trying to build on DirectX 9. GPUI requires Shader Model 5.0, which is supported by DirectX 11 - so some of the syntax we use in various shaders also follow dx11 specifications.

    Can you try building with DirectX 11 and see if the error persists?
     
  29. somosky

    somosky

    Joined:
    Feb 15, 2014
    Posts:
    104
    Hi I've been keeping an eye on your asset for a few weeks now. I'm currently working on a fairly large game (scale wise) and with my previous projects optimization wasn't too much of a priority because they were so small. Now with the larger worlds I'm creating I'm very much beginning to think I've got a lot of optimization to do.

    So my questions about your asset are

    (1) Am I allowed to create my scene as I would normally and then choose the objects which will be GPU instances.

    (2) Is there a built in occlusion culling system for GPU instancer or does it use Unitys built in system?

    (3) Are there any limitations on what can be instanced? For example I'm using a large number of Synty models (their new nature pack has many great trees and grass objects)

    (4) Does this work with any other optimization tools such as SECRT Complete.

    Thanks for taking the time to read this .Sorry for the long post .
     
  30. LouskRad

    LouskRad

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

    Exactly. You can choose which prefab instances you have in your scene to instance.

    Yes, we have introduced a built in GPU occlusion culling feature that does not require any baking with the latest update. You can take a look at this video for more info:


    Currently, limitations include skinned meshes and SpeedTree objects. GPUI works with custom shaders so the models you have in mind should work. It is in our roadmap to add SpeedTree (and TreeCreator) support in a future update, but for now you can instance tree objects with custom shaders with our Prefab Manager.

    We have not tested specifically with SECTR, so can't give you a guarantee there; but even if it does not work out of the box, we have an API that you can make use of to manually integrate GPUI to your workflow in most of the scenarios.

    I highly suggest you watch the tutorial videos to make a decision:
     
  31. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    266
    This looks interesting, hopefully Metal support coming soon for macOS as well.
     
  32. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Hi there, and thanks.

    GPUI already supports Metal API on macOS (as well as iOS). We will update the Asset Store description to make this clearer.
     
    trilobyteme likes this.
  33. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    154
    Hi,

    When is the android demo coming ? :D
     
  34. LouskRad

    LouskRad

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

    We're currently working on some improvements and fixes to the android version and we will publish the android demo with the next update which will include these changes. We have scheduled this update for the next week.
     
  35. therewillbebrad

    therewillbebrad

    Joined:
    Mar 2, 2018
    Posts:
    76
    Any timeframe on skinned mesh support?
     
  36. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    170
    I did like to know this too.
     
  37. LouskRad

    LouskRad

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

    We're currently working on android improvements - update is scheduled for next week, along with an android demo build. After that the first major feature will be the Tree Manager and support for Tree Creator and SpreedTrees. There will also be various integrations and other features added in between. Skinned mesh support will come after all these, so we can't give you an exact date for that yet.
     
  38. Isaac-Udy

    Isaac-Udy

    Joined:
    Aug 4, 2013
    Posts:
    5
    I recently purchased this asset, hoping to improve my performance on terrain detail rendering. However, when I follow the video tutorial posted above, my performance drops massively. Without GPU instancer, I have a scene running at ~80fps, and when I enable GPU instancer my performance drops to <10fps. I feel like I must be doing something wrong?

    With the instancer enabled, the Unity profiler says that ~400ms is used by GFX.WaitForPresent.

    I'm using an AMD Radeon R280x and using Unity 2017.1, if that makes any difference.
     
  39. LouskRad

    LouskRad

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

    Do you face the same issue in the included detail demo scene?
    What is your platform (Windows or macOSX)?
    What graphics API are you using in the Unity Editor? (DirectX11, OpenGL or Metal?)

    Can you please send us a mail at support@gurbu.com with answers to these and the settings you're using for the Detail Manager? It could be better if you could send us a screenshot of your Detail Manager settings.
     
  40. Isaac-Udy

    Isaac-Udy

    Joined:
    Aug 4, 2013
    Posts:
    5
    Hi, thanks for the quick reply! It turns out I don't need to send you any information, because I've figured out what the problem was. I'm posting back here so hopefully anyone googling the same issue might find my solution.

    The detail demo scene ran totally fine, so I spent a bunch of time diffing between the two scenes to figure out what the difference was. By default, when I painted details (grass) with a target strength of 1, I would end up with a super thick sea of grass in the editor, and when I ran the project, I'd get even thicker grass with the GPU instancer.

    By turning down the detail target strength to something around 0.065, I could get the same "thickness" in play mode, but at the GPU instancer's faster speed.

    As far as I could tell, turning down the detail density made no difference - it was *only* the target strength that helped.
     
    LouskRad and Akshara like this.
  41. Mohamed-Anis

    Mohamed-Anis

    Joined:
    Jun 14, 2013
    Posts:
    57
    Hi,
    Re prefab instancing, will performance still be good if there are say 1000s of different prefabs out of which maybe 100s of different prefabs (instanced multiple times) are visible at any time? In particular I'm wondering if your frustum/occlusion culling solution still give good result in the above situation?

    For reference I'm looking at houses in a 3d town (fantasy setting). I need the interiors of these houses to be culled if I'm not inside a building. However if I enter a building I'd like the other houses to be automagically culled. You can assume the houses will be architecturally different and yet mostly consistent internally (e.g. one house might be of a poor person, so the prefabs of the things in the house might be of someone who isn't rich. However there can be another house which belongs to a rich person. The prefabs there might look a little bit extravagant).

    Thank you!
     
  42. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Hi,

    GPU Instancer increases performance scaling with the number of instance counts for the same prefab. For example, if you had hundreds of instances of the same prefab, you would see an increase in performance, since by GPU instancing you draw the same mesh-material combination multiple times in a single draw call. GPU Instancing would not help when you have only a few instances of the same prefabs.

    Unity has frustum and occlusion culling features already, but they work on the CPU which sometimes results in spikes in CPU usage. Also, occlusion culling requires you to set your occluders and occludees to static and bake your scenes.

    GPU Instancer makes the frustum and occlusion culling calculations on the GPU and does not require static objects or baking. Since GPU's are much more efficient in these kind of mathematical calculations, you won't get spikes. Because no baking is required, you can add/remove objects at runtime using our API. And no static required means that everything in the scene becomes an occluder.

    For example in this screenshot you can see that while I am flying around, the grass under the space ship is not being rendered.
    upload_2018-7-17_3-15-45.png

    Please note that you can also combine culling features of Unity and GPU Instancer. You do not have to set all your prefabs to use GPU Instancer, it is better to select the ones that are more suitable for it.

    In short, with GPU Instancer, you would still benefit from frustum and occlusion culling. But if you use gpu instancing with very few number of instances, the overhead created for gpu instancing might be more harmful then the performance gained by gpu culling. This all depends on your scene setup.
     
    therewillbebrad and Neviah like this.
  43. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    154
    oh man, eagerly waiting for the android demo :D
     
    LouskRad likes this.
  44. LouskRad

    LouskRad

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

    We have recently submitted the 0.8.2 version update for review, and it should be live soon. This update focuses on mobile fixes and improvements.

    We have also uploaded 3 new demo builds including a macOS, a Linux and an Android build. You can download them now at this link.

    Please notice that the Android demo build currently targets high-end mobile devices and requires minimum Android 8.0 (Oreo).
     
  45. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    394
    I have a question regarding streaming worlds of objects. How would your GPU instancer work in a runtime scenario where objects are being streamed. Can the objects be added at runtime ? Does your GPU instancer only perform well when the objects are known before hand and can be computed ?
     
  46. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    154
    artifact in android demo :(

    my device is Xiaomi Redmi S2 with open gl es 3.2 (GPU Adreno 506)
     

    Attached Files:

  47. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Hi lolclol,

    Thank you for pointing this out. We have found out that the latest Unity 2018.2 release fixed some android issues with the DrawMeshInstancedIndirect API - specifically for the Adreno GPUs.

    The fix is this one:
    Graphics: Fixed a bug with DrawMeshInstancedIndirect not working on Adreno and some Nvidia GPUs on Android. (1008623)

    We had made our build with 2018.1. We now re-made and uploaded the build with 2018.2. Can you please download the new version and try again and see if this fixes the issue?
     
    lolclol likes this.
  48. LouskRad

    LouskRad

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

    Absolutely. We have an API that you can use to register your objects after you instantiate their GameObjects. Various example scenes for this is included with the package (AddRemoveInstancesDemo, PrefabInstancingDemo), and you can also take a look at this video to see how it is done.
     
  49. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    154
    asteroids are now fixed but still there is some artifact near the globe.

    Check Screenshot

    See those black areas, they are tearing.
     

    Attached Files:

    Last edited: Jul 19, 2018
  50. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    231
    Ok, looks like the tearing issue is not related to GPU Instancer (asteroids look fine).

    Rather, the problem seems to be our lack of experience with android builds :) We are testing with a Samsung Galaxy S7, a Galaxy S8, a Galaxy S9+ and a Google Pixel 2 which all show correct results.

    We have uploaded yet another version of this android build. This version reduces texture sizes and reduces the tri-counts of the planet and sun meshes. The only potential cause left that we can think of for your case is removing v-sync as well, but let's give this a shot first because that would limit your fps to 30.

    Please tell us if this build fixes the problem for your device.
     
    Last edited: Jul 19, 2018