Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

[RELEASED] GPU Instancer

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

  1. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    72
    When I change for the first time the active camera with SetCamera (first person to third person), it freezes for a moment before actually changing. After the first change, though, it transitions instantly. Is a warmup somewhere needed for cameras?
     
  2. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    35
    Hey there. I picked up GPU instancer and have two issues I can't figure out.

    1. I have a open world game and I'm translating the scene back to 0.0.0 of the world to correct float point errors. If I use GPU instancer to create a bunch of objects, do those objects move with the rest of the scene? From the looks of the asteroid demo scene, seems they stay in worldspace.

    2. I'm trying to utilize the terrain SetGlobalpositionOffset, though not having much luck. Part of the problem is that I'm simply an Artist and don't know how to code, haha. I use Playmaker for all my scripting. Here's an attached screenshot of Playmaker and some of the GPU parameters it can access. In the listing, the Offset is available, though nothing happens to my GPU grass when a value is applied. If you suspect playmaker can't set the offset, do you have an example of your own method to set this offset? (mind you I have multiple terrains, and I offset one at a time)
     

    Attached Files:

    Last edited: Feb 2, 2019
  3. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    60
    I am. Planing to get GPU Instance I have few questions
    Can we Integrate it with my existing scene as in the tutorial it based on make new scene?

    Does it supports andoids and IOS

    And

    Does it support assets like sectr and world streamer
     
  4. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    131
    Hi there,
    Can you check what is causing the freeze in the profiler?
    Are you using the SetCamera(GPUInstancerManager manager, Camera camera) method or SetCamera(Camera camera)?
    Also if you are making API calls inside a Job thread, it might cause problems. The API methods are designed to run in the main thread.
     
  5. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    131
    Hi there,
    I attached a simple script that you can add to your terrain or any other object that the instances will be under.
    Then assign the GPUI Managers that needs to be affected by the position modifications.

    upload_2019-2-2_23-53-47.png

    We will also add this script to the next update.
     

    Attached Files:

  6. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    131
    Hi there,
    GPUI is designed to work out of the box with the existing Unity terrains. For prefabs, the GameObjects in your scene should be prefab instances without overrides.

    You can have a look at the Minimum Requirements for Android and iOS support.

    GPUI does not have out of the box integration with SECTR or World Streamer. It would require additional coding to implement an integration with a streaming system.
     
  7. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    35
    Thanks for the support! This works well!
    Though I found one issue. If you translate the terrain while the entity is disabled, the grass is misaligned when re-enabled. I've included a gif.
    offset.gif
     
  8. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    131
    Hmm I missed that. I changed the script to fix the misalignment when reactivated.
     

    Attached Files:

  9. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    60
    What will happen If the scene if built with GUPI and it ran on android 7
     
  10. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    35
    Great! This solved most of transform issues. Sometimes the grass and terrain are still not aligned, it seems to only happen when I translate my entire scene. When this occurs, the grass blinks out for a frame when the transform is applied (i have everything in my scene under one parent gameobject, I simply move this parent object). I have a good framefrate, so not sure what this might be.

    I came by an issue with GPUI detail meshs + screen space ambient occlusion. I see these streaks. Turning off the GPUI manager or reducing the detail distance make the streak go away. The meshs I use are a small cluster of rocks using the gpui foliage shader with 2 levels of LOD. Grass has no issues, just the detail meshs cause it. Any suggestions?

    ao_gpui.gif
    I'm using 'Amplify Occlusion'
    https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/amplify-occlusion-56739
     
    Last edited: Feb 3, 2019
  11. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    314
    Good day. This error began to appear. The camera is determined and the prefabs are registered. in 0.9.3 there was no such error. How to fix it?
     

    Attached Files:

    • gpu.jpg
      gpu.jpg
      File size:
      21 KB
      Views:
      56
  12. LouskRad

    LouskRad

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

    The main requirement for Android devices when building for GLES3 is that they support OpenGL ES 3.1 and have relatively high end specs. We set the minimum operating system to Android 8 so that it covers the newer devices - since older devices might have some GPU limitations (e.g. limited buffer counts, lower group threads, etc.) that can cause some problems.

    Androids that support Vulkan usually overcome this limitation; but the lower end devices usually don't support Vulkan anyway.
     
  13. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    354
    Hi there,
    The blinking issue can be related to translating your terrain by extreme distances (e.g. moving the terrain by 100s of units). When the terrain is moved by such high distances, GPUI refreshes the GPU memory that is responsible for the instances.

    As for Amplify Occlusion, we have made some tests with it and the problem you see can be solved by either using deferred rendering or by setting the Per Pixel Normals property to "none" in the AO component.
     
  14. LouskRad

    LouskRad

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

    It looks like a pre-registered instance is null during GPUI's update routine. This can be caused by either a registered instance that is removed from the scene (click the Register Instances in Scene button to solve), or if you are using the API, the runtime added instance can be null (or the instance is prematurely destroyed by some other code).
     
  15. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    185
    Hey,grass is working well with floating point, but adding new trees with a world moving script doesn´t recognize them and don´t appear(or they are moved to other places).If i uncheck the moving script, all works well.I have deleted prototype data and the managers and create again, but doesn´t work.Uninstalling completly GPUI and installing again seems to work, but it is a bit disturbing everytime a new tree is added to do this.
     
  16. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    149
    Hi, I'd like to ask about no gameobject workflow
    1. Does Matrix4x4[] only handle one prefab?
    2. If the prefab is nested prefab, do I have to instantiate child prefab too? If it's not then does child prefab need to have GPUInstancerPrefab component?
    3. Will the attached component (script, collider, particle) in prefab still work (some scripts may access its gameobject or transform etc.)?
     
    Last edited: Feb 4, 2019
  17. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    60
    I am little confused when I use the
    GPUI Prefab Manager my Tri Count goes down however FPS don't increase
    490K Tris = 71 FPS (prefabs in GPUI Prefab Manager )
    1mil Tris = 180 FPS no GPUI
     
  18. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    131
    Hi there,
    Can you please elaborate what you exactly mean by adding new trees with a world moving script?
    Are you using Prefab Manager or Tree Manager?
    Are you adding new instances to existing prototypes or new tree prototypes?

    Please have in mind that SetGlobalPositionOffset method updates position data in GPU memory. When you update the positions with terrain while using Detail Manager or Tree Manager, it is quite simple because there are no GameObjects. But if you are using the Prefab Manager, you need to consider the GameObjects, since this method does not change their transforms. If they are not child to the terrain, it might cause in conflicting results. If this is the case, you either need to add your instances as a child to the terrain or move their positions also when you make a call to this method.

    Hi there,
    1- You can use the no-gameobject workflow with multiple prefabs, but each would require their own Matrix4x4 arrays.
    2- If you do not define the child as a prototype in Prefab Manager then you do not need to make new Matrix4x4 arrays for the children. But if you need to move/rotate/scale the children independently (meaning they will need their own transform changes), they will need their own prototypes and Matrix4x4 arrays. Also if you have repeating children (e.g. legs of a table), it is recommended to define them as new prototypes for better performance.
    3- When you use a no-gameobject workflow, there is no gameobject in the scene, so there will be no components or anything to attach to. They will only be rendered with their given transform data. You would need to instantiate these GOs and make the required modifications yourself. But if you are using other components or need access to most gameobjects, there is not really much gain in using a no-gameobject workflow.

    Hi there,
    Stats window does not show the tri counts for the GPUI prototypes, since it is using its own rendering system.
    You should have high instance counts for Prefab Manager prototypes for GPU Instancing to help improve performance.
    You can have a look at the Best Practices for information on the intended usage of GPUI. Also, you can have a look at the Terminology documentation for a better understanding of the technology GPUI uses.
     
  19. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    149
    What's about shader? I have a dithering shader which will fade the gameobject when it's near the camera. The shader checks distance between its position and camera position. I think that this should work right? Because the shader is a part of renderer and it has its position in Matrix4x4[].
     
  20. LouskRad

    LouskRad

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

    with the no-gameobject workflow, your shaders would work as they would normally (without the no-game object workflow). However, please have in mind that transparency (and fade) shaders may not work as expected with GPU instancing out of the box: the draw order would not be taken into account where there are instances that behind other instances.
     
  21. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    185
    I use the tree manager.Only works with one prototype(the first one) when the world moving script(moves the world to avoid floating point) is activated, if the script is deactivated, all the prototypes work well.I have done a video.

     
  22. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    131
    Thanks for sending the video. It looks like the terrain is moved before the GPUI Tree initialization is finished. Probably only the first prototype was finished initializing when you made the movement.

    To solve this, you can either wait for initialization to finish before the movement, using StartListeningGPUIEvent/StopListeningGPUIEvent API methods.

    Or you can change the GPUInstancerTreeManager.cs line 297 from this:
    Code (CSharp):
    1. GPUInstancerConstants.TreeKernelProperties.TERRAIN_POSITION, terrainPosition);
    to this:
    Code (CSharp):
    1. GPUInstancerConstants.TreeKernelProperties.TERRAIN_POSITION, terrain.GetPosition());
     
  23. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    185
    changing line 297 works! thanks
     
  24. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    98
    Can you please make it so we can REPLACE TREES! in the tree manager. At the moment there is no way to replace the trees without messing things up.
     
  25. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    98
    Placing Detail Objects Such As a Boulder with a standard shader, Their scales are messed up all look the same size. Detail Scale does not match at all when you do simulate at scene start.
     
  26. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    60
    How to increase the instance count?
    And you should make a video based on the information on the guide for best practices
     
  27. LIVENDA_LABS

    LIVENDA_LABS

    Joined:
    Sep 23, 2013
    Posts:
    101
    It seems there is a significant issue we cannot figure. Our tests indicate much lower performance when GPUI is active on prefab instancing. This is strange because the Asteroid Demo clearly demonstrates the Advantage of GPUI and it is working well with the Asteroid Meshes.

    Is there a mesh poly/vert limit per-mesh for GPUI to work? the Asteroid meshes do not exceed ~900tris ...

    We tested with a scene where we instantiate 300 huts, 5 prototypes (each hut has approximately 5000tris with 2 LOD's )

    With GPUI ~ 230fps without GPUI ~700fps , what is going on!
     
  28. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    131
    Hi there,
    We will look into it. Thanks for the feedback.
    Unity terrain does not provide scale data for the details. GPUI uses the Healthy/Dry Noise Texture, Noise Spread and Detail Scale values to determine the scales of the detail objects. You can edit these values if you wish to change the scaling.
    If you wish your objects to have exactly the same scale with the unity terrain, adding these objects as a tree instead of detail would solve this issue.

    Hi @lorddanger
    We will add more tutorial videos in the future, however Prefab Instances are basic Unity knowledge. We will perhaps add some links to related Unity documentation and videos later on.

    Here is a simple tutorial/example:

    When you drag and drop a GameObject from the Hierarchy window to Project window, you create a Prefab.
    PrefabInstance-Part2.gif

    Now the GameObject in your scene becomes a Prefab Instance.

    PrefabInstance-Part3.png

    When you add more of this Prefab in your scene, you will have higher Instance Counts.

    PrefabInstance-Part4.png

    You will benefit more from GPU Instancing when your instance counts gets to higher numbers, as in the Asteroid Demo, where there are thousands of instances of Asteroid prefabs.

    Hi @LIVENDA_LABS ,
    GPUI improves performance by reducing the amount of data that is sent to GPU every frame and also by applying various optimization techniques in the GPU like occlusion and frustum culling.
    In your case you have 5 huts with 300 instances each with approx. 5000 tris and also 2 LODs. If we assume for example that for each draw call the amounts will be divided equally, you will have 300/5/2=30 instance per draw call. This is a relatively low number to use with indirect GPU Instancing. Since the meshes tri counts are high, every frame a huge amount of mesh data will be sent to GPU for only instancing 30 of them. When your instances are also one big mesh, you will not benefit from culling as much as you would from smaller objects, because even if a small corner of the hut is visible, the hall hut will be rendered. And when you have these big meshes in your scene without anything else, your system is already GPU bound, so putting more operations on the GPU without significant gain reduces the frame rate instead.

    As for a solution, if the objects are suitable, it would be better to divide the mesh into repeating instances. For example having every wall piece as a separate object of smaller tris and repeat these objects to create the hut. That way you will be sending less mesh data to GPU and have higher gains from culling (for example a wall behind another will not be rendered while using occlusion culling).

    But if you have already 700fps there will not be much room to grow, and there is no need for improvement at all. Even the smallest script you add to the scene will slow the system down (like custom draw calls or compute shader dispatches GPUI makes). So it does not really make sense to try to improve such a scene with complex operations. GPUI is designed to improve performance when you have lower FPS while rendering high number of objects.

    You can have a look at the Best Practices for information on the intended usage of GPUI. Also, you can have a look at the Terminology documentation for a better understanding of the technology GPUI uses.
     
    LIVENDA_LABS likes this.
  29. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    268
    Hi! I have thousands of foliage objects exported from now deprecated Critas Prefab Painter and want to import them into GPU Instancer, but all of them are automatically made prefabs and GPUI won't allow the import. I have a whole scene carefully populated by hand with grass and flowers and stuff and the work would be lost if there is no way to get over this issue. How can solve this?
     
  30. SprAmir

    SprAmir

    Joined:
    May 16, 2018
    Posts:
    9
    Hi there!

    We use GPUI TreeManager for our speed trees. Unfortunately, GPU Instancer does not display new billboards from SpeedTree v8 in the build. In the editor billboards looks great.

    How can I fix this?
     
    Last edited: Feb 7, 2019
  31. LouskRad

    LouskRad

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

    GPUI managers allow you to add either Prefabs (in project window) or Prefab Instances (in your scene hierarchy) as prototypes by dragging and dropping them to the manager. If this asset has created GameObjects instead of prefab instances, you can use the included Scene Prefab Replacer tool to replace them as the instances of a prefab. If they are already prefab instances, you can simply use the Scene Prefab Importer tool to create a new Prefab Manager with them.
     
  32. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    26
    Hi, when I am changing from free fly camera to helicopter cockpit camera:
    Code (CSharp):
    1. ...
    2. GameObject.Find("GPUI Prefab Manager").GetComponent<GPUInstancer.GPUInstancerPrefabManager>().SetCamera(Camera.main);
    ...I am getting error in editor console:
    Code (CSharp):
    1. Destroying components immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate. You must use Destroy instead. UnityEngine.Object:DestroyImmediate(Object) GPUInstancer.GPUInstancerManager:SetCamera(Camera) (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:516)
    So I changed method on line 516 from "DestroyImmediate" to just "Destroy" and error is not appearing anymore, but I think this is not right solution or? .
    If it helps...Free fly camera has sphere colider attached with "Is trigger" checked. Helicopter has box collider also with Is trigger checked. Cockpit camera does not have collider component. Error appears only when I am switching from fly to cockpit camera. Switching from cockpit to fly is without error.

    Unity 2018.3.4f1, GPUI 0.9.9

    EDIT: error is pointing to line 582, 516 was in older GPUI version.
     
  33. LouskRad

    LouskRad

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

    SpeedTree v8 is currently not supported out of the box by GPUI. We haven't tested this thoroughly, but the new SpeedTree 8 shader should be automatically converted just like any other built-in shader when you import the shader in your project. You can download this shader from the Unity Archives. Please have in mind that the shader you need to import into your project is the SpeedTree8.shader (under DefaultResourcesExtra\Nature folder in the built-in archives) and not the SpeedTree8Common.cginc.

    GPUI should recognize this as a SpeedTree instance as well, and create the proxies for you at runtime.

    However, please also note that the GPUI billboard generator currently does not generate SpeedTree 8 top-down billboards.
     
    SprAmir likes this.
  34. SprAmir

    SprAmir

    Joined:
    May 16, 2018
    Posts:
    9
    GPU Instancer works great with SpeedTree v8. Everything works in editor mode. In the build does not work builtin new SpeedTree billboards (which use the same SpeedTree shader).

    I understand that there is no top-down billboard generator yet :)

    Thanks for reply!
     
  35. LouskRad

    LouskRad

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

    When using the occlusion culling feature, the camera uses a CommandBuffer that takes care of depth texture calculation and compute shader operations. The reason for DestroyImmediate is that when changing cameras, if the hi-z generator is not immediately destroyed, both cameras will have such a CommandBuffer for a very short time. There is a small chance that this can cause a stutter, but if you are not seeing such an effect, you can safely use Destroy instead of DestroyImmediately.
     
    Bzuco likes this.
  36. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    354
    It's great to hear it works :)

    However, I'm not sure I understand the problem with the billboards. Does instancing work on SpeedTrees but not billboards in the build? Or do the billboards not show at all?

    Can you please send us a screenshot of this, and any relevant information to support@gurbu.com so we can investigate this?
     
  37. SprAmir

    SprAmir

    Joined:
    May 16, 2018
    Posts:
    9
    Yes, built in billboards is simply not visible in the build (but works great in editor mode). Instancing works great, no problems in the editor mode or in the build is not observed.

    Ok! I'll send you an email right now describing the problem.
     
  38. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    60
    upload_2019-2-12_4-41-21.png

    I have some Failed to compile Shader for GPUI
     
  39. kidne

    kidne

    Joined:
    Nov 29, 2013
    Posts:
    22
    Hi, Just bought this and I'm really excited to work with it, however I set it up for a Scene that has a ton of prefabs, and it detected all of them just fine, but when I spawn in and it detects my camera, it seems like it also instantiates a bunch of unselectable (and non visible in hierarchy) clones of all of my prefabs right ontop of the camera.

    https://gyazo.com/2a7ed70f10c32509732cf4d9447dfa2c
    Notice how they follow the camera around. I can make out sometimes trees, water, etc. So I know theyre the prefabs I set in the GPUI Prefab Manager

    Turning the GPUI off in the hierarchy makes all the pink prefabs go away, but then culling doesn't occur.
     
  40. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    72
    How can shadow popping be avoided? I have shadows suddenly appearing inside the shadow distance. Does the frustum buffer size help with this?
     
  41. LouskRad

    LouskRad

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

    We can help you Identify the problem if you can tell use what error the shader showing. If you see any errors/warnings in the console (or in the inspector window when you click the generated shader) please show them.
     
  42. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    354
    Hi there,
    and thank you for supporting GPUI.

    It looks like either a shader issue or a projector in your scene may be causing this.

    If it is a shader issue, this wiki document can help you solve it:

    if you have projectors in your scene, this wiki document can help you solve the issue.

    If these don't solve the issue, you can mail us at support@gurbu.com with the details of your shader and we can help you identify the problem.
     
  43. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    354
    Hi there,
    GPUI uses a seperate buffer for shadows to avoid shadow popping. If you enabled the option Use Culling for Shadows for your prototype, this can cause popping issues in certain camera angles. If you still have popping when you disable this, you can send us a screenshot/recording of the problem and we can identify the issue.
     
  44. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    6
    Hello I have a problem when using GPU instancer. I have a terrain using the unity editor with about 30 different trees. When I add the tree manager it flashes the wait timer cursor a number of times then crashes. Here is a link to the video i apply gpu instancer at the end and it crashes. https://www.twitch.tv/videos/379925697
     
  45. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    131
    Hi there,
    Can you please send the details of the error message that shows in the Console window so that we can investigate?
     
  46. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,107
    Found another bug.
    When using several cameras and deactivate one and activate other, the objects managed by GPU Instancer disappear from scene. (I suppose the asset lost the camera reference, despite of the cameras are tagged as Camera main).
    Is absurd something so basic is not predicted and provided by the asset.
     
  47. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    354
    If you switch cameras at runtime, you need to use the SetCamera API Method right after you enable/instantiate the new camera in order to notify GPUI of the new camera.
     
  48. ivabibliocad

    ivabibliocad

    Joined:
    Jan 11, 2014
    Posts:
    63
    Has anyone tried the instancer for high end VR like Oculus Rift?? I have some Rift projects that have a few thousand of trees and that has lowered down performance a lot... Hope this tool can get the trick for me???
     
  49. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,107
    Very easy and intuitive, instead of implement that automatically (setting to Camera.main)
     
  50. LouskRad

    LouskRad

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

    You can download the VR version of the demo builds and try for yourself for a better idea.