Search Unity

[RELEASED] GPU Instancer

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

  1. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have bunch of errors occuring for PS4 platform. I have sent the email about it. Please take a look. I am willing to work with the asset team to fix the compatibility issue for PS4.
     
  2. dragonballydev

    dragonballydev

    Joined:
    Nov 21, 2020
    Posts:
    2
    hi please refund
     
  3. Stingreye

    Stingreye

    Joined:
    Mar 15, 2018
    Posts:
    9
    I got this to work by creating another prefab by dragging one of the prefabs to the an asset folder. Then using the prefab replace tool on the gpu menu to replace the old prefabs with this new prefab. Then when I added it to the prefab manager all the instance counts made sense. Not sure if this is the correct way to do it or not but it worked for me.
     
  4. gewl

    gewl

    Joined:
    May 19, 2016
    Posts:
    95
    Hey, this tool looks incredible! Is it currently compatible with MicroSplat? I saw some discussion about it in here a few months ago, but wasn't sure what the conclusion was.

    I'm on URP and 2019.4.15, if it matters.
     
  5. devpros

    devpros

    Joined:
    Jan 26, 2017
    Posts:
    4
    Greetings, I seldom ask for guidance, so i would start by saying, thank you for this wonderful piece of technology (for lack of better words), that you provided to our world of Unity :p.

    We got a large project on our hands that was simply made possible by gpuinstaner, no need to explain, you guys know it.

    One of our biggest issues comes from frustrum culling at this point. I will try to be very specific:
    - URP Single Pass VR
    - Prefab Instancer
    - 400 to 600 draw distance

    The issue:
    - ritgh eye on Ocullus (and Vive, so it's not hardware related) will catch frustum culling too early. Now this will sound weird, but if we set the frustrum culling from the scriptable objects to something like 90 the problem goes away, but the performance impact is dramatic. We experienced with values ranging from 0 to whatnot up to 90 where it calms down.
    We wre wondering if you could provide some insight to maybe why this would happen, or if maybe is related to LOD, or simply the calculation of the bounds are not taking into account the prefabs scale? I will have to mention that we are using a 0.25f -0.50f scale for prefabs and a 4x scale for the scene parent as we are using dungeon architect to generate the scene environment. I hope this does not set you off on the wrong direction to ivestigate...
    I can provide builds obviously, but screenshots will serve no purpose since we're talking about the right eye...
     
    Last edited: Nov 29, 2020
  6. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    259
    I'm having an issue almost exactly like this, and it seems to be related to shadows. I am using a no GameObjects setup with a compute shader, and I go from over 120fps to under 3fps if I enable shadows. If I switch to the scene view and pull the camera away from the game camera position, the framerate goes back to somewhat normal, which leads me to believe it's caused by some huge overdraw related to the shadows.

    Edit:
    More specifically, it seems to be related to the billboard shadows. I am using Amplify impostors and I don't get any shadows at all from the billboards, however they do affect performance enormously when enabled. It's like all billboards are drawn at the center of the camera for the shadow depth pass.
     
    Last edited: Nov 29, 2020
  7. devpros

    devpros

    Joined:
    Jan 26, 2017
    Posts:
    4
    UPDATE:
    As a temporary workaround we found that modificatying your Culling.compute shader by adding a % of the bounding box as an offset, instead of just adding the offset as a pure float, solves the issue, but I am not sure if this shoud be done so.
    Below also 2 screenshots on the occlusion mesh after the change in Culling.compute with 0f as offset and then with 0.3f (basically +30% to the bounding box).
     

    Attached Files:

  8. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi there,
    it looks like you have created your camera as a prefab at runtime? In any case, please check if the prefab has a "GPUInstancerHiZOcclusionGenerator" component on it - and if it does, remove it.

    Looks like the shader variant collection isn't getting in the build - and in this case your alpha cut off variant isn't being included specifically. You can make sure the GPUInstancer/Resources/Settings/GPUIShaderVariantColletion file also gets in your build.

    It looks like your graphics card is capped at your monitor's refresh rate - which is probably 144 Hz.

    We have not tested GPUI with FlatKit shaders. The known shader limitations for GPUI can be found here. But other than that, the shader basically need to support procedural instancing. GPUI can auto set-up most shaders, but this shader would likely require an integration from the shader developer's side depending on its features.

    Yes, GPUI works on user created prefabs. You can use the provided prefab tools and read up on using GPUI with Nested Prefabs.

    Hi there and thanks!

    Microsplat's terrain features would work since GPUI does not get involved with the terrain layers. However, terrain blending features might not work out of the box if they require a per-object/instance script on them.

    Hi There, and thank you for your kind words!

    GPUI optionally can test culling for either both VR eyes or only for the left eye. It might be the case that you are using the latter - which can be changed from GPU Instancer Preferences for VR.

    If you see shadows on top of the camera, it would generally mean that the shadow pass of the shader is not setup with GPUI and is not being instanced correctly.

    Please also make sure you are using Shadows with Original Shader option, which would be required for shadows with imposters.
     
  9. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    259
    This turned out to be the case and was an easy fix, thanks for the reply!
     
    LouskRad likes this.
  10. Stingreye

    Stingreye

    Joined:
    Mar 15, 2018
    Posts:
    9
    added the folder the resources unity folder to force include it...... still not working. Sent you an email with what we are doing.
     
  11. RIPANN

    RIPANN

    Joined:
    Aug 9, 2017
    Posts:
    9
    Hello.
    I am getting this error while playing the scene using GPUI.
    So this error comes up and stops the game from playing in editor. But if I stop and play again then this does not show up. But again it comes after sometime when I press play.
    Can you please tell me the reason and solution for it ? Thanks!
    upload_2020-12-2_23-56-43.png
     
  12. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    210
    When adding a prefab to the prefabManager that has the mesh renderer as child of the prefab object, on play it gives the "no mesh renderer" error. Any clue?

    The error:

    Can't create renderer(s): no MeshRenderers found in the reference GameObject <MyPrefab> or any of its children
    UnityEngine.Debug:LogError(Object)
    GPUInstancer.GPUInstancerRuntimeData:CreateRenderersFromMeshRenderers(Int32, GPUInstancerPrototype) (at Assets/GPUInstancer/Scripts/Core/DataModel/GPUInstancerRuntimeData.cs:350)

    And yes, it has an SkinnedMesh Renderer. Aren't those supported?

    Any plans to ever support Animancer for the Crowd extension?

    @LouskRad ?
     
    Last edited: Dec 7, 2020
  13. Stingreye

    Stingreye

    Joined:
    Mar 15, 2018
    Posts:
    9
    Ok, we have it working. Need to work through the steps and verify what did it and I will post steps. It did involve shader varient as suggested.
     
  14. RIPANN

    RIPANN

    Joined:
    Aug 9, 2017
    Posts:
    9
    I think, this error is due to some Unity bug.
    Thankfully, by accident I found this temporary resolution.
    Disabling the "Enter Play Mode Options(Experimental)" in Project Settings does not throw this error.
     
    LouskRad likes this.
  15. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    Hi i am curious if GPUI can work in "no gameobject" mode, without prefabs?
    As we don't have any prefabs, and objects are constructed on runtime, meshes are loaded from disk.
     
  16. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    119
    Working great for instanced prefabs. The terrain details are taking 3-5 or so seconds to appear when I start my game. Any insight as how to resolve?
     
  17. LouskRad

    LouskRad

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

    Yes it is possible and is indeed recommended. You can take a look at this wiki article for further information.

    For information on defining prototypes at runtime, you can use the DefineGameObjectAsPrefabPrototypeAtRuntime API method.

    Depending on your detail amount, the initialization time can vary. You can take a look at the included detail demo scene for an example of listening to an event that fires when the initialization is done.

    Other than that, you can use the Initialize in Threads option of the detail manager (off by default) for potentially increasing the initialization speed (depending on your setup).
     
  18. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi,

    is there a way to get LOD cross fade on HDRP?

    The Cross Fade is working when i use the Vegetation Engine Speed Tree 8 Shaders who are GPU Instancer compatible.
    After GPU Instancing with the PRefab Manager cross fade is not available anymore.
     
  19. henriquebg

    henriquebg

    Joined:
    Jan 8, 2020
    Posts:
    1
    Hello there!

    I have a question about which method would be more optimised.
    I have a bookshelf filled with books. Each book is a child of bookshelf GameObject (none of them are prefabs). I turned the bookshelf a prefab.
    Would it be more optimised if I remove the books from bookshelf, turn them into prefabs and add each prefab book to GPU Instancer or should I keep them as a child of bookshelf prefab (but the books are not prefab) and insert this big prefab on GPU Instancer?
    Another question: are you planning to add Billboard on HDRP?
    Thank you for your time!
     
  20. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    210
    Any workaround for crowd extension to get animations from scriptable object/manually to bake them instead of animator controller? I use Animancer and not mechanim
     
  21. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    variation.gif
    Hi I have a group of cubes, all of them have the same prefabPrototype and same shader but different color variation in several materials.
    Is it possible to make PrefabManager remember every instance's own color variation? (just like keeping scale & position infomation).
    In demos I only find out how to set random color for runtime instantiated instance by
    DefinePrototypeVariationBuffer() and AddVariation().
    I tried ColorVariationShader_GPUI.shader and also tried shadergraph shader with GPUI Float4 Variation subgraph.
    The Cubes just turned black.:(
    However how could I register existing prefabs' color into StructuredBuffer and find them back under play mode.
    Thanks.
     
    Last edited: Dec 12, 2020
  22. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    I do not know the specifics of Vegetation Engine. However, GPUI currently does not support cross-fading in HDRP. The reason being Unity have changed their implementation of the cross-fading system. As of now, there are technical limitations that prevent us to override this new version and implement a generic cross-fading solution. I can only say that we can do this implementation if and when Unity changes the way they have implemented and limited our access to customizing the cross-fading system.

    Hi there,
    Adding the Book as a prototype would be the way to go. You can take a look at this wiki article for further information.

    Crowd Animations does not support the Animancer asset (or any other solution that replaces the Mecanim).

    Hi there.
    The color variation demo in the package works with random colors.
    If you want to use predefined colors instead of random ones, you can use your own array elements (instead of the Random.ColorHSV()) during the for loop in that example.

    That is, there is not a generic solution for this that would work out of the box form the inspector and it requires you to write your own script to use this feature.
     
  23. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    Thanks for your response! I can understand your explanation.
    However I'v no idea how to get each instance's id before game start, how to save the then?
    It looks like variation infomation should be put into an Array by DefineAndAddVariationFromArray()? If color variations are defined in an array, how to know the right order?
    If they should be id-color key-value pair information(dictionary or something else), then they should be written into which place by which file format so that StructuredBuffer<float4> gpuiFloat4Variation could get them properly?
    I would greatly appreciate it if you could give me some advice .:) Thanks again!
     
    Last edited: Dec 19, 2020
  24. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi,

    I could not work on my previous problem until now, since I wanted to construct some of the important game mechanics first. I am now at a point to generate grass prefabs by using HDRP foliage shader of GPU Instancer and prefab manager. Also, I am using same prefab manager to generate other foliage prefab models like custom plants and also stones and rocks. However grass is somehow problematic. Here is how (sorry for the long explanation but it might be needed as my workflow is not standard):

    First of all, my game scene is loaded and generated at runtime by another scene almost entirely procedurally. I am using the addressable system here and have no other options because of well-known Unity's 4 gb resources folder issue. I have no option to define prefab prototypes on editor. Actually, I might have one, but I prefer this way to go with to be safe. In that loaded scene, I have 5 planets and one prefab manager on each planet. When generating foliage, I use the API and assign the prototype and then instance the prefab. For this, I wrote separate coroutines to be sure that related prototype is created before the instancing operation. Compared to my previous code, this one works well.

    If you perform add and remove on the same prefab on the same prefab manager the system deletes the generated scriptable object under GPUInstancer folders. Then, scripts complain about not finding the prototype. In my situation, I found a workaround for this. I put my planet on another scene and create prototypes on its prefab manager. Finally, I delete the planet game object. Then, the scriptable object remains under the GPU Instancer folders and I can successfully instance the prefabs. One little issue in this case is the attached GPUInstancerPrefabRuntimeHandler script. This was not designed to hold until it finds a prefab manager in the system, and when it can not find it does not instance the prefab. I added another coroutine here for this. Then, everything worked like a charm. I have every each of plants and rocks instanced. Great!

    However, when I try grass prefab in the same workflow, I get an unpositioned and floating instance around the camera, but noting else. The same workflow, only the shaders are different. And I haven't touched existing GPU Instancer/Foliage HDRP shader. I have 2 questions:

    1- What might be the problem with grass prefab? Deleting and re-making it did not help. In the meantime, all other instancings work well for other prefabs using regular HDRP shaders.
    2- Is prefab prototype data attached to a specific prefab manager, by id or a similar technique, so that prototypes are valid for only the prefab manager they are produced at? If this is the case I might need a single prefab manager in the scene. However, in that case, count for foliage prototype of planet 1, for example, will be 0 while we are on planet 2 (and I will have 10s of objects on each planet). I preferred this design to avoid such case that may cause performance issues - just my cautious thinking, I don't know if it is safe or not.

    Please, note that I received a very much appreciated wiki link previously when I asked this question. I looked at it. That does not provide an answer to my problem. There might be a very simple solution here that I can not see since I am not the person who wrote the asset. Because, regular HDRP shaders are working in this workflow. So, I appreciate any help. Thanks.
     
    Last edited: Dec 15, 2020
  25. matt1101

    matt1101

    Joined:
    Mar 10, 2017
    Posts:
    38
    Hi, my setpass calls has increased by a lot and can't seem to find a solution. What setting do I have to change?
     
  26. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    755
    I just upgraded to 2020.2, HDRP 10.2, and it fixed my 2020.1.7 woes, mostly.

    Edit: Got the LOD to work. Since I was using specific camera, GPUI was still using the first camera in the scene to determine LOD. Once I set it to "auto detect" it selected my second camera when necessary, and the LOD's started working. I bet the API has a manual camera selector.

    EDIT: This error went away, not sure why, so hiding in spoiler tag
    Code (csharp):
    1.  
    2. Graphics.CopyTexture called for entire mipmaps with different memory size (source (R32 SFloat) is 5475520 bytes and destination (Depth) is 2737760 bytes)
    3. UnityEngine.Graphics:CopyTexture (UnityEngine.Texture,int,int,UnityEngine.Texture,int,int)
    4. GPUInstancer.GPUInstancerHiZOcclusionGenerator:UpdateTextureWithComputeShader (int) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:273)
    5. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRendering (UnityEngine.Camera) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:260)
    6. GPUInstancer.GPUInstancerHiZOcclusionGenerator:OnEndCameraRenderingSRP (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at Assets/GPUInstancer/Scripts/GPUInstancerHiZOcclusionGenerator.cs:212)
    7. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    8.  
    I read I just have to adjust a setting somewhere, but wondering if I should wait on GPUI to fix it, since it does not appear to be game breaking.


    I don't care much about this next error, but in the prefab runtime instancing demo, the ship and "dust cloud" are pink, here is the error:
    Code (csharp):
    1.  
    2. Shader error in 'GPUInstancer/AsteroidHaze': undeclared identifier '_BlendMode' at /topsekritpojekt/201218_topsekritpojekt_GPUI/Library/PackageCache/com.unity.render-pipelines.high-definition@10.2.2/Runtime/Material/Material.hlsl(51) (on d3d11)
    3.  
    4. Compiling Fragment program with _SURFACE_TYPE_TRANSPARENT _BLENDMODE_ALPHA
    5. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
    6. Disabled keywords: DEBUG_DISPLAY _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY _BILLBOARDFACECAMPOS_ON UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30
    At least now all the asteroids are GPUinstanced and running well (unlike in 2020.1.7, which I
    edited out of this post after upgrading to 2020.2).
     
    Last edited: Dec 18, 2020
  27. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    119
    Does this apply to PlayStation development? Does GPU Instancer work for PS4/5 dev?
     
  28. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    DefineAndAddVariationFromArray() is mainly designed for use with a no-gameobject workflow where you would normally already have your instances in an array.

    For instance based access, you could use the AddVariation<T> and UpdateVariation<T> API methods, which simply take the prefab instance as parameter.

    Hi there,
    and thank you for the detailed explanation.

    Given you are using the GPUI foliage shader, it eliminates the issue being caused by the shader (assuming it has not been modified). I would then, suggest to first make sure the problem is indeed related to GPUI by running the same scene without GPUI and seeing the instances are not on the camera.

    If the problem goes away without GPUI active, then firstly please check if you are having any errors/warnings in the console window that might be related to GPUI. If so please tell us the error. If there are no errors though, and if you have made sure the issue is indeed related to GPUI, I must ask you to send us a sample project where we can see this so that we can investigate the issue.

    As for the prefab prototypes in the managers, the prototypes themselves are scriptable objects (the prototype data) and the managers hold references to these scriptable objects. As such, the prototypes can be used in different managers, but a prototype's setting changes in one manager would of course apply to the same prototype in other managers since they are one and the same.

    Please also note that 0 instance prototypes are ignored by the managers, so it wouldn't effect performance.

    Hi there,
    You can get more information on the actual draw calls made by a manager during runtime in the inspector of that manager (in the "Registered Instances" section).

    Please also make sure that you are using GPUI as intended with prefabs that have a high number of instances in your scenes. For more information please take a look at the Best Practices wiki.

    Hi there,
    We haven't tested GPUI with the new versions (10) of HDRP and URP yet. We will make the required tests and do any necessary updates regarding HDRP and URP 10 in the week following weeks.


    GPUI supports PS4/5. The restriction mentioned it the comment you quoted applies strictly speaking to OpenGL 2.0 and 3.0 where compute shaders are not supported (for mobile platforms, OpenGL ES provides support for them in 3.1). Playstation's own API does not have such a restriction.
     
  29. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    755
    I didn't think you had, since it just came out. It's working pretty well for me right now, just pointing out some minor flaws.
     
    Last edited: Dec 23, 2020
  30. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    I try to use DefinePrototypeVariationBuffer() for defining color variation before game starts, however AddVariation<T> and UpdateVariation<T> doesn't work under editor. Because instance's instancerID is null under editor so that I can't use UpdateVariationData() to restore the color.
    Is it possible to make prefabInstance.instancerID PrefabVariationData.dataArray work under editor? Or maybe there is another better approach?Thanks.
     
  31. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    hi - i have around 70 terrains in my scene so the map is very large. When I enable the instancer components in the scene, the scenes fps goes down to around 5fps. When i disable the components its fine. When I run the game its also fine (when I first enable the components then run the game). Any idea why this would be ?
     
  32. ChocoFries

    ChocoFries

    Joined:
    Jun 25, 2018
    Posts:
    1
    Hi, I've been getting the below error when I added my grass prefab to the GPUI Prefab Manager, can't figure out how to resolve it. Any help would be awesome. Thanks!

    NullReferenceException: Object reference not set to an instance of an object
    GPUInstancer.GPUInstancerUtility.DispatchCSInstancedCameraCalculation[T] (UnityEngine.ComputeShader cameraComputeShader, System.Int32[] cameraComputeKernelIDs, T runtimeData, GPUInstancer.GPUInstancerCameraData cameraData, System.Boolean isManagerFrustumCulling, System.Boolean isManagerOcclusionCulling, System.Boolean isInitial) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:481)
    GPUInstancer.GPUInstancerUtility.UpdateGPUBuffer[T] (UnityEngine.ComputeShader cameraComputeShader, System.Int32[] cameraComputeKernelIDs, UnityEngine.ComputeShader visibilityComputeShader, System.Int32[] instanceVisibilityComputeKernelIDs, T runtimeData, GPUInstancer.GPUInstancerCameraData cameraData, System.Boolean isManagerFrustumCulling, System.Boolean isManagerOcclusionCulling, System.Boolean showRenderedAmount, System.Boolean isInitial) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:351)
    GPUInstancer.GPUInstancerUtility.UpdateGPUBuffers[T] (UnityEngine.ComputeShader cameraComputeShader, System.Int32[] cameraComputeKernelIDs, UnityEngine.ComputeShader visibilityComputeShader, System.Int32[] instanceVisibilityComputeKernelIDs, System.Collections.Generic.List`1[T] runtimeDataList, GPUInstancer.GPUInstancerCameraData cameraData, System.Boolean isManagerFrustumCulling, System.Boolean isManagerOcclusionCulling, System.Boolean showRenderedAmount, System.Boolean isInitial) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:319)
    GPUInstancer.GPUInstancerManager.UpdateBuffers (GPUInstancer.GPUInstancerCameraData renderingCameraData) (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:556)
    GPUInstancer.GPUInstancerManager.LateUpdate () (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:265)
     
  33. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    Hi. Hope you can give me a few pointers. I want to double check if the GUI Late Update call would be considered normal for a large product with lost of different types of items. Runs between 2-4+ milliseconds. Right now have 4 different detail managers for 4 different terrains in the scene with 4-5 different types of grasses. Everything else is done via the Prefab manager ie trees etc. Will show that below. Basically just looking to see if this is in the ball park or if it looks like I need to dig deeper for ways to reduce this load if possible. I am including a list of most of the prefabs with instanced counts. I know the CPU cost for each different type of object can cause a hit based on the docs so perhaps I am including to many lower instanced objects. Any pointers or advice on what could lower the CPU cost?

    Thanks and great product.


    upload_2020-12-23_14-4-5.png

    upload_2020-12-23_14-7-10.png

    upload_2020-12-23_14-7-42.png

    upload_2020-12-23_14-8-21.png

    upload_2020-12-23_14-9-0.png
     
  34. MinoanStudios

    MinoanStudios

    Joined:
    Dec 10, 2017
    Posts:
    11
    Hello!

    Using 1.4.3 with URP 2020.2, I am succesfully instantiating my trees at runtime with the prefab manager and adding/updating color variations of stems and leaves separately using vertex colors and a custom buffer node in Shader Graph. However, I have come across three issues, both when using auto update mode and when I enable/disable manually:

    1. The instances does not react to any changes in my material properties and seems locked to whatever state they were in when instantiated or from my latest variation update. For example, I want to be able to do things like changing a global wind direction using Shader.SetGlobalVector() and also update them all to a solid color (see image where I'm trying to blend colors with a float). Is this not supposed to be working? Maybe I'm being dumb somewhere. Do I have to do this type of update through material variations on each instance even though I want the same change applied on all instances?

    image1.png

    2. I get a null reference exception on prefabInstance in GPUInstancerPrefabManager.DefinePrototypeVariationBuffer() for all my prefab prototypes. If I do a null check and just ignore it (it is never not null for me), everything still works as far as I can tell. I did not have this issue with the same exact code yesterday so maybe its some unity script execution order thing but even though I have tried to test for that, I still can't get rid of it.

    image2.png

    3. Is there a preferred way of reregistering an instance list that grows or should one use AddPrefabInstance() even though adding many at a time? What if i have 1000 instances and then want to add 1000 more? Should I Clear() or Unregister() and then Register() again? Do I have to Initialize() both after Unregister() and Register() or is one time at the end fine? I'm trying to avoid having to specify a buffer size in the manager as that makes my variation updates significantly slower and I don't know the desired amounts of each prefab as everything is procedural.

    Thanks and happy holidays!
     

    Attached Files:

    videon likes this.
  35. mixmotion00

    mixmotion00

    Joined:
    Jun 15, 2017
    Posts:
    3
    Hi, i tried to integrate with GAIA Pro. Unfortunately, the fps drop really bad. In mobile it went from 20fps to 3-4fps. I work on built in pipeline, and nothing fancy regarding the setup. Can somebody help me?
     
  36. videon

    videon

    Joined:
    Feb 22, 2015
    Posts:
    10
    Hello there,

    I'm having a similar problem as Ioten regarding color variations with shader graph on Unity 2020.2.
    Using the regular, non shader graph color variation shader, color variations work as described in the GPU Instancer manual, albeit with lighting errors (material remains unaffected in dark scene, see screenshot).

    When using shader graph with the GPU Instancer Setup and GPUI Color Variation nodes, objects appear black.

    I have also tested the shader graph variations demo which came with the plugin, which also does not work (see screenshot 2).

    Edit: I might add that before trying to use the GPUI shader graph modules, I upgraded my project from 2020.1 to 2020.2. GPUI was already in the project at the time of upgrading.
     

    Attached Files:

    Last edited: Dec 27, 2020
  37. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    Hello, bought this asset a little while ago, and finally got round to trying it out! getting good performance increase, however i seem to get a lot of flicker from my grass prefab? please see the gyazo vid : https://i.gyazo.com/86b9ccdbe13755b40abc14051e0d93ff.mp4
    Is there anything i can do to fix this? thanks
     
  38. D1234567890

    D1234567890

    Joined:
    Aug 11, 2019
    Posts:
    65
    Are there any plans to make this work as a package manager package? I tried setting it up as an embedded package for URP but it has pathing issues. Thank you.
     
  39. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Hi, we've been using GPU Instancer for two years, works great. Haven't updated it since early 2019. But we just discovered that it somehow stopped working on MacOS recently, at some point between game patches in October and December. The objects using it simply don't render, though the we can tell that they exist in the scene. We're trying to figure out what has gone wrong...in that time, we upgraded from 2019.4.0 to 2019.4.14, and the Mac we use to publish the game went from 10.14 to 10.15. We didn't touch any of the code using GPU Instancer. Any idea what might have gone wrong? (I'm going to try updating to the latest version, but the developer who set this up is long departed and we suspect he made some edits to the code, so updating may have its own risks....)

    And of course, we are releasing a big update in two days, only discovered this now....

    thanks
    Dave
     
  40. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    The reason why that method doesn't work in the editor is because GPUI does not render your prototypes during editor time. That is, InstanceIDs are set during runtime, because instancing starts at Play mode. However, you can use material property blocks to to set the colors in editor time with the same logic. Below you can find an example for this in the attachment (GPUIColorVariationEditorExample.unitypackage).


    Hi there,
    I'm not sure I understand what you mean by "when I first enable the components then run the game" - GPUI components must usually be enabled when the scene starts.

    In any case, you can check the profiler to see what is causing the issue, and if that doesn't help you can send us that profiler data so we can investigate.

    Hi there,
    from the error message it looks like you are getting this because you haven't defined the pipeline asses in your Project Settings -> Quality -> Rendering field. This is usually required for Unity as well - but we will add a null check for this in the next update.

    Hi there, and thanks.

    It is normal to have a few ms for the LateUpdate with that many instance prototypes. However, you could (and should) not add the lower instance count prototypes (like some of those with 1 - 10) to the manager at all. For ones with relatively small instance counts (like some of those 21 in your screen) I would say the same if they are not usually in the same camera frustum in your scene.

    (If these instances are on a Tree or Detail managers you might want to remove the low instance prototypes from the terrain and put them on your terrain as game objects - still using the Tree/Detail Manager)

    In general, you can try adding/removing prototypes that you are suspicious are helping and find a sweet-spot.

    As for CPU improvements, other than the usual C# optimizations, my only general suggestion would be to look into ECS and DOTS.


    Hi There, and thanks!

    1) if you are using global properties, it should work. (Non global properties won't; since GPUI uses its own created material and changing material values won't work). You might want to make sure you are using a property in shaderGraph with its "exposed" property turned off (to use it with Shader.SetGlobal...) and that you are actualy using the reference name (and not the shadergraph name) of the variable. Other than that, you are not using the "GPUI Float4 Variation" node so I can't comment on your custom one. (You could use the float4 node with a color buffer, by the way).

    2) That looks like prefabInstance is null? If that's the case, it shouldn't be null, so a null check isn't helping you there. Are you clicking the "Register Instances in Scene" Button in the manager after you add/remove instances from your scene during the editor time? If you're adding/removing your instances at runtime, you can either use the Auto. add/remove feature or use the AddPrefabInstance() and RemovePrefabInstance() APIs.

    3) Using the AddPrefabInstance() API would be the preferred way, since it handles resizing the variation buffer automatically as well. After Adding/removing, using the UpdateVariation API would be enough.


    Hi there,
    we have tested the scene in Unity 2020.2 and it is working out of the box. You can try re-importing GPUI (and re-export the variation demo) and see if it helps. If it's still not working, there might be an issue with your project update so I would recommend switching your assets to a clean Unity 2020.2.

    As for the lighting, I can't comment on that but if you send us a sample showing this, we can investigate.

    Hi there,
    it looks like an issue with the occlusion culling feature (which you can verify by turning off occlusion culling in your manager). If it is so, the issue can be related to something interfering with the depth texture. You can debug the depth texture by enabling the debugger on your camera during runtime. If that doesn't help, you can send us a sample project showing the issue and we can investigate it.

    I'm afraid Unity doesn't allow for asset store assets to deploy as packages at the moment.

    Hi there,
    We haven't seen any issues with our MacOS test. If you can send us more details (especially on the potential changes to the codebase you mentioned) we might be able to help you.
     

    Attached Files:

    zIyaGtVm, MinoanStudios and videon like this.
  41. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    @LouskRad Thanks for the quick reply.

    >>> As for CPU improvements, other than the usual C# optimizations, my only general suggestion would be to look into ECS and DOTS.

    Regarding this is there a way you could suggest using DOTS and Jobs etc with GPUI API in a way to further reduce GPUIs cpu overhead in lateupdate?

    For instance using no game objects workflow in jobs perhaps. I could give it a go but wondering if you think there would be any benefit. Thanks again.

    Instead of update do the update visibility in a job etc.

    1. private void Update()
      {
      // change the data of the array
      for (int i = 0; i < _matrix4x4Array.Length; i++)
      _matrix4x4Array = Matrix4x4.TRS(Random.insideUnitSphere * 15, Quaternion.identity, Vector3.one);
      // update buffers
      GPUInstancerAPI.UpdateVisibilityBufferWithMatrix4x4Array(prefabManager, prefab.prefabPrototype, _matrix4x4Array);
      }
     
  42. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    Oh another thought. Is GPUI cpu overhead impacted at all by settings like Shadow, Billboard, LOD, tri count of prefabs etc or is just number and variety of instances? I could see how all the above would impact rendering time but specifically talking about CPU processing of GPUI in lateupdate etc.

    Thanks again for keeping on this project.
     
  43. D1234567890

    D1234567890

    Joined:
    Aug 11, 2019
    Posts:
    65
    Oh, of course. I mean to make it compatible for those who are willing to convert them. The only issue with this one I believe is that the relative paths don't seem to work when used as a package. It also couldn't find the Lit_GPUI shader it creates.
     
  44. notSCOPY

    notSCOPY

    Joined:
    Dec 21, 2019
    Posts:
    3
    Would this work with photon?
     
  45. animal531

    animal531

    Joined:
    Aug 26, 2014
    Posts:
    25
    Hi,

    Great product, but recently I started experiencing a bit of a problem. On trying to enter playmode GPUI would complain about kernels being missing (as per the screenshot). Trying a 2nd time it would complain about different kernels, and then for the 3rd try about another kernel.

    However after that it would enter playmode and work perfectly fine (for a time, then it would repeat the cycle of 4 restarts to get it working again).

    I've tried clearing the shader bindings/variants and removing/rebuilding the GPUI Manager, removing assets, re-installing GPUI etc. It will work fine for a bit but then the error just keeps coming back.

    Thanks for the help!
     

    Attached Files:

  46. animal531

    animal531

    Joined:
    Aug 26, 2014
    Posts:
    25
    Just an update. I had Editor -> Enter Play Mode -> Reload Scene enabled.
    Disabling that causes it to fail every time (but if I close down Unity, restart etc. then eventually it works again)
     
    Last edited: Dec 29, 2020
  47. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    Thanks for your great example! I know how to keep the color now and also make a shadergraphversion.
    Only a little problem with the color( Cubes' color looks different after entering play mode).
    You can see the difference between editor and runtime buffer through the gif below.
    color diff.gif
    I tried changing color space, also removed the lights, still can't find why color's value changed.
    Thanks!
     

    Attached Files:

  48. aldha

    aldha

    Joined:
    Dec 22, 2018
    Posts:
    1
  49. r137

    r137

    Joined:
    Mar 12, 2018
    Posts:
    47
    Hi, I am sorry if this is already asked but I couldn't find any answers.

    On requirements it says:
    - OpenGL ES 3.1 (Android 8.0 Oreo or later)

    but OpenGL ES 3.1 supported on Android 5 according to this link. I couldn't understand why is Android 8.0 is a requirement.
    https://developer.android.com/guide/topics/graphics/opengl
    • OpenGL ES 3.1 - This API specification is supported by Android 5.0 (API level 21) and higher.
    Do I need to target Android 8.0 if I want to use this asset or API level 21 is sufficient?
     
  50. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Yes, using no game object workflow would be the way to go.

    However, you should keep in mind that GPUI is all about rendering and isn't doing much other than dispatching Compute Shaders and making draw calls in the CPU. As such, it's already intended to take the load from the CPU (as such its operations are not heavy on the CPU). The overhead you see in the LateUpdate is therefore mainly coming from Compute Shader dispatches and draw calls - which are internal Unity wrappers and can't be further optimized.

    Thus, using dots in your project would not be to further optimize GPUI, but instead, it would optimize other parts of your project - like to provide the matrix array faster for GPUI to use. So using DOTS would be a solution for CPU while GPUI works for rendering in the GPU. They would work side by side. I hope this makes sense.

    In any case, if you want to decrease the time GPUI's operations in the LateUpdate take, the only way to go about it for your case would be to use a smaller amount of prototypes.

    We haven't tested photon with GPUI, but since GPUI is purely a (client side) rendering solution, I don't see a potential incompatibility with any networking solutions.

    Hi there, and thanks!

    It looks like an import problem, assuming your target platform meets GPUI's requirements (basically a platform where compute shaders are supported). But having said that, please also make sure that there isn't a code and/or 3rd party asset in your project that interferes with Unity's asset import pipeline.

    It is color space. The color difference would go away if you change the following line in your code:

    GPUInstancerAPI.UpdateVariation(prefabManager, GetComponent<GPUInstancerPrefab>(), bufferName, color.linear);

    Hi There,
    GPUI does not support baked lights. You can see all the lighting limitations in this wiki page.

    However, having said that, you can use the GPUI foliage shader on your grass and increase the "ambient occlusion" property of it - or otherwise achieve a similar darkened effect in your shader. Using an SSAO effect would be another option.

    Hi there,

    Android 8.0 is not a hard requirement, but it limits the potential target device GPUs to a certain average quality. Since GPUI works on the GPU, the performance gain that comes from it scales with the power of the GPU that it runs on.

    Also, some earlier android GPUs that support GLES 3.1 (and thus compute shaders) impose various limitations on GPU usage, such as limiting the usable buffer amounts, etc.

    Thus, the soft requirement on Android 8.0 is intended to bring the average GPU expectancy above a certain quality - but nonetheless, it is the lowest Android version GPUI officially supports.
     
    zIyaGtVm likes this.