Search Unity

[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:
    3
    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:
    79
    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,081
    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:
    6

    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:
    417
    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:
    853
    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:
    3
    Polygons? You might be GPU-bound.
     
  8. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    686
    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:
    686
    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:
    686
    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:
    686
    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:
    686
    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,081
    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:
    19
    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,081
    It seems that Unity 2019.3.1f1 somehow fixed the problem. Can @SOSolacex confirm?
     
  16. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    968
    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,081
    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:
    42
    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:
    686
    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:
    686
    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:
    686
    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:
    686
    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:
    42
    --

    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:
    213
    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 at 4:26 AM
unityunity