Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. 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. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    273
    Was GPU instance tested with Unity 2020.1.8f1? While paused, the same scene loaded in that version runs at < 1 FPS with all tabs closed except the scene view, where it runs at >30 FPS in Unity 2019.3.15f1.
     
  2. Steve2375

    Steve2375

    Joined:
    Mar 28, 2015
    Posts:
    27
    In my project, all unity flares don't show up as soon as the script GPUInstancerHiZOcclusionGenerator is attached to the camera. Is this a known problem and can we workaround it? What is this script doing?
     
  3. monda

    monda

    Joined:
    May 14, 2015
    Posts:
    22
    Thanks for your help. Unfortunately the main (only) reason I've bought this was for Android, at the end I've just used the Unity "Standard" way to do GPU Instancing and the Shader works fine on Android.
     
  4. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    876
    We haven't seen any problems with the 2020.1.8.f1 in our tests. I suggest you use the profiler to identify what is causing the performance hit.

    You can solve the issue as described in this F.A.Q.
     
    Steve2375 likes this.
  5. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    910
    Hi,
    We use GPU Instancer in our project.

    For a simple billboard which moved around (a thought bubble above the head of a character), I created an own simple unlit shader (vertex / fragment) which uses Unitys instancing for a color property (MaterialPropertyBlock).

    I realized that the billboard sometimes disappears if GPU instancing is enabled in the material.
    I assume that it has something to do with your asset... Is this a known problem and is there a workaround for this?
     
  6. FrozenKiwi

    FrozenKiwi

    Joined:
    Mar 7, 2019
    Posts:
    13
    Hey:

    First - incredible job on your support - amazing to see such responsiveness after so many years/pages :).

    I'm interested in using GPUI to handle GPU occlusion/frustum culling for my entire scene. We have lots of small meshes and a very high rate of occlusion. From what I understand, if you are doing culling on the GPU then you must also be doing all your actual draw calls on the GPU, is that correct? So there should be a single draw call to trigger drawing all meshes/instances that share a material?

    In this case, wouldn't it be -always- more efficient to render with GPUI? This doesn't seem true, because your docs state it is less efficient to use GPUI for low numbers of instances (and there are a few comments I read that noted multiple draw calls for different meshes). However, I'm trying to wrap my head around how you do occlusion culling without issuing the draw calls on the GPU.

    Apologies if this has already been asked, I tried to skim the pages but there is a lot of questions already
     
  7. SinDeSiecle

    SinDeSiecle

    Joined:
    Sep 30, 2017
    Posts:
    65
    Hi,

    Ok, changing the original message, since I figured out what was wrong. But, I have a different problem, now.

    I am using runtime prototyping and instantiation. I needed a grass prefab to place on the surface by raycasting on ground, so I needed GPUInstancer to instance it after placement was done. I managed how to do this by the following code:

    public void GPUInstancingOperationInstant (GameObject anObject, bool makeRemovableByObjects = true) {
    // if prototyped previously, we keep the object name in list named "prototyped" to filter out further requests
    if (!prototyped.Contains (anObject.name)) {
    Debug.Log ("Object " + anObject.name + " is not prototyped, will be runtime prototyped.");
    prototyped.Add (anObject.name);

    GPUInstancerPrefabPrototype p = GPUInstancerAPI.DefineGameObjectAsPrefabPrototypeAtRuntime (prefabManager, anObject);
    p.isFrustumCulling = true;
    p.isOcclusionCulling = true;
    p.useOriginalShaderForShadow = true;
    p.enableRuntimeModifications = true;
    p.extraBufferSize = 50000;
    p.addRemoveInstancesAtRuntime = true;
    p.autoUpdateTransformData = true;
    p.addRuntimeHandlerScript = false;

    GPUInstancerAPI.AddInstancesToPrefabPrototypeAtRuntime (prefabManager, p, new GameObject[] { anObject });
    Debug.Log("Called GPU Instancer method");
    if (makeRemovableByObjects) {
    removablePrototypes.Add (p);
    }

    }

    if (!anObject.GetComponent<GPUInstancerPrefab> ()) {
    anObject.AddComponent<GPUInstancerPrefab> ();
    }
    anObject.AddComponent<MYRemoveFromGPUInstancerOnDestroy> ();
    GPUInstancerAPI.AddPrefabInstance (prefabManager, anObject.GetComponent<GPUInstancerPrefab> ());
    }


    The problem is: although the frame rates showing over 45 - 50 fps on editor, it plays like 1-2 fps short time after instancing. And there is an instance appearing in camera space just floating in the air and moving with the camera, but comes into view when I look back. No warnings, no errors in the console. Only 8000 instance was instanced. (I also have a increased max buffer size to a number like 500000 in GPUInstancer settings, but 8000 is way beyond that number).

    What am I doing wrong?

     
    Last edited: Oct 14, 2020
  8. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    876
    Hi there,
    the "enable instancing" option on the materials does not effect the working of GPUI at all, since it uses its own rendering solution.

    If you are using GPUI with that billboard, please keep in mind that MaterialPropertyBlocks for instanced properties would not work with GPUI. Instead, you can take a look at this wiki article for material variations.

    Hi there,
    and thanks for your kind words.

    Yes that is correct; the culling features only work for the instances that are rendered by GPUI. But it wouldn't be always more efficient to use GPUI for everything just to have it cull them. The reason is simply because GPUI's culling, etc. operations use some small operation time in the GPU which is unnoticeable with high instance numbers because of the gain from draw calls, but would slow down the system if used for a lot of prototypes with low instance counts.

    The point about culling is, it is only good if the testing operations take less then the gain in rendering when some objects are culled. In the case of GPUI, this operation works on top of the instances for some extra benefit to indirect instancing. However, if the rendered objects are not benefiting from indirect instancing to begin with, than the culling operations are actually a hindrance - so it doesn't make sense.

    Instancing appearing on top of the camera are almost always because of a shader problem (which would slow down performance as well). You can take a look at this wiki F.A.Q for more information on the shader setup.
     
  9. LouskRad

    LouskRad

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

    the GPU Instancer v1.4.3 update is live in the asset store. This version comes with a new demo scene that showcases how you can use material variations (in this case the UV) with shader graph. You can find this new demo scene inside the GPUI_ShaderGraph_v5.x_or_Later_Node package. So if you have been using the shader graph node, you need to re-extract the package to see the new demo.

    image_2020_10_19T13_37_48_700Z.png

    This version also fixes the issue with Map Magic 2 graphs that have biomes.

    You can see the full changelog for v1.4.3 below:

    New: Added a sub graph and a demo scene for material variations with Shader Graph

    Fixed: Instances are not rendered when editor is paused
    Fixed: Map Magic 2 integration can not import objects from graphs with biomes
    Fixed: Shadow distance is now correctly read from the Universal Render Pipeline Asset in URP.
    Fixed: XR and VR libraries are now checked for and the VR logic defaults to non-VR if both libraries are not present.
     
  10. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    18
    Hi there. Just bought this to manage my forest scenes. I use nature renderer's shaders and my trees lose their wind animation when they get instanced. Is this because maybe those shaders make use of Geometry shaders which are supposedly not supported by GPU Instancer?
     
  11. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    556
    Hello,

    I'm using NatureManufacturer's Forest environment trees in HDRP. Would this asset in any way let me speed up the game without having to change their shaders? (I'm using mapmagic2 to add them as trees to the terrain).

    Thanks!
     
    Last edited: Oct 25, 2020
    LouskRad and Duffer123 like this.
  12. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,164
    It would, definitely. I use GPUI with just the same assets.
     
    LouskRad likes this.
  13. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,164
    The way GPUI plugs in to Map Magic 2 is magic....
     
    DGordon and LouskRad like this.
  14. NikoBay

    NikoBay

    Joined:
    Aug 15, 2018
    Posts:
    27
    Is it recommended to use GPUI for instantiating bullets in a 2D Bullet Hell game? I can change sprite renderer to mesh renderer. Already use Pool for bullets. All bullets moving on Transform.
    Now does this asset provide any performance boost for this type of scenario?
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    876
    Geometry shaders are indeed not supported (Unity does not support them together with GPU instancing). I don't know details about how nature renderers shaders work, but if it's using its own instancing setup, it would be conflicting with GPUI.

    Well, if you mean if you will get a performance boost by using lots of quad meshes with GPUI, you would get a rendering performance boost. But if you are slowing down because of, for example, a script's update, this boost might not increase fps.

    As for whether this solution would indeed be faster than using sprite renderers and an object pooler, I can't comment on that without trying it. But the performance gain over this would certainly scale up with the amount of bullets you have in your bullet hell.
     
    NikoBay likes this.
  16. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    556
    I'm quoting myself to give an update. Using this I managed to go from low 30 fps to mid 40fps, and that was only from trees. While I do notice a bit of popping, thats on me -- I could set the LOD further back if I wanted ... it has an amazing set of tools for putting things under my control that I didn't even know _could_ be under my control.

    7.5k draw calls listed in the stats window for HDRP (is that accurate?) down to 1.5k by adding 1 gameobject, and I don't have any bushes on this, just my trees. If I really went to town with this and whatever else I should be doing, it could be much lower I'm sure.

    If anyone else is wondering, yes, this was worth it.

    Note: I am using NatureRenderer for my grass. I am not using GPU instancer for grass. Is this correct, or does this somehow work in tandem with NR? It seems like, from the above post, I am correct in assuming I should just let NR do what it does and not touch it with this. If I'm wrong just let me know, otherwise I'll sit here happily as it is :).
     
    LouskRad likes this.
  17. FrozenKiwi

    FrozenKiwi

    Joined:
    Mar 7, 2019
    Posts:
    13
    Thanks for the info,

    Just to clarify, I assume the technique you are using is Hi-Z like https://github.com/nvpro-samples/gl_occlusion_culling? Your documentation says you read the depth buffer from the camera, does this mean you using the current frame as occluders? or do we do a depth pre-pass? Should I be doing some sort of sorting to ensure I render occluders early? Is there any chance of doing temporal-current-frame method?

    I'm not getting the performance boost I was expecting from this and I feel I must be setting things up wrong/poorly. I am just trying to eliminate the gaps in my knowledge so I can move in the right direction.
     
  18. Aleksei-Kolotilov

    Aleksei-Kolotilov

    Joined:
    Jun 3, 2015
    Posts:
    13
  19. PradyumnaP95

    PradyumnaP95

    Joined:
    Dec 3, 2019
    Posts:
    1
    Hey Guys, I've created instances for a a set of prefabs in two levels. But the GPUIs created work only for one level at a time. For the other level to work, I have to delete the existing instances created and add them in the prefab manager. When I do this, the instancing works in the curent level but gets disabled in the other which uses the same prefabs. How do I solve this? Thanks for your help.
     
  20. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    876
    As said, the main gain comes from instancing and not culling. You can take a look at https://wiki.gurbu.com/index.php?title=GPU_Instancer:Terminology for more information on how they both work in GPUI.

    If what you mean is to add instances to your manages in your two scenes, you can take a look at this wiki article for more information.
     
  21. meichen8050753

    meichen8050753

    Joined:
    Jan 16, 2017
    Posts:
    27
    I solved this by render gpui use independent camera after all scene object rendered.
    @LouskRad Thanks for your replay, I's very helpful to me.
    Upload.png
     
    Last edited: Nov 9, 2020
  22. sasob8

    sasob8

    Joined:
    Jul 11, 2017
    Posts:
    16
    Hi,
    i have performance question... In Unity 2020.1.10, URP i made simple scene with MapMagic2. With GPUI i instanced 8000 trees (trees are scattered objects on terrain with mapmagic). Turning GPUI on/off i go from 56k batches, 11M tris and 44 setpass calls to 13 batches, 2k tris and 13 setpass calls. That is significant change, but frame rate remains more or less the same, or it even goes down - around 30 - 35 FPS...
    I have laptop with MX150, so that means i am gpu bound quickly. Am i doing something wrong in my case or is it just gpu bound, and i cannot do anything? Does that also mean, there would be significat boost of frame rate on different machine (same scene)?
    For test i reduced number of trees (to 2000) and frame rate goes from 70 to 110 FPS. If i reduce trees again there is less difference in FPS (bytheway i use Fraps for FPS count, i also look at unity stats, but difference is the same).
    To sum up... The best way to use GPUI is only in cases you have your scene set up to have around 60 FPS without instancing and than turn it on to boost. Is that how it works? :)

    Edit:
    I downloaded Asteroids demo for benchmarking and tried all 4 scenes. Stats:
    Scene - AvgFPS > boostedFPS
    10k - 64 > 69
    50k - 28 > 57
    100k - 14 > 45
    200k - 7 > 35
    I would call that significant boost... Why am i not seeing that kind of boost? What am i doing wrong? Please help :rolleyes:

    Edit2 (solution?):
    Ok, so i did a lot of test to figure this out... It doesn't matter how many "Tris" (in stats) you have in the scene. It only matters how many polygons has instantiated object. I created simple cubes with 48, 192 and 768 polygons. With Mapmagic i scattered different number of objects. When i toggle GPUI on/off, there is significent difference when using 48 version of cube. 192 is way smaller, and 768 has negative effect with GPUI.
    So... You can have 2k or 20k "48" cubes, there will always be a difference in FPS. Meanwhile "768" has negative effect.
    Why is that?

    Thank you
     
    Last edited: Nov 3, 2020
  23. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    39
    Hello, quick question. I need to move my terrains at runtime, but the trees registered in the GPUI Tree Manager stay static and won't follow the terrain transforms. Is there a way to allow them to move like the prefabs registered in the GPUI Prefab Manager with the Auto. Update transform data option enabled?

    EDIT: if not, will having the trees in the Prefab Manager instead of the Tree Manager make a difference on performances?

    Thanks
     
    Last edited: Nov 4, 2020
  24. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    41
    Hi, can I change the smoothness value of instanced prefab ?
     
  25. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,804
    @LouskRad - Tree Settings on GPU Instancer Map Magic 2 Integration script don't work.
    I know terrain and SpeedTrees don't mix well, but isn't instancer not using terrain trees but rather drawing indirectly on Gfx Card?

    So kind of curious as to why SpeedTrees aren't working with the settings (Random Rotation, Random Height and Use Prefab Scale). (Neither work).

    I assume it's because it's somehow treating it as a Terrain Tree. Kinda stinks how Unity and SpeedTree's have all sort'a issues and it's the only real tree option we have for Unity lol. (not your fault).

    But anyways, if there's anything that can be done I'd be happy to know :)

    Take care mate.
     
  26. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    425
    after trying use ASE and GPUI and did all stuff in guide i simply dont see objects in scene.
    they dont show up after i hit play
    did all things like was described here https://wiki.gurbu.com/index.php?title=GPU_Instancer:FAQ#Amplify_Shader_Editor_directives

    please help

    new: after i used ASE shader, i tried just use other material. with complete new material and new prefab manager objects still dont show up in scene.
    new object works fine, but not old one

    new new:
    got this 4 errors:

    Change stack is empty, did you call BeginChangeCheck first?
    UnityEditor.EditorGUI:EndChangeCheck()
    GPUInstancer.GPUInstancerEditor:DrawGPUInstancerPrototypeBox(GPUInstancerPrototype, Boolean, Boolean) (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerEditor.cs:761)
    GPUInstancer.GPUInstancerEditor:DrawGPUInstancerPrototypeBox(List`1, Boolean, Boolean) (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerEditor.cs:388)
    GPUInstancer.GPUInstancerManagerEditor:DrawGPUInstancerPrototypesBox() (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerManagerEditor.cs:407)
    GPUInstancer.GPUInstancerPrefabManagerEditor:OnInspectorGUI() (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerPrefabManagerEditor.cs:54)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)


    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEditor.EditorGUILayout:EndVertical()
    GPUInstancer.GPUInstancerManagerEditor:DrawGPUInstancerPrototypesBox() (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerManagerEditor.cs:409)
    GPUInstancer.GPUInstancerPrefabManagerEditor:OnInspectorGUI() (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerPrefabManagerEditor.cs:54)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <437ba245d8404784b9fbab9b439ac908>:0)
    GPUInstancer.GPUInstancerPrefabManagerEditor.DrawRegisteredPrefabsBoxList () (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerPrefabManagerEditor.cs:515)
    GPUInstancer.GPUInstancerManagerEditor.DrawRegisteredPrefabsBox () (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerManagerEditor.cs:271)
    GPUInstancer.GPUInstancerPrefabManagerEditor.OnInspectorGUI () (at Assets/GPUInstancer/Scripts/Editor/GPUInstancerPrefabManagerEditor.cs:45)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <a20a50bbfaff4193bf6ba6b262f9a71f>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    new3: seems GPUI have some problems to instanciate transparent shader... opaque works fine, but still ASE opaque wont show

    new4: ok, i found that gpu instancer tools panel was more usefull then a though. clear all shaders and generate tham again fixed my problem. but i have to do this every time i need to change ASE shader. changes dont accept automaticly.
    sadly, this is works with opaque shader only, but not with transparent.
     
    Last edited: Nov 5, 2020
  27. Tirus

    Tirus

    Joined:
    Aug 9, 2013
    Posts:
    5
  28. Slowin

    Slowin

    Joined:
    Mar 6, 2015
    Posts:
    62
    Hi,

    I receive this error message now using the prefab manager in my scene:

    Graphics.CopyTexture called for entire mipmaps with different memory size (source (R32 SFloat) is 22118400 bytes and destination (Depth) is 11059200 bytes)
    UnityEngine.Graphics:CopyTexture (UnityEngine.Texture,int,int,UnityEngine.Texture,int,int)
    GPUInstancer.GPUInstancerHiZOcclusionGenerator:UpdateTextureWithComputeShader (int) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:273)
    GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRendering (UnityEngine.Camera) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:260)
    GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRenderingSRP (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:212)
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)

    But it still does work and draws all the items I want. Would still be good to get rid of this error of course.

    Unity 2020.2.0b10
    HDRP 10.1.0

    Thanks
     
    Last edited: Nov 8, 2020
  29. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    876
    In general, you will get the most benefit from GPU Instancing where you have lower amount of polygons per instance and high instance counts of that object. For example, 1600 instances with 48 polygons are a lot better than 100 instances with 768 polygons - although total rendered polygon counts would be the same. This is related to how GPU Instancing itself works. You can read up more on this in our terminology page.

    You can use the floating origin feature to move your trees along with the terrain when using any manager. You can take a look at this video for more information:

    (You can jump to 9:50 for the relevant part)



    GPUI will use the smoothness value of the material of the prefab for all the instances. If you mean smoothness variation among instances, you can do that in the same logic that the color variation demo exemplifies.

    Hi there,

    GPUI Tree Manager (and the MM integration) reads the applied rotation and scale values from the Unity terrain. This works the same whether the tree is a SpeedTree or not. So if you see the (speed)tree rotated or scaled on the terrain, it should be rotated or scaled matching the same values when rendering with GPUI as well.

    SpeedTrees can be random rotated in a Unity terrain:

    upload_2020-11-9_15-5-51.png

    If you add the directives to an ASE shader manually (rather than leaving it to GPUI to auto convert the shader) you should not need to cleanup or generate shaders - since you are basically telling GPUI to ignore any conversion by manually setting up your shader.

    We can investigate what is wrong if you send us a sample project.

    As for Transparency, it doesn't play well with GPU Instancing as written in this wiki article, but the problem is with the ordering of the instances, etc. - it should not be breaking your instances otherwise.

    Yes you can use custom shaders and materials, and also there is a ShaderGraph setup node.

    Alpha and Beta versions of Unity are not officially supported by GPUI, since most of such errors are fixed by Unity for a stable final Unity build. We test and make any necessary fixes/adjustments to GPUI when official release versions of new Unity builds are released.
     
    pierre92nicot likes this.
  30. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,804
    @LouskRad I decided to just use regular terrain (outside of MM) and it works perfectly fine now. Perhaps there was an issue with MM2 and GPUI? Well didn't stop using MM, just use it to generate the base terrain and then hand sculpt the rest lol.

    But I do have a question I've always wondered - is there a way to make GPUI work in the sceneview? Can't we do a [ExecuteInEditMode] or whatever it's called flag? Or is there any plans in the future to implement a feature like this if there isn't one yet?
     
  31. ash4640

    ash4640

    Joined:
    Jan 19, 2018
    Posts:
    62
    upload_2020-11-10_20-32-37.png upload_2020-11-10_20-32-5.png
    With Tree instancing the FPs drops by 20fps even when the tris and set pass calls are less
    How is that in the example scene fps increase drastically
     
  32. zwiglm

    zwiglm

    Joined:
    Jul 20, 2015
    Posts:
    1
    Well, a "bit" more documentation as how to convert shaders in URP would be nice. So far I haven't managed to solve this.

    Edit: Of course everything works perfectly fine in SRP.
     
    Last edited: Nov 15, 2020
  33. mutp

    mutp

    Joined:
    Oct 1, 2018
    Posts:
    60
    Enabling the Runtime Settings for registered prefabs in the GPUI Prefab Manager does not work correctly.

    These prefabs are supposed to be enabled and disabled in the scene at runtime with their position change. The same should work when they are added to the GPUI Prefab Manager. So the prefabs in the GPUI Prefab manager does not change their position or active status at runtime.

    Checking further in the "GPUI Instancer Prefab Runtime Handler" script's OnEnable and OnDisable(attached to these prefabs), it seems like the script was not able to get the GPUI Prefab manager in the scene.
     

    Attached Files:

  34. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    876
    For the Detail Manager, you can use the Simulate at Scene Camera button for this. For the prefab manager, you can Disable Mesh Renderers under Advanced Actions and use the Simulate at Scene Camera [Experimental] button that appears after. There is no simulation mode for the Tree Manager.

    You can take a look at the Best Practices wiki for information about how you can make better use of GPUI. In general, what would mainly effect performance are instance counts, mesh vertex counts and shader complexity. I would also suggest fixing the errors in the screenshot before optimizing performance - since they can be effecting the result as well.

    If you can be a bit more specific I can help direct you toward a solution. But if you want to manually convert URP shaders to set them up with GPUI, you can take a look at this wiki article.

    That might be a rare case of an execution order problem. You can try taking the Prefab Manager higher in the priority order in the Edit -> Project Settings -> Script Execution Order.
     
    ash4640 and N1warhead like this.
  35. mutp

    mutp

    Joined:
    Oct 1, 2018
    Posts:
    60
    We've tried doing this, but it still doesn't work.
     

    Attached Files:

  36. dongliang28

    dongliang28

    Joined:
    Oct 3, 2010
    Posts:
    182
    Hi, i'm looking for a terrain vegetation rendering system and GPU Instancer looks pretty nice.
    i have two 2 questions about it before i buy it.

    1.does GPUI support "density falloff by distance"?
    this is an important feature to fade out details and increase performance, but i didn't find it in the document.

    2.does GPUI support higher detail density value than the terrain's detail density?
    the max value in document i see is limited to "1",but some time huge terrain will need more density value to fill up.

    if these 2 features are not included in GPUI, will they be added in the future?
     
  37. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,804
    @LouskRad
    I'm facing an issue I just realized, not even sure how to even articulate this.

    Okay Scenario 1 - I go into my forest with GPU Instancer off - get 35 FPS.
    Scenario 2 - I go into my forest with GPU Instancer on - get 15 FPS.

    Okay now them two numbers don't necessarily mean anything, they are just numbers. So I needed to find some context as to what was causing such a massive FPS drop considering Instancing is supposed to be way faster.

    Well if I go to Scene view while the game is running and change the shading mode from shaded to overdraw I noticed something off - for some reason ALL the overdraw is stuck over the camera center.

    Example - here's normal overdraw without GPUI on.
    upload_2020-11-19_6-3-47.png

    Now here it is with GPUI On.
    upload_2020-11-19_6-4-43.png

    Perhaps GPUI is supposed to do this I do not know. The terrain trees and such all render where they should, but overdraw is all drawn on top of camera apparently so it makes things extremely inefficient. I mean I'm losing 20FPS using GPUI and I can think this is the reason why.

    Any info on how to fix this?
     
  38. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,804
    Here's how simple my scene is now and still losing a ton of FPS.

    This is without GPUI on.
    upload_2020-11-19_15-24-30.png

    This is with it ON.
    Stats are WAAAYY better (for some reason have a ton of more batches with GPUI), but performance still losing about 10 FPS. This is a very simple area - a few trees (20ish trees), no grass. Each tree has LOD's - the max lod is like 4K Polys.
    upload_2020-11-19_15-26-21.png
     
  39. JuanJSAR

    JuanJSAR

    Joined:
    Feb 21, 2014
    Posts:
    39
    Hi, I am using the "GPU Instancer" and the "Bakery - GPU Lightmapper", my question is if I can use a "Baked Lightmap" in the GPU instances so that it has the details of shadows and highlights.

    Without being running:
    upload_2020-11-20_10-35-7.png

    in running:
    upload_2020-11-20_10-35-23.png

    I have it like this:
    upload_2020-11-20_10-35-52.png

    This is what a cube looks like
    upload_2020-11-20_10-36-12.png

    Thank you for your attention.
     
  40. Da-Luk

    Da-Luk

    Joined:
    Apr 25, 2017
    Posts:
    44
    Hey, i want to use gpui only for lod levels 1 and 2 because my lod 0 material contains tesselations which is not supported. I created a prefab including 2 prototype prefabs which will be instanced and a normal gameobject. The gameobjects lod 1 and 2 is empty. On the other side the two instanced prefabs lod 0 is almost empty (only a small cube with a standard cutout shader alpha 0).

    That works great in play mode but i have problems with the lod group switching from LOD 0 to LOD 1. There is a gap no matter what i do. I tried same bounding size, same lod bias. I even tried to adjust the min culling distance to the end of lod 0. There is always a gap were no objects are rendered and i dont want to overlap two lod levels.

    Is there another way to solve my problem.
    Is it possible to write a smal script which will check the lod group of the instance to activate or deactivate the lod 0 mesh renderer from the game object which is not instanced?

    Thank you in advance.
     
  41. Stingreye

    Stingreye

    Joined:
    Mar 15, 2018
    Posts:
    9
    Is there a walk through on what's required on the wiki or somewhere for asset bundles to work with GPU instancer?

    we have a scene using GPU instancer that is getting packed as a bundle asset. How do we get it to load properly when we load it as a bundle asset?

    where its obvious is in the editor view on the scene when hitting play I can see the GPU Billboards which look GREAT and are set to appear when culled.

    When loading the asset bundle in the game, the bushes and trees get culled instead of billboarded.

    Any help is appreciated!
     
  42. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    41
    I want all my trees to get wet or dry depending on the weather (by modifying the smoothness), is it possible?
     
  43. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    876
    You can take a look at this wiki article to see alternative methods on adding instances at runtime. You can also send us a sample project which shows the problem so we can investigate it.

    Hi there, and thanks!

    The built-in systems do not provide falloff and increased density features for the Unity Terrain details - however, you can use a no game object workflow for maximum control over your instances and implement your own solution.

    Hi there.

    The reason why "the overdraw view" in Unity shows the GPUI instances on top of each other is because Unity's overdraw view shader is not setup for GPUI.

    Other than that, the fps issue could be related to something else in the scene; such as an effect or a projector, etc. In any case, if you haven't already checked it, please check the best practices page. If you send us a sample project showing the issue, we can investigate it further.

    Hi there;

    GPUI's LOD calculations can differ from Unity's slightly - which would create that "gap" effect. This is because Unity calculates the LODs based on screen relative height and the object's bounding boxes. GPUI matches this calculation as much as it can, but it would not result 100% the same with Unity's.

    You could script your LOD switching manually for the LOD 0 to work with distances and use min distance in the manager for LOD 1 and LOD 2 prototypes (instead of using them as LOD group components).

    There is nothing special that needs to be done for GPUI when using asset bundles; other than making sure all the necessary files are getting in the bundle / build (such as GPUI prototype scriptable objects, shaders, billboard textures, etc.)

    You can check for error messages in the built game; and make sure especially the generated "_GPUI" shaders are being included in the build along with the generated billboard textures if you are using the "generate billboard" feature.

    If you want the same smoothness value on all the instances changed during runtime, you can use the "smoothness" value as a Global Shader Property in your shader. If you want to modify the material during runtime for this instead, you can use the ChangeMaterial API method
     
    pierre92nicot likes this.
  44. xkingjohnx

    xkingjohnx

    Joined:
    Feb 22, 2016
    Posts:
    59
    Hi there,

    I am using GPUInstancer with a runtime instantiated camera which has the GPU Instancer Camera Handler attached to it. Everything seems to work so far, but I am receiving the following error in my console:


    Destroying assets is not permitted to avoid data loss.
    If you really want to remove an asset use DestroyImmediate (theObject, true);
    UnityEngine.Object:DestroyImmediate(Object)
    GPUInstancer.GPUInstancerManager:SetCamera(Camera) (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:568)
    GPUInstancer.<>c__DisplayClass2_0:<SetCamera>b__0(GPUInstancerManager) (at Assets/GPUInstancer/Scripts/API/GPUInstancerAPI.cs:46)
    System.Collections.Generic.List`1:ForEach(Action`1)
    GPUInstancer.GPUInstancerAPI:SetCamera(Camera) (at Assets/GPUInstancer/Scripts/API/GPUInstancerAPI.cs:46)
    GPUInstancer.GPUInstancerCameraHandler:Update() (at Assets/GPUInstancer/Scripts/GPUInstancerCameraHandler.cs:33)

    Could someone please help me regarding that?
     
  45. Stingreye

    Stingreye

    Joined:
    Mar 15, 2018
    Posts:
    9
    ok I confirmed my bundle has the billboard textures and scriptable objects. I think I am missing the shaders. I will dig into it further.
     
  46. Stingreye

    Stingreye

    Joined:
    Mar 15, 2018
    Posts:
    9
    Ok confirmed, adding shaders to a resources folder fixed it. Thanks again!
     
  47. Stingreye

    Stingreye

    Joined:
    Mar 15, 2018
    Posts:
    9
    Its working but the leaves seem to be having problems. All the leaf cards seem to be losing transparency. Is it possible the alpha is somehow lost when we are doing the asset bundles?

    These are speed trees. Unity 2018.2 Speed Tree 7.


     
  48. taoleaf

    taoleaf

    Joined:
    Jul 15, 2020
    Posts:
    15
    I was excited about GPU Instancer, but I downloaded and tried out the Asteroid tech demo. At 10k & 50k asteroids at 1440p, framerates were practically the same with GPUI off or on (~145fps), in fact it seemed to lag 2-3 fps on average with GPUI on. I was expecting to see a significant difference in performance in the tech demo, yet it seemed exactly the same. What am I missing? If it matters, 8 core i7 @ 5.0ghz / Radeon 55000 xt 8gb.
     
  49. RafaelGuimaraesBarbosa

    RafaelGuimaraesBarbosa

    Joined:
    Dec 14, 2019
    Posts:
    11
    Hello, I saw a comment in the reviews that a user was having problems with the flatkit, can you tell me if they solved the problem, will I be able to use it with FlatKit?

    My project uses FlatKit, I would like to know if it works with it?
     
  50. dragonballydev

    dragonballydev

    Joined:
    Nov 21, 2020
    Posts:
    2
    Need help!

    I get "GPU Instancer only accepts user created prefabs. Please create a prefab from this imported 3d model asset."

    The problem is the imported model has tens of thousands of objects of dozen types: chair, desk, keyboard, mouse etc. They are stored in a hierarchy al over the place.



    update: okay I figured out how to generate variant prefab from the imported model

    but when I add it now I get this:

    "Prefab is a variant. Do you wish to add this variant as prototype or corresponding prefab?"

    I choose prefab and it doesn't get added. I see an information message: "Can´t add component 'MonoBehaviour to workstation because the game object is a generated prefab and can only be modified through an AssetPostprocessor."

    so I try again and this time I choose Variant. It begins to import.

    However, it ends up importing the entire prefab that contains all the individual objects.

    I specifically dragged and dropped a small subset amongst the individual objects like chair, keyboard, etc.

    How can I work with this???
     
    Last edited: Nov 25, 2020
unityunity