Search Unity

[RELEASED] GPU Instancer

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

  1. ash4640

    ash4640

    Joined:
    Jan 19, 2018
    Posts:
    66
    Yeah hopefully this gets fixed, mainly brought this for the Terrain and Trees rendering options it provides as I was satisfied with mesh combine for just game objects. But this seems more powerful if they can fix the issues for the Terrain.
     
  2. ash4640

    ash4640

    Joined:
    Jan 19, 2018
    Posts:
    66
    Thanks, I tried going to each tree prefab getting spawned by the Unity tree painter and then turned LOD Cross fade to off in the option, still when GPUI doesn't render the trees.
     
    Last edited: Apr 30, 2020
  3. taylank

    taylank

    Joined:
    Nov 3, 2012
    Posts:
    182
    Any plans for a MapMagic 2 integration?
     
    ftejada likes this.
  4. LouskRad

    LouskRad

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

    This node will be added in the next update.
     
    Davood_Kharmanzar likes this.
  5. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Thank you for the feedback.
    We inspected this issue and found the latest SRP versions indeed cause the objects not to be rendered with LOD crossfade. We will investigate this further, but we will disable the LOD cross fade option for SRP in the next update untill a solution will be implemented.
     
  6. LouskRad

    LouskRad

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

    Gaia has recently received another update, which we still haven't tested with GPUI. We will do this test and make any necessary changes on our side, if there are any. But your case might be unrelated to this; if you wish to speed up the process, you can email us a sample project showing the issue so we can investigate it directly.
     
  7. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904

    Thank you for the videos.

    At first look it looks like a material reference issue, but I can't be sure without checking it. If you can't find the culprit, you can email us a sample so we can investigate it.
     
  8. LouskRad

    LouskRad

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

    it looks like the issue is that the auto-converted shader puts the line

    #include "Assets/GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc"

    below the usage of gpuiTransformationMatrix

    GPUI normally puts this at the end of the shader because Unity keeps changing their usage of their internal includes. You can simply move it to before the usage in the generated shader file to solve the issue.

    As for 2, your usage seems to be proper. However, an alternative and easier way would be to use 2 prefabs with Auto. Add/Remove Instances enabled on them (where the API calls will be made automatically when you enable/disable the GameObjects).
     
  9. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    You can contact us with detailed information with this guideline and we can help you identify the issues.
     
  10. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Yes, this is a work in progress which will be available in a later update.
     
    ftejada and taylank like this.
  11. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    We try GPU Instancer with Meadow Environment Dynamic Nature,
    1. Crate Project Unity3D 2019.3.11f1 ( DX11) - Windowx x64 - HDRP ( 7.3.1 )
    2. Import "CPU Instancer"
    3. Install GPUI_Foliage_HDRP_Support
    4. Import "Meadow Environment Dynamic Nature"
    5. Create New Scene
    6. Paint Tree "prefab_Baked_05_Poplar"
    7. Add "GPUI Tree Manager " to scene, It detects tree and terrain look no problem,
    8. Run scene , ad get exception

    upload_2020-5-2_12-55-17.png


    After :
    1- Try Re-Install "GPU Instancer"
    2- Set Another Tree comes from CPUInstancer ( TreePineLP_003 )
    3- Add this Trees on the scene (30000) - these are fbx not prefab
    4- Set GPU Instancer
    5- Play
    6- It works

    After :
    2- Test with Tree comes from Meadow Environment Dynamic Nature ( 05_Poplar_skan.fbx)
    3- Add this Trees on the scene (30000) - these are fbx, not prefab
    4- Set GPU Instancer
    5- Play
    6- These is no error , but we can not see any treee,
    7- Now Import GPUI extras at
    GPUInstancer > Extras > GPUI_Foliage_HDRP_Support
    GPUInstancer > Extras > GPUI_ShaderGraph_v4.x_Node
    GPUInstancer > Extras > GPUI_SpeedTree8_Support
    8- Test again, but noting changed. There is no tree at the runtime,

    After :
    1. Unset Terrain
    2. Delete Data ( New Terrain_18570)
    3. Add Tree again ( 05_Poplar_skan.fbx )
    4. no error but no tree

    At the final ,
    • System not work Meadow Environment Dynamic Nature
    • We can not use Meadow Environment Dynamic Nature Tree prefabs
    • We can add Meadow Environment Dynamic Nature Tree fbx, there is no exception but there is no tree also.

    I will try more and more with trace code. Please reply to me if you support Meadow Environment Dynamic Nature its important to us.
     
  12. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    When we un-check LOD Cross Fade Checkbox, It works :) with fbx

    upload_2020-5-2_14-2-31.png


    Prefab versions still throw an exception

    upload_2020-5-2_14-4-33.png
     
  13. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    I'm using built-in and my cross-fade was already unchecked, but trees are still invisible. I'm seeing the same thing in the trees example scene that comes with GPU Instancer. Using 2019.3.9.

     
  14. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    @LouskRad
    hi,
    seems that GPUI needs to be reworked ...
    i tested it with URP on Android "Device Simulator Package" and nothing happened !! :]

    for now everything are working great on editor and PC standalone build [URP].
     
  15. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    yes same issue. When you add direct FBX and un-check LOD Cross Fade Checkbox, It works. But if you use tree prefab its not working.
     
  16. stas1990

    stas1990

    Joined:
    Aug 2, 2018
    Posts:
    9
    Can this be used with Sectr? and will they be effective in pairs? I am using GAIA.
     
  17. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    @LouskRad Is it normal for billboards to appear obstructing the camera view using GPU instancer with HDRP 7.3.1? Billboards are what comes at SpeedTree8
    I think I remember that GPUi did not handle billboards in HDRP or something like that. Is this why this problem I say happens, or should it not happen to me?
    If it shouldn't happen to me, how do I fix it?
    I leave video:


    Cheers
     
  18. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    There is no support i think.
     
  19. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    SECTR uses its own culling system, and as far as I remember it does this by turning on and off mesh renderers. This would be incompatible with GPUI.
     
  20. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    We will take a look at the latest HDRP and SpeedTree 8. If you are using the SpeedTree 8 model in any special way, please let us know.

    The instance on camera problem is in general because the shader is not setup properly for GPUI though.
     
  21. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    For everyone that have been facing the disappearing trees issue with the Tree Manager in HDRP, the latest update (v1.4.1) that was live today should fix this issue.

    This update also introduces some additional bug fixes, so if you are having any issues, please make sure you update your GPUI from the asset store first. If that still doesn't help, please send us an email with the details of your issue using this guideline.
     
  22. ahumanbeing

    ahumanbeing

    Joined:
    Dec 5, 2016
    Posts:
    15
    GPU Instancer components really slow down the editor to a crawl in HDRP
     
  23. ManaPotionStudios

    ManaPotionStudios

    Joined:
    Dec 26, 2016
    Posts:
    16

    Hi!

    I was truing to add effect of crowd instanced animated objects being drawn with solid alpha color when they are blocked by depth test. Like in RTS games when unit is behind building. I added this pass to Standard_GPUICA.shader, and it works but only for GPUI instanced objects. If I have a building with standart shader I cant see my unit behind it but I see ghost if it's blocked by object that is using GPU prefab instancing. What am I missing?

    Pass
    {
    Name "OUTLINE"
    Tags { "LightMode" = "Deferred" }
    Cull Off
    ZWrite Off
    ZTest Always

    Blend One OneMinusDstColor // Soft Additive

    CGPROGRAM

    #include "UnityCG.cginc"
    #include "Include/GPUICrowdInclude.cginc"
    #pragma multi_compile _ GPUI_CA_BINDPOSEOFFSET
    #pragma target 3.0

    #pragma multi_compile_fwdbase
    #pragma multi_compile_fog
    #pragma multi_compile_instancing
    #pragma instancing_options procedural:setupGPUI
    // Uncomment the following line to enable dithering LOD crossfade. Note: there are more in the file to uncomment for other passes.
    #pragma multi_compile _ LOD_FADE_CROSSFADE

    #pragma vertex vertBaseGPUI
    #pragma fragment frag

    fixed4 frag (appdata_full v) : SV_Target
    {
    return float4(0.1, 0.1, 0.1, 0.1);
    }

    #include "UnityStandardCore.cginc"
    #include "Include/GPUICrowdStandardInclude.cginc"

    ENDCG
    }
     
  24. Poopaloop

    Poopaloop

    Joined:
    Aug 1, 2013
    Posts:
    21
    Having a weird issue. I'm using unistorm and mTree trees. When GPU Instancer is enabled and I look up into the sky when near trees I see this.


    When disabling GPU Instancer it goes away. Using Unity 2019.3 and GPU-I 1.4

    Thanks
     
    Last edited: May 10, 2020
  25. kanestudio

    kanestudio

    Joined:
    Jan 29, 2018
    Posts:
    7
    Hello, @LouskRad , I have some problems with using GPU Instancer. When i painted whatever 2d and 3d grass the result like this. The grass is too bright in the faraway distance, and the grass shoadow is too dark. But in the GPU Instancer DEMO DetailInstancingDemo there is no problem. Did I make any wrong with settings? My setting: camera rendering path: Deferred, Light Mode: Mixed. grass shadow is open.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      142.1 KB
      Views:
      378
    • 2.jpg
      2.jpg
      File size:
      178.5 KB
      Views:
      371
    • 3.jpg
      3.jpg
      File size:
      136.7 KB
      Views:
      362
    • 4.jpg
      4.jpg
      File size:
      186.2 KB
      Views:
      360
    • 5.jpg
      5.jpg
      File size:
      87.1 KB
      Views:
      376
    Last edited: May 11, 2020
  26. sgtkoolaid

    sgtkoolaid

    Joined:
    May 11, 2010
    Posts:
    899
    when playing a game displaying animated fans in my stadium I get this error. thoughts?

    NullReferenceException: Object reference not set to an instance of an object
    GPUInstancer.CrowdAnimations.GPUICrowdAnimatorRandomizer.RandomizeAnimations () (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdAnimatorRandomizer.cs:56)
    GPUInstancer.CrowdAnimations.GPUICrowdAnimatorRandomizer+<RandomizeCrowdAnimators>d__7.MoveNext () (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdAnimatorRandomizer.cs:35)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <d815b7efac424eeb8e053965cccb1f98>:0)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    GPUInstancer.CrowdAnimations.GPUICrowdAnimatorRandomizer:OnEnable() (at Assets/GPUInstancer-CrowdAnimations/Scripts/GPUICrowdAnimatorRandomizer.cs:20)
     
  27. ManaPotionStudios

    ManaPotionStudios

    Joined:
    Dec 26, 2016
    Posts:
    16
    It's straight forward: "NullReferenceException: Object reference not set to an instance of an object"

    Make sure you are using CrowdAnimator on your fans and not Makanim one, also you can put a breakpoint and see what is null exactly. This library goes with all source codes witch is very handy
     
    LouskRad likes this.
  28. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Is it possible to use decals with GPUI and if so is there a suggested way to do so?
     
  29. Pixel2015

    Pixel2015

    Joined:
    Mar 10, 2016
    Posts:
    35
    Hi, are you planning on implementing Native Collections API? At the moment most of our scene/geometry is created/updated within JOBs using Native containers which we then need to convert to managed just to be able to send to GPUInstancerAPI.UpdateVisibilityBufferWithMatrix4x4Array

    Which obviously just slows down the code unnecessarily. So having Initialize buffer and Update buffer using NativeArray would be really helpful.
     
    sebas77 likes this.
  30. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    If you email us saved profiler data, we can take a look at the issue you are facing. Please make sure you also say which Unity version that data belongs to.
     
  31. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    This might be caused by the lack of sorting order when using GPU instancing, but if you email us a sample project showing this we can investigate the issue.
     
  32. LouskRad

    LouskRad

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

    looks like a shader issue. Please take a look at this wiki article.
     
  33. LouskRad

    LouskRad

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

    Please look at this wiki F.A.Q for the cause/solution.
     
  34. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    If you mean by a decal system a simple quad mesh with a cutout material on it, you can register as any other prototype to a prefab manager. Other that that, however, we have not tried out any decal solutions with GPUI that I can recommend.
     
  35. LouskRad

    LouskRad

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

    Thank you for the feedback. We will look into providing API support for NativeArrays in a future update.
     
    Bzuco and sebas77 like this.
  36. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    GPUI works great on URP [with static and dynamic batching] with very large terrains with tons of trees and details grasses and tons of prefabs but eat too much of memory [RAM]!! is it possible to compressing it??
     
  37. Pixel2015

    Pixel2015

    Joined:
    Mar 10, 2016
    Posts:
    35
    Thanks, looking forward to it, at the moment I went with grabbing the compute buffer with GPUInstancerAPI.GetTransformDataBuffer and just feeding the NativeArray through SetData directly but I would definitely welcome a more robust solution.
     
  38. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    It would be compatible if you use SECTR for short distance objects loading them into view as full versions of a building with interiors. you could then use GPUI for distance based objects which would be for gameObjects (less detailed versions) of a building, but would require a modification to SECTR loader.
     
  39. Deleted User

    Deleted User

    Guest

    Hey :)
    We use Voxeland, for our meshes and I was trying to instance the mesh terrain, however, after setting up the prefab prototype with the GPUInstancerPrefabManager I experience a frame drop, I come to the conclusion that's just because GPU Instancing makes no sense when just having one object and having to compute 3000 individual prototypes is not the purpose so I have 2 questions

    Does it make sense to instance these chunks maybe every mesh with a different variant, and how can I do this?
    But what makes definitely sense is to cull this chunk meshes, so is there a way to use the culling feature without having to compute the other instancing logic?

    EDIT: Already solved it with a simple but not that accurate culling system
     
    Last edited by a moderator: May 16, 2020
  40. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    Sounds crazy, but this is TOO good for my project, resulting in it being incredibly GPU-bound. Any ideas to avoid this, such as having the ability to transfer specific features to CPU?
     
  41. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    57
    Hi,
    I want to modify the detail density during runtime, how can I do this ?
    Also, is there a way to know, what detail there is under the player feet ?
    (I want to make a sound whenever the player run across some grass)
    Thanks
     
  42. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    196
    Does anybody know what would cause instanced objects to be shiny in build, but look fine in editor play mode? Using regular unity HDRP shader.
     
  43. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    Hi @LouskRad I noticed my unity Lens Flares don't show in game when this GPUI Occlusion Generator script is active. When I disable this script, my Lens Flares appear. I assume this GPUI script is necessary, is there any way to get Lens Flares to show up while this script is active? I'm on Unity 2018.3.8, standard pipeline, GPUI v1.4.0
    upload_2020-5-15_14-51-46.png
     
  44. tubbz0r

    tubbz0r

    Joined:
    May 24, 2014
    Posts:
    72
    @LouskRad I currently have an issue where adding a prototype to the prefab manager crashes my unity client.
    Happens everytime.
    crash.png
     
  45. sgtkoolaid

    sgtkoolaid

    Joined:
    May 11, 2010
    Posts:
    899
    thanks bub, that worked. I also deleted the crowd manager for good measure since I went with a different system for scattering. baked the animations via crowd animator and no more errors. much appreciated. let's see how this performance holds up as I add fans now. :) wish me luck.
     
  46. sgtkoolaid

    sgtkoolaid

    Joined:
    May 11, 2010
    Posts:
    899
    now i have another problem i go to put in my fan lod into prototypes and i only get one despite the fact I have a couple thousand in the scene. fan instance count: shows 1 and shows up in red. even if i bake the animations via crowd animator. where as i have around 2100 in the scene using megascatter.

    DISREGARD: figured it out. found out that you can't use from the scene itself but rather from your asset folder where the object in question is located. derp. these are little lessons to be learned.
     
    Last edited: May 17, 2020
  47. LouskRad

    LouskRad

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

    if the scale of your project is starting to cause memory management issues, it could be a good idea to switch to using a no game object workflow so that you don't have GameObjects cluttering memory.
     
  48. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    GPUI features all work on the GPU, so transferring as such would not be possible. However, you could eliminate some of its GPU usage by removing prototypes with relatively lower instance counts from the manager.
     
  49. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Changing detail density in terms of adding more detail instances would require a re-initialization of the manager, however, you could change detail meshes (for example by increasing the quad counts, or using another bunch mesh all together) without breaking instancing. You can take a look at the DetailDemoSceneController.cs for an example usage.

    As for knowing if there is detail in a given location, GPUI does not remove terrain details but only disables their rendering. That is, you can write your own solution based on the data from the Unity terrain.
     
    pierre92nicot likes this.
  50. LouskRad

    LouskRad

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

    Thank you for the feedback; it looks like there is an issue with Unity when you use the depth texture in a blit shader. You can, however, use the alternative method by changing to it from the GPU Instancer Preferences and use the Compute Shader technique instead:

    upload_2020-5-19_14-45-29.png

    This would not cause any performance loss, and should fix the issue with lens flares.