Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. 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. paradoxical-jay

    paradoxical-jay

    Joined:
    Jan 28, 2020
    Posts:
    8
    Can't get terrain tree or detail manager to work on 2019.3.0f3 with HDRP 7.1.8. Prefab manager seems fine. Known issue?

    EDIT: detail manager is working (although idiosyncratic); however, tree manager fails to render any trees, even when set up identically to prefab and detail manager in same scene.
     
    Last edited: Feb 5, 2020
  2. zoltanBorbas

    zoltanBorbas

    Joined:
    Nov 12, 2016
    Posts:
    81
    Hi there,

    I have a terrain with tree editor trees and the tree manager of GPUI. I have a script, part of the wheater maker asset that controls wind. I did appended that script with the provided shader set global vector code as shown below, however it doesn't seem to work. The code is being called for sure and right after the wind zone is modified as suggested in the documentation. Please note that a not runtime windzone works just fine.

    Am i missing some other line of code for this to work?

    WindIntensity = Mathf.Lerp(oldWindIntensity, newWindIntensity, t.CurrentValue);
    WindZone.windTurbulence = Mathf.Lerp(oldTurbulence, newTurbulence, t.CurrentValue);
    WindZone.windPulseFrequency = Mathf.Lerp(oldPulseMagnitude, newPulseMagnitude, t.CurrentValue);
    WindZone.windPulseMagnitude = Mathf.Lerp(oldPulseFrequency, newPulseFrequency, t.CurrentValue);
    WindZone.transform.rotation = Quaternion.Lerp(oldWindDirection, newWindDirection, t.CurrentValue);
    Debug.Log("Wind Changed");
    Shader.SetGlobalVector("_Wind", GPUInstancerManager.GetWindVector());

    Thanks, in advance!
     
  3. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,238
    We are experiencing an infinite import bug with Unity 2019.3.0f6 that apparently is caused by the import of
    Assets/GPUInstancer/Resources/Settings/GPUInstancerSettings.asset" when the Asset Database V2 is used.
    While this is obviously an issue that I am discussing with Unity, I wonder if the author here can suggest me any workaround to the problem.
     
  4. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    30

    It happens even when turning the Frustum / Occlusion culling off in the GPUI prefab manager. It just starts as soon as it's loaded in within the manager. With or without editing the culling
     
  5. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    772
    GPU Instancer hangs
    I’m having the same issue in 2020.1.0a22. Using URP on a Mac.
     
    Last edited: Feb 7, 2020
  6. sgtkoolaid

    sgtkoolaid

    Joined:
    May 11, 2010
    Posts:
    861
    im getting 12-14 fps despite going from 6722 batches to 242 or so. what gives? my scene currently populates approximately 1200-1400 or so fans in a stadium so far, clearly I need to be able to display aboiut 10-15k approximately at the end of this.
     
  7. paradoxical-jay

    paradoxical-jay

    Joined:
    Jan 28, 2020
    Posts:
    8
    Polygons? You might be GPU-bound.
     
  8. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    Hi there,
    It is highly likely that this can be a shader issue. However, I can say more if you are getting any errors. If you can email us a sample project showing the issue, we can also investigate the problem.
     
  9. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    Hi Zoltan,

    You also need to notify GPUI that the wind changed as such:

    WindIntensity = Mathf.Lerp(oldWindIntensity, newWindIntensity, t.CurrentValue);
    WindZone.windTurbulence = Mathf.Lerp(oldTurbulence, newTurbulence, t.CurrentValue);
    WindZone.windPulseFrequency = Mathf.Lerp(oldPulseMagnitude, newPulseMagnitude, t.CurrentValue);
    WindZone.windPulseMagnitude = Mathf.Lerp(oldPulseFrequency, newPulseFrequency, t.CurrentValue);
    WindZone.transform.rotation = Quaternion.Lerp(oldWindDirection, newWindDirection, t.CurrentValue);
    GPUInstancerManager.UpdateSceneWind();
    Debug.Log("Wind Changed");
    Shader.SetGlobalVector("_Wind", GPUInstancerManager.GetWindVector());
     
  10. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    This is indeed a Unity error, and I can only guess that the culprit is the settings file creation logic in GPUInstancerDefines.cs. It might be that the Unity bug is related to this class working with [InitializeOnLoad]. But this is only a guess, and we could not reproduce this error. I can thus not think of any workarounds for this; but it will probably be fixed in a future update of Unity.
     
  11. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    Then it could be caused by your scene's lighting setup. Please make sure you read the known limitations; and if you are not seeing the issue there, please email us a sample project showing this so we can investigate the issue.
     
  12. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    it could indeed be because of being GPU bound as @paradoxical-jay has suggested, but there could be various other reasons as well. My suggestion would be to first check Unity's optimization guidelines, and then take a look at the GPUI Best Practices wiki for resolving this.
     
  13. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,238
    I am studying the settings and I think I stumbled upon some not documented settings

    1) in the GPUInstancerShaderBindings there is a settings "IsOriginalInstanced". What does it involve exactly?
    2) Matrix Handling Type what's the difference between Matrix Append and Copy to Texture and should I care about it?
    3) what is the Instancing Bound Size used for? "Instancing Bounds Size: Defines the bounds parameter's size for the instanced rendering draw call." is not quite explicative.
     
    Last edited: Feb 12, 2020
  14. Mozq8

    Mozq8

    Joined:
    Dec 30, 2016
    Posts:
    39
    Greetings, is it possible to use this asset only for GPU Occlusion Culling? And how to set it up?
     
    MorpheusXI likes this.
  15. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,238
    It seems that Unity 2019.3.1f1 somehow fixed the problem. Can @SOSolacex confirm?
     
  16. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,069
    I've been having issues with the GPU Instancer Settings (found in Resources) not working with git / source control. It's hard to debug, but it looks like the settings are somehow ignored / reset when reimported, somehow. The reason this is an issue for me personally is that I need to be able to disable auto shader conversion, and it keeps breaking.

    Is there a way I could get into a conversation with you so we could fix this bug?
     
  17. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,238
    Does anyone experience problems with GPUInstancer/URP 7.2.0 and shadow cascades? The shadow cascade are broken and I am trying to figure out what causes it.
     
  18. MorpheusXI

    MorpheusXI

    Joined:
    Jan 18, 2018
    Posts:
    53
    Targeting Android:
    I have GPUI and....in addition to Mozq8 question for my first game I'm targeting OpenGL ES 2.0 and higher. I know instancing would not be supported at the bottom end or as per your FAQ but if I include GPUI in my project can I enable all elements of GPUI and does it detect the GPU and use only what it can or would it just crash if incompatible? Assuming the latter, can I just enable your OC and is this compatible with OpenGL ES 2.0? I will also be targetting PC with same game and know I'll have minimal worries there, just trying to ascertain if GPUI is only good for OpenGL ES 3.1 or Vulkan API.

    Hardware:
    So I have bottom end old mobile Cubot S168 which has ARM Mali 400 - OpenGL ES 2.0 conformant multi core GPU.
    https://developer.arm.com/ip-products/graphics-and-multimedia/mali-gpus/mali-400-gpu

    FAQ: GPU Instancer requires OpenGL ES 3.1 or Vulkan API for Android platforms. Hence question over can I get OC working on this?

    Regards

    Morpheus
     
  19. LouskRad

    LouskRad

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

    1) "IsOriginalInstanced" is true if the original shader is already setup for GPUI.
    2) This is an advanced setting. Compute shaders might work differently in different target platforms. GPUI handles this in the background according to the current target platform (e.g. matrix handling) and uses the required compute shader for them. But for advanced users there is also an option to override this setting and choose the compute shader. You can inspect the code to see the difference.
    3) this changes the "bounds" parameter for DrawMeshInstancedIndirect.
     
    sebas77 likes this.
  20. LouskRad

    LouskRad

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

    No, it is not: GPUI operates on the instances when doing occlusion culling, and this feature would not work for non instanced GameObjects. For more information on this, you can take a look at this wiki article.
     
  21. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    You can disable auto shader conversion from the GPUI preferences. If you are having issues with the GPUInstancerSettings file, you can email us detailed information about these issues and we can investigate them.
     
  22. LouskRad

    LouskRad

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

    all GPUI features work on the instances and through compute shaders, so it is not possible to use elements of it when disabling GPUI. If GPUI is run on a platform that does not meet the minimum requirements, it would throw an error and disable itself.

    You can selectively run GPUI by detecting the compute shader compatibility, but not its features individually.
     
  23. MorpheusXI

    MorpheusXI

    Joined:
    Jan 18, 2018
    Posts:
    53
    --

    Hi LouskRad

    Can I use Unity OC on OpenGL ES 2.0, effectively baking it for scene.

    In the same game build for android *can I also use GPUI to detect the compute shader compatibility so if device was OpenGL ES 3.1 GPUI would run? Or would this conflict with Unity baked OC.

    If yes*, how is the detection done to enable/disable GPUI, is this documented?

    Thanks for your advice.
     
  24. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    341
    I am not using a Unity terrain, but my own run-time generated Mesh as terrain...

    ...is there still a way to use this on my own trees (they are actually Mtree's) or should I not even bother trying?

    It says "requires at least one unity terrain in scene", I assume this does not mean I could make a tiny Unity terrain and hide it in the scene, then magically GPUI works. :D
     
    Last edited: Feb 19, 2020
  25. taylank

    taylank

    Joined:
    Nov 3, 2012
    Posts:
    170
    Hi there. I'm using GPUI along with MapMagic and AmplifyImpostors. It works great for the most part. One issue I'm having is the huge CPU spike when MM enables a new terrain tile with a lot of objects on it. I was happy to see GPUI seemed to have a solution to this in the way of serializing prefab instances. There's a problem however.

    For one thing, the GPUI instanced prefab objects do not have collisions working, as in I can walk right through them. I followed the instructions on the GPUI Modification Collider section of the wiki, but no luck. The MM integration object in the scene cannot be assigned to the prefab manager field of the modification collider, and assigning the runtime generated prefab manager to the modification collider does not do anything for me. Am I missing something?

    Another issue is that serialization removes prefab instances that are already there at design time, but instances that are auto-generated by MM at runtime do not appear to be taking advantage of this system. It should be possible for GPUI to read the instantiation parameters from MM and use the transform data to instantiate new GameObject-less instances. Is this something GPUI might provide in the future?
     
  26. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    146
    Hi,
    There is any API function/or trick to know if a GPUInstancerPrefab (with GPUInstancerPrefabRuntimeHandler attached to it) is culled or not on Runtime ?

    Thanks
     
  27. LouskRad

    LouskRad

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

    Yes, you can have a Unity baked occlusion culling option and use that when you do not use GPUI.
    You can detect if a platform supports compute shaders with the Unity API SystemInfo.supportsComputeShaders
     
  28. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    The Detail and Tree Managers are for Unity terrains, but for your mesh terrains you can use the Prefab Manager. Here is a video that exemplifies this:

     
    Ne0mega likes this.
  29. LouskRad

    LouskRad

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

    The Modification Collider is an optional solution with which you can use RigidBodies with bettet performance. Or enable/disable instancing in general in a given area (defined by the collider).

    In your case, you do not need to use this, you can simply run the MapMagic Intergration Manager and your colliders should be working if you have them on your prefabs.

    GPUI does not remove prefab instances, but instead turns off mesh renderers for instances in the scene during play time. This helps use the existing other components on your prefabs (colliders, scripts, etc.) This behavior is exactly the same for the MM generated terrain prefabs on infinite terrains.

    We are considering adding the GameObject-less MM integration, but one issue with this is what to do with colliders (and any other attached components for that matter). In any case, if and when this feature gets implemented, it will be for MM2.
     
    Lars-Steenhoff likes this.
  30. LouskRad

    LouskRad

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

    Since the culling operations are executed in the GPU, it would require a readback to determine if specific instances are culled. This would cause a major slowdown, so it is not provided as an API method.

    If you need this for a test, the GPUInstancerGUIInfo component uses such a readback for debug purposes.
     
  31. duruenesqr

    duruenesqr

    Joined:
    Feb 2, 2019
    Posts:
    4
    Hey I have a noob question here. I'm thinking of buying this asset but there is a question in my mind.

    It says that the asset requires shader model 5.0 Directx 11.

    Does this mean that when I build the game, only graphic cards with these specifications will be able to run the game?
    Or is it just for being able to build the game?
     
  32. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,238
    only DX11/SM 5.0 cards will be able to run the game, specifically all the cards from Intel HD 4000 and newer on Windows, which means all of them (like 97% of steam user base or even more).
     
    LouskRad likes this.
  33. taylank

    taylank

    Joined:
    Nov 3, 2012
    Posts:
    170
    Thanks for your answer. What about the new Entity Component System? Is that something that could be used in conjunction with GPUI? Are there any potential performance gains from doing so?
     
  34. pdinklag

    pdinklag

    Joined:
    Jan 24, 2017
    Posts:
    82
    One question about transform data buffers: Do I have to update them every frame?

    I am using GPUI with the crowd animator to well, simulate a crowd. :D There is a "focus point" in the scene they're all looking at. To achieve this, I upload that focus point to a compute shader along with the transform data buffer acquired using GetTransformDataBuffer. The code is out of context but it should be understandable:
    Code (CSharp):
    1. private void Update()
    2. {
    3.     AudienceFocus.SetVector("_focus", Focus);
    4.  
    5.     var numPrefabs = Prefabs.Length;
    6.     for (var i = 0; i < numPrefabs; i++)
    7.     {
    8.         AudienceFocus.SetBuffer(0, "_memberTransforms", _instances[i].TransformBuffer);
    9.         AudienceFocus.SetInt("_memberCount", _instances[i].Count);
    10.         AudienceFocus.Dispatch(0, _instances[i].NumComputeShaderThreads, 1, 1);
    11.     }
    12. }
    The compute shader simply computes the necessary rotations for all instances. However, once I disable the component so Update isn't called, all rotations go back to identity. Why is that? The positions stay, so I guess this may either be a bug, or related to crowd animations in some way (transforms being reset for animation?).

    Is there any way I can avoid having to re-compute the buffer in every frame? I'd like to skip a few frames every time to reduce the GPU load per frame.

    EDIT: Figured it out. I had root motion enabled on the animators, which seems to make CA reset the positions every frame. I disabled root motion and got everything working like I want it now. :)
     
    Last edited: Feb 26, 2020
  35. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    146
    I´ve bought GPU instancer a while ago but had some problems integrating it with my projects. So with the latest version now it´s working. So I did some stress tests and... Thank you !! Now I can proceed with this dream project of mine, because I never could the level of detail / performance I wanted.and needed for gameplay



    This is everything cranked up to the top and has much room for performance immprovements.
    Only problem I still have is to get the grass colors right. Somehow I can never reach the exact color I want (and had before on the terrains without the instancer). But that´s neglectable.
     
  36. Cushmily

    Cushmily

    Joined:
    Mar 25, 2015
    Posts:
    9
    I am facing the same infinite looping issue when importing GPUI in Unity 2019.3.x on my mac.

    In my case, everything turns out fine after I remove Entities from the package manager.

    If you need Entities, you can import Entities back after importing GPUI, and it will work.
     
  37. Slowin

    Slowin

    Joined:
    Mar 6, 2015
    Posts:
    60
    But not in Unity 2020.1. I have to remove Entities to be able to import GPUI. If I then readd Entities, it again hangs on gpuinstancersettings.asset import.
     
  38. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    161
    Hello Guys I am Having a funny problem while using gpu instancer with enviro lite Sky And Weather , When I play The Scene With Enviro Activated , All Trees And Grass Disappears And I can only see the shadow of tree and when i get close to tree shadow or to terrain like very close then only i can see the grass or tree , when i disable enviro all becomes normal . now on doing vice versa when i play the scene with enviro enabled and gpu instancer disabled then also everything becomes normal the problem is while using them together. So can anybody help me on what to do to see all trees and grass with both GPU Instancer and Enviro Enabled
     
    Last edited: Mar 2, 2020
  39. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    232
    I needed to report a few PS4 bugs. It seems that clearing all the buffers in OnDestroy doesn't work and will still cause a memory leak. I've had to change this to a manual method I call when starting to load a new level.

    The other issue is a bizarre one that happens in VR mode. It seems that if the headset is turned on after the game was started, the culling doesn't work correctly. Things pop in/out when they shouldn't such as when they're directly in front of you or not very far off.

    I suspect that the view frustrum or fov are somehow changed once VR is enabled which causes GPU Instancer to incorrectly calculate what's visible. Leaving the match and re-joining (complete new scene load) doesn't fix it. You have to exit the game entirely to fix. Any ideas on what might be causing this? It's a really big problem as it really breaks the scene.
     
  40. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    96

    I am running into this issue with Standard shader, my emission is not showing up, I tired both Standard and gpuinstancer/shaders/Standard_GPUI emission not working for both.
     
  41. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    83
    Hi,
    I just update to version 1.4 and "Infinite import loop issue when using Unity 2019.3 or higher" is not fixed.
     

    Attached Files:

  42. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    232
    Here's a video showing the problem on the PS4 in VR mode.
     
  43. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    There is no out of the box ECS integration for GPUI currently. Having said that, you can use a no-game object workflow and render your ECS entities with GPUI by using their LocalToWorld matrices. However when doing this you won't be using Unity's ConvertToEntity component, but handle the entities yourself manually.

    Or if all you need is to render the objects, you don't need to create entities for them at all; you can simply use a no-gameobject workflow.

    Rendering wise, using entities would not change any performance with GPUI, but of course entities would speed up other aspects of your game, resulting in a generally more performant solution.
     
  44. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,238
    @taylank We are using GPUI in place of the UECS Hybrid rendering system. I didn't have the time to compare performance though and now it's a bit too late for us to do so, but I may do one day for my personal blog.
     
  45. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    There is an array called InstanceDataArray working in the background. GPUI CA calculates root motion on this as well, so when updating your _instances.TransformBuffer, you can update this array as well if you want to use root motion along with this solution.
     
  46. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    Thanks!

    GPUI Foliage Shader uses a PBR based lighting model, so that would make the grass colors look different than on Unity terrain. If you are not using URP or HDRP, you can use the GPUInstancer/FoliageLambert shader with a custom material in the Detail Manager. This version uses a Lambert lighting model and your colors would look similar to the original grass with this.
     
    secondsight_ likes this.
  47. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    We were able to re-create this issue with Unity 2019.3 and while having the Entitites package previously existing in the project. We made a workaround for this and in our tests it solved the issue during import; we added this workaround in the v1.4.0 update. If you still are facing this issue after upgrading GPUI to the latest version, please let us know how we can re-create this issue step by step, and also which extra packages you have in your project so we can investigate this.

    Having said that, please note that this is caused by a Unity bug, and all we can do is to workaround it. As a generic temporary solution until Unity fixes this, you can try commenting out the Scripts/Editor/GPUInstancerDefines.cs until your import is finished, and uncomment it again after.
     
  48. LouskRad

    LouskRad

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

    Can you please check if there are any projectors in your scene? If so, this might be the reason, and you can read more on this from this wiki article. Otherwise, if you can email us a sample project (not including enviro files, of course) we can investigate this issue.
     
  49. LouskRad

    LouskRad

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

    The reason buffers are not being released OnDestroy can be because of another unrelated previous error that you might be getting. PS4 should not require anything special in terms of releasing the buffers, but you might be getting a PS4 related error that might be causing the buffers not to release. Please make sure to check any such errors and let us know if any of them are GPUI related.

    As for VR issues, GPUI detects VR upon initialization. If you change into VR after game starts, the manager needs to be destroyed and created again (disable/enable wouldn't be enough).

    We will look into enabling/disabling VR at runtime, and potentially adding an automatic detection system for this for a future update.
     
  50. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    842
    Please email us a sample project showing this so we can identify the problem.
     
unityunity