Search Unity

[RELEASED] GPU Instancer

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

  1. escCalibahr

    escCalibahr

    Joined:
    Feb 3, 2020
    Posts:
    3
    For some reason the asteroid demo only gives 10 fps with GPU Instancer on and even less with it off. I've run the demo at 60 fps before. Not sure if its because I updated GPUI or if it's because I'm using unity 2021.1.5f1. Build FPS is the same as editor. For my game the fps difference is like nothing now. It used to be a huge difference. The screenshots are of the prefab manager enabled vs enabled. Untitled.png Untitled2.png
     
    Last edited: May 9, 2021
  2. Spudly1701

    Spudly1701

    Joined:
    Aug 25, 2013
    Posts:
    36
    I could be very wrong, but you seem to have a lot of shadow caster objects (ignore this, I was looking at the wrong image. lol.). I'd double check to see if they all need to cast shadows and turn off shadows for those objects if not. Only other thing I can think of is have you enabled GPU Instancing on your materials? It's a little baffling from the screenshots as to why the fps is struggling. I have a bit of a similar setup (all internal, no external light environment), with a similar Ryzen5 processor and a 1050Ti(4gb), with a lot more tri's than you have and getting around the same fps.
     
  3. Spudly1701

    Spudly1701

    Joined:
    Aug 25, 2013
    Posts:
    36
    Hmm, okay well it seems like I'm having a similar problem. My game is 'underwater', if I spawn in 200 coral prefabs 'normally' I get around 40-50 fps. If I swap that out for a GPUI version (200 of the same prefabs using GPUI) I get 7fps. Umm. wtf? lol.
     
  4. Da_Neel

    Da_Neel

    Joined:
    Dec 29, 2013
    Posts:
    15
    Hi there. What will be the best practice for using the GPU Instancer with a level streamer system? In my game there are many chunks of level wich I spawn and delete around the player as he moves. I use Unity Adressables for loading and spawning chunk assets.
     
  5. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    121
    Similarly to this, I use Gaia world streaming where parts of terrain get loaded/unloaded, which unfortunately also unloads the terrains from the GPU detail managers. I looked at the Gaia integration on the wiki, which seems to be very outdated and there no longer is anything about GPU Instancer under the Gaia extensions tab.
    I was wondering how I'd set this up correctly so the managers would keep being tied to the terrain.

    Also of course, when trying to use the prefab manager etc, you also get the cross reference scene error when trying to use world streaming.

    I'll admit I saw Gaia Integration was advertised.. so I was hoping I didn't have to do any programming myself to actually get things to work.
     
    Last edited: May 9, 2021
  6. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    I have a problem while using both GPUI and MTree. Because trees made by Mtree is a total prefab, what should I do to make leaf or bark as Prefab Prototypes? Thanks
     
  7. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    So having an issue with memory and using GPUI Detail Manager. We wired up four of them to 4 different terrain objects. We have a handful of different grasses 6 or so and the terrain sizes are all 512x512x600, 64 per patch and resolution of 2048.

    This causes GPUI to add over a 1G of memory. We see that as a jump to GC as well as just straight up in task manager. This is using a stand along build but you can also see it jump in editor as well.

    My guess is something related to whatever system you using to create cells for detail manager to use to remove, add, cull etc. Is this normal? Some sort of bug. Something we can optimize?

    Right now for us it would seem like a better solution would just be to use GPUI directly and have a cross hatched grass prefab that we place vs using the Detail Manager especially for that kind of hit.

    Thanks

    Jason
     
  8. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    ChangeMaterial will change the material to all the instances of a specific prototype, but what if we want to create at run time a new prototype as copy of the original one, with a new material without affecting the already created prototypes?

    In other word, is there a way to generate a new prototype from an existing one without involving gameobjects?

    Use case:

    we can place blocks of various shape and paint material at run time. The already placed blocks must not change and a new prototype with a new material must be generated if wasn't previously generated. We would like to achieve this without holding to the original gameobjects.

    a way to clone existing prototypes would be a solution for us.
     
    Last edited: May 12, 2021
  9. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    HI @LouskRad !!! I have installed the latest version of GPU Instancer, after deleting the cache to avoid problems with the PackageManager ... in Unity 2021.2.0a16 and HDRP 12.

    The fact is that everything seems to work fine, but when I press play I always get this error from the console:
    ErrorGPUI.jpg

    I take this opportunity to ask you something else that we were seeing last year ... Is the incompatibility problem with the PlanarReflection and the GPU Instancer culling fixed in this latest version of GPUI?

    How can I solve that? Greetings
     
  10. MiniBeatBoy

    MiniBeatBoy

    Joined:
    Sep 23, 2013
    Posts:
    15
    Hi @LouskRad,

    I purchased the GPU Intancer few days ago, but I haven't been able to make it work.

    I tried it on a new project on Unity 2019.4.8f1 with URP and it just doesn't compile.

    I got these errors:
    upload_2021-5-14_17-32-28.png

    This is the first error:
    Shader error in 'CSSkinnedMeshBake.compute': failed to open source file: './../../../GPUInstancer/Resources/Compute/Include/PlatformDefines.compute' at kernel CSAnimationTextureToBuffer at CSSkinnedMeshBake.compute(2) (on d3d11)

    Could you please guide me through the workaround?

    Has anyone here had the same issue?
     
  11. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Please check if you are having any warning/error messages in the console. If you are not having any, please check the profiler to see what is using up most of the resources when using GPUI. If both of these do not show the culprit, please follow this support guide to send us a support request.

    Hi there,

    You can use a single Prefab Manager and define all your prototypes (in all the levels you will be using them in) on it. You can set this manager to Enable Runtime Modifications, and specifically enable the Auto. Add/Remove Instances option on it. This way, GPUI would handle all your instances as they come and go.

    As for the Detail Manager, when you are streaming in your terrains, you can add the manager on the terrain object for it to initialize itself with the terrain.

    GPUI does not offer an integration for the Gaia PRO; specifically with its terrain streaming features. The integration was made for Gaia, and looks like some updates between both assets caused the menu buttons to disappear under the GX menu. We will look into this for the next update; however, you can still access the same menu items from under the original Tools/GPU Instancer menu.

    I'm not sure I understand what you mean by "Total Prefab", but if you mean it's a model prefab, you can take a look at this wiki article to see how you can create user created prefabs out of it. On the other hand, if you mean Nested prefabs, you can take a look at this article for more information on using them with GPUI.

    Hi Jason,

    Since GPUI doesn't control the placement of the detail objects, it has to request it from the terrain itself. This causes extra memory imprint scaling with the detail resolution, etc. on the terrain.

    You can get a more optimized result in terms of memory by creating a custom solution using a limited area to store a lower amount of details to save on memory data storage, and handle the rendering inside this area using GPUI's API (you would potentially want to use a no game object workflow with this). You can then modify this area based on your camera movement to load/unload your instances.

    Hi Sebastiano,

    you can use the following method to clone a prototype at runtime. We will add this to the API in the next update:

    Code (CSharp):
    1. public static GPUInstancerPrefabPrototype ClonePrototypeAtRuntime(GPUInstancerPrefabManager prefabManager, GPUInstancerPrefabPrototype originalPrototype)
    2. {
    3.     GPUInstancerPrefabPrototype clone = ScriptableObject.Instantiate(originalPrototype);
    4.     prefabManager.prototypeList.Add(clone);
    5.     GPUInstancerRuntimeData runtimeData = prefabManager.InitializeRuntimeDataForPrefabPrototype(originalPrototype);
    6.     GPUInstancerUtility.InitializeGPUBuffer(runtimeData);
    7.     return clone;
    8. }
    Hi there!

    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. We will take a look at HDRP 12 when it is officially released.

    As for the planar reflection component, it uses (and modifies) the depth texture that GPUI uses for occlusion culling - so there is not much we can do about it.

    Hi there,

    Firstly, please make sure both GPUInstancer and GPUInstancer-CrowdAnimations folders reside under the same parent (by default they are under the Assets folder).

    Second, please select both these folders in the project hierarchy and right click to open the context menu for them. Then choose Reimport to re-import all the files under these folders and see if it helps solve the problem.
     
    sebas77 likes this.
  12. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Hi, I'm testing GPU Instancer on my project running in 2020lts and hdrp 10. So far i have great performances but a couple of problems within the editor. What should be the optimal level design workflow? The main problem with hdrp is that it doesn't have support for terrain detail mesh, so i can't see the detail i paint on terrain until i enable gpui simulation. Also to be able to see the trees i paint on my terrain i can enable draw trees, but always remember to disable the checkbox otherwise the trees will get renderd with the standard system beneath the gpui ones, with terrible performances. Shouldn't gpui be able to automatically disable the terrain original trees when starting it's own rendering?

    Lastly, how should i control things like detail density and tree lod distance at runtime?
    Changing the detail density on the terrain doesn't have effect, is there some method i have to call to reinitialize gpui ?
     
    Last edited: May 16, 2021
  13. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    MTree generates a tree as a single User Created Prefab (In fact inside the tree has root, barks, and many quad leaves), What I'm thinking is make a single leaf quad as a prefab prototypes so that leaves could be instanced while there is a forest (However the leaf quad couldn't be selected and dragged into gpui manager in inspector).
     
  14. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi. I sometimes have some models not rendered at the position but I probably have the colliders there so that player can not walk through the way even though there is nothing visible blocking the way. Any idea what is causing this?
     
  15. wheee09

    wheee09

    Joined:
    May 21, 2018
    Posts:
    68
    Hi,

    I'm rendering meshes with GPUInstancer and I'm noticing that custom forward renderer features don't seem to affect the meshes.

    For example, I'm using a custom renderer feature to always render a mesh on top of everything else by manipulating the depth. It works on non-GPU instanced meshes.

    Is there any known limitation for this?

    Thanks
     
  16. miknios

    miknios

    Joined:
    Sep 12, 2017
    Posts:
    6
    Are Material Variations supported with shaders made in Amplify? I saw a post about added support for Shader Graph, but I'm wondering if it's possible for Amplify too.
     
    XaneFeather likes this.
  17. ysundawa

    ysundawa

    Joined:
    Mar 2, 2020
    Posts:
    33
    Hello...
    I am using GPU Instancer with MapMagic2, and use it to handle OBJECT and TREES only, (no detail,).
    So far ti works perfectly, until lately when I have multiple scene which has multiple MapMagic2 object, GPUI start acting funny, such as :
    1. The instantiated Trees is different from the one should be (Editor mode it shows the correct tree, but runtime it shows different trees)
    2. In some scene, the trees just completely gone .... but in other scene it is there.
    3. Some bushes (object) instantiated extremely big in size, I tried to check/uncheck the random size/height/prefabs size .. but seems like got ignored.

    But nevertheless, in one of the scene, it works perfectly fine... the error only happened in the other 2 scene.

    FYI, My current setup is :
    - MapMagic2 Importer object in separate scene, together with Camera, Directional LIght.
    - MapMagic2 Object in scene 2
    - MapMagic2 Object in scene 3
    - MapMagic2 Object in scene 4

    Scene2, 3, 4 NEVER got loaded together, always only one of them loaded..

    Any feedback appreciated...
     
  18. LouskRad

    LouskRad

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

    GPUI does not turn off the drawing of tree and details on the terrain because it handles them separately. Instead, when using the tree manager, it sets the tree drawing distance to 0 (which effectively is the same as ticking the draw option off). If you are having trees rendered both by GPUI and Unity at the same time during runtime, you might want to check if anything in your project is increasing the tree draw distance during runtime as this should not happen by default.

    As for detail modifications at runtime, you can check both the DetailInstancing and AddModifyTerrainsRuntime demo scene controller scripts for examples. For changing LOD distances at runtime, the API supports changing Bias at runtime. You can use the SetLODBias method for this. If you want to make further individual changes for the LOD values, you can take a look at the internal workings of the SetLODBias method to investigate how you can access GPUI runtime data to do this.

    You can only add (user created) prefabs to a Prefab Manager. If you want to add a leaf quad therefore it has to be a prefab itself. You can use Nested Prefabs for this as I suggested earlier.

    Hi there,

    You can check (a) if any prototype instances are being moved at runtime without their prototypes using the Auto. Update Transform Data option on the manager's prototype settings for them and (b) that any of your prototypes might be using a shader that is not compatible with gpu instancing. If (b) is the case, you can take a look at this wiki article to manually set up your shaders.


    Hi there,

    when doing instance based operations in the custom feature, it might be that the shader you are using there is not set up for GPUI. In most cases, you could use the context menu on this shader to have GPUI auto set it up.

    If that doesn't help, you can send us a sample and we can investigate what exactly is the issue.

    GPUI currently does not have a variations node for ASE.

    ASE does not have out of the box support for structured buffers. But as you said, we found a workaround for shader graph to do this and we will look into if we can come up with a similar workaround for ASE as well.

    It could be that the mapmagic objects of other scenes are loaded on the integration manager that is responsible for the first scene. As mapmagic streams terrains, the integration manager for it was not designed for streaming scenes with different mapmagic objects.

    Nonetheless, we can take a look at what exactly is causing the issue in your case if you can send us a sample project.
     
  19. WeltenbauerRenn

    WeltenbauerRenn

    Joined:
    Jun 20, 2017
    Posts:
    40
    Hi @LouskRad, we are using "The Vegetation Engine" together with GPUI in HDRP 10. By using normal prefabs we get MotionVectors drawn which it not the case with GPUI.

    When using TAA moving trees look blurry even worse with imposter that moves. Is there any chance to add MotionVectors in GPUI?

    Greetings
     
  20. IvanWeeskey

    IvanWeeskey

    Joined:
    Jan 8, 2017
    Posts:
    12
    Grass by details manager looks absolutaly different from what it should be. Dark color, and it looks like all grass is 1 in texture, like another transperant terrain layer above my terrain. Also simulate button in editor do not shows grass, just hides actual native grass.
     
  21. amasinton

    amasinton

    Joined:
    Aug 12, 2006
    Posts:
    138
    Hi @LouskRad , I've had GPUI for about a year now and absolutely love it. It's magic.

    My current project involves a two-camera setup to create a "portal to another time" effect. Camera A only displays objects in the Camera A layer mask and Camera B only displays objects in Camera B. Sometimes both cameras are active at the same time to do a kind of portal overlay effect, and much of the time only one or the other camera is active, depending on which side of the portal the player is on. The point is, there is no main camera in the game.

    GPUI will display all instanced objects to both cameras all of the time, which breaks the "overlapping dimensions" visual concept of the game.

    Multiple cameras with no main camera is not really an ideal situation for GPUI, I know. However I thought I'd ask if there might be a way to work around this limitation? Can I set and change the layer of instanced objects, for example, so that they only render to the appropriate camera? Can I be clever with culling, somehow, to find some way to cull instanced objects that should only render to one camera? Any ideas?

    Thank you for an excellent product and thank you for your advice about my odd game use-case.
     
  22. miknios

    miknios

    Joined:
    Sep 12, 2017
    Posts:
    6
    I've managed to make it work. I couldn't get my head around Amplify node API, so it's really hacky solution, but works :p I will post it later. Thanks for your reply anyway.
     
  23. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    As far as I know, this is a shader issue: HDRP uses MotionVectors from a "MotionVectors" shader pass, so the shader must support MotionVectors, and the shader's MotionVectors pass must be set up for instancing for TAA to work.

    For example, this pass will be auto-generated when writing your shaders with the ShaderGraph. In such cases, GPUI's ShaderGraph node should support MotionVectors and thus TAA. This is why TAA works also with the Lit shader using GPUI.

    I cannot comment on the Vegetation Engine, however, as I am not familiar with their shaders. As this is a shader issue, though, I would suggest asking them.

    We would need a bit more information to identify this issue. If you can follow this support guide and provide us some information on the issue you are facing, we can help you identify the issue.

    Hi there,
    and thank you for your kind words!

    For a multiple camera setup, you can use a manager per camera. The manager would pick up the masks from your camera so you don't need an additional step for masks.

    You can take a look at this article for more information on using multiple cameras.
     
  24. gewl

    gewl

    Joined:
    May 19, 2016
    Posts:
    95
    Hi,

    In the past week or two, I've begun getting the following errors from GPU Instancer whenever I run my project:

    This persists through my reimporting the package, stripping/readding the GPUI managers, etc. Any idea what could be causing this?
     
  25. Coold0wn

    Coold0wn

    Joined:
    Nov 4, 2018
    Posts:
    2
    Hello,

    I am currently looking through the sample scenes and can't find quite what I want to do. On a side note - for me the "PrefabInstancing" demo does not work and only shows ~10 asteroids. When I fly around they disappear completely.

    What I am trying to do:
    I have a map editor in my game where players can create maps and chose from a list of thousands of objects. They can place hundreds or thousands of objects if they want to, to create the maps they want to have.
    Now I want to make these objects GPU instanced.

    My questions:
    - What is your recommendation on how to use the GPU instancer for this purpose? Does it make sense to use it at all?
    - Am I supposed to add/remove prototypes dynamically for the objects that are used in the current map? Adding 4000 prototypes by default seems counter intuitive and also will reduce performance by a lot, right? Each map will use 50-500 different objects depending on the map.
    - Adding prototypes dynamically increases my map loading times by a lot. At the start of each map I need to load in all used objects and therefor also add all the prototypes at once. If a map has 100 different objects in it, it takes about 10 minutes to load. Is this expected behavior or am I doing something wrong? Because I cannot have my players wait that long to open a map.


    Here is the code I currently use, just in case (this is called per gameobject I want to instantiate) :

    Code (CSharp):
    1.         bool prototypeExist = false;
    2.         List<GameObject> prefabList = manager.prefabList;
    3.         for (int i = 0; i < prefabList.Count; i++)
    4.         {
    5.             if (prefabList[i].name == goToCreate.name)
    6.             {
    7.                 prototypeExist = true;
    8.             }
    9.         }
    10.  
    11.         if (!prototypeExist)
    12.             prototype = GPUInstancerAPI.DefineGameObjectAsPrefabPrototypeAtRuntime(manager, goToCreate);
    13.  
    14.         List<GameObject> prototypelist = new List<GameObject>();
    15.         prototypelist.Add(newGameObjectToInstantiate);
    16.         GPUInstancerAPI.AddInstancesToPrefabPrototypeAtRuntime(manager, prototype, prototypelist);

    Thank you very much for your help!

    Kindest Regards,

    Coold0wn
     
  26. ChiliStudio

    ChiliStudio

    Joined:
    Jan 19, 2018
    Posts:
    33
    ANGRYMESH Winter Pack trees on HDRP terrain are not rendering leaves and only rendering shadows in some cases.
     
  27. WeltenbauerRenn

    WeltenbauerRenn

    Joined:
    Jun 20, 2017
    Posts:
    40
    The shader has a MotionVector pass that's also the reason why drawing them with GameObjects works. GPU Instancer is using Graphics.DrawMeshInstancedIndirect, which seems to need additional work for MotionVectors https://github.com/keijiro/InstancedMotionVector
     
  28. rjohnson06

    rjohnson06

    Joined:
    May 27, 2017
    Posts:
    17
    I'm getting the following error after entering play mode after a compilation. Leaving and entering play mode again fixes the issue. I have Reload Domain and Reload Scene disabled for entering playmode, I'm thinking these settings are causing the issue. Also, I am using Standard render pipeline, with no pipeline asset selected, I think that is the official Unity method for enabling standard render pipeline though.



    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:441)
    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:564)
    GPUInstancer.GPUInstancerManager.LateUpdate () (at Assets/GPUInstancer/Scripts/Core/Contract/GPUInstancerManager.cs:273)
     
  29. kevhayes

    kevhayes

    Joined:
    Nov 8, 2015
    Posts:
    10
    Seeing some weird artefacts in the sky when using GPUI to render my forest and grass. I'm using Aura2 here and standard foliage shaders used with Unity Trees. This doesn't appear in the Scene view, just the Game view when running...
    upload_2021-6-1_13-7-0.png
     
  30. ChillPalace

    ChillPalace

    Joined:
    Jun 19, 2020
    Posts:
    7
    I'm sorry if this is a stupid question, but I'm new to the whole Shader Graph thing and don't fully know what I'm doing.

    I'm using this grass asset- https://assetstore.unity.com/packages/3d/vegetation/plants/stylized-grass-wind-194396

    When I put a prefab into the instance, an error message popped up telling me GPU Instancer Setup is not present, and I need to add it from the Shader Graph window. How do I go about doing this? I've never even touched anything shader-related so I'm a bit lost.
     
  31. Calamitycal

    Calamitycal

    Joined:
    Jul 6, 2014
    Posts:
    36
    Edit: I think I figured out the issue I was having with the grass so removing that part.

    Still would love to know if the below question is possible.

    I'm using the Instance Remover script to remove grass from under a player placed object. Works great! Is there an easy way to put back the grass if the player moves the object to another location?

    Thanks!
     
    Last edited: Jun 5, 2021
  32. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    755
    Just want to say, this is the best asset in the asset store. I have pushed it to its limit, and everything continues to just work. This time it was the shader graph implementation. I was able to make my own tree shaders, with my own wind and changing seasons, on a full world map, (meaning trees in north and south get snow first) and it just works. I was scared to try things, but every time I would, much to my delight, no issues, and the high framerate didn't even flinch.
     
    LouskRad likes this.
  33. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Looks like you have some lost references in your project. You can try using the menu item

    Tools -> GPU Instancer -> Shaders -> Clear Shader Bindings

    and see if this solves the issue.

    Hi there,

    The asteroid demo had an issue in the v1.4.5 and we have fixed it in the v1.4.6 version. If this is not the source of your error, it would mean that GPUI is not working in your project so we should address that first.

    As for your question; since you have a lot of prototype candidates, it is indeed a good strategy to dynamically load your prototypes to save memory and loading times. I would also suggest that you have a minimum instance count limit to use GPUI only when it makes sense.

    I would suggest contacting the developer of this asset since it is a shader compatibility issue.

    If you need per instance motion vectors, yes it would need additional setup. But in most cases where you use motion vectors for post processing (such as motion blur and TAA) you would not need this AFAIK.

    In any case, if you can send us a sample of your issue, we can investigate the problem.

    Looks like a Unity issue; probably related to you Unity version. I would suggest upgrading your Unity to the latest LTS version and see if it fixes the issue.

    Please check this troubleshooting F.A.Q for resolving the issue.

    Hi there,

    if you want to use GPUI with ShaderGraph, you can include the ShaderGraph setup node in your shader. Please see this wiki link for further information on how.

    Short answer is No. if you want to add (all) your grass back, you can re-initialize the manager.

    Thank you for your kind words!
     
  34. Calamitycal

    Calamitycal

    Joined:
    Jul 6, 2014
    Posts:
    36
    Understood, re-initializing should work. I did run into an issue last night that I am not sure how to solve. I have a building that has the GPUInstancerInstanceRemover on it to remove grass and trees. It works great, but I also have the ModificationCollider on my character, that way when he walks near a tree it can be chopped down. This also works great. But, when I walk into the building the trees that were removed by the Remover appear. Turning on RemoveAtUpdate does make them hidden again when the character walks away, but it's odd looking to have trees popping in and out of place.

    Is there a way to tell the Collider not to do anything with objects that were hidden by the Remover?

    Edit: And just as I wrote this I figured out a way. Added a check in the GPUInstancerInstanceRemover script to check if the object's mesh renderer or LOD Group is disabled and if so, return and do nothing. Works like a charm! Not sure if that will have other effects down the road, but for now it does the job!
     
    Last edited: Jun 6, 2021
  35. kevhayes

    kevhayes

    Joined:
    Nov 8, 2015
    Posts:
    10
    @LouskRad I'm not using any custom shaders for foliage - the grass is just a specified grass texture with no material override and the trees just use Unitys standard Tree Creator shaders. I'm using Aura 2 but the visual artefacts remain even if I remove Aura 2 from the project. I'm also using MapMagic 2 and the GPUI MapMagic integration.
     
  36. shay91

    shay91

    Joined:
    Feb 27, 2021
    Posts:
    3
    Can someone help me with this GPUI asset. The prefabs dont instancing and disappear from the scene when i Hit play
     
  37. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    Hi. What is the most recommended streaming solution with GPUI currently? I mean, which asset has best integration with GPUI.(Deciding streaming solution while I already have GPUI)
     
  38. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    Have any updates on supporting the Quest more officially? Instancing in general works on it, but I'd guess the issue is certain GPUI features don't work (HiZ depth culling?). I'm curious if the situation has changed in the last 6 months.
     
  39. Calamitycal

    Calamitycal

    Joined:
    Jul 6, 2014
    Posts:
    36
    So this does cause problems after all as it renders the modificationcollider unable to interact with anything.

    Is there a way to safely ensure that a ModificationCollider doesn't turn on an object that has been hidden by a GPUInstancerInstanceRemover?
     
  40. amarillosebas

    amarillosebas

    Joined:
    Feb 28, 2013
    Posts:
    44
    I just added GPU Instancer to a big project. I can't build the game because I'm getting this error:

    Code (CSharp):
    1. Assets\GPUInstancer\Scripts\GPUInstancerDetailManager.cs(56,13): error CS0103: The name 'keepSimulationLive' does not exist in the current context
    I'm using Unity 2020.2.3 and I haven't made any modifications to this asset's code. The GPU Instancer works perfectly fine in the Editor.
     
    castor76 likes this.
  41. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Yeah I was just about to report this as well.

    If I move it outside #ifDef , then it obviously works.
    public bool keepSimulationLive = false;

    It needs to be fixed in the official package so it stays there for a future update.
     
    pierre92nicot and amarillosebas like this.
  42. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi there,
    can you change the following lines like this and see if it fixes the issue:

    GPUInstancerModificationCollider.cs Line 44:

    from:
    else if (prefabInstance.state != PrefabInstancingState.Disabled)

    to:
    else if (prefabInstance.state == PrefabInstancingState.Instanced)

    and Line 55

    from:
    if(prefabInstance != null && prefabInstance.prefabPrototype.enableRuntimeModifications && prefabInstance.state != PrefabInstancingState.Disabled)

    to:
    if(prefabInstance != null && prefabInstance.prefabPrototype.enableRuntimeModifications && prefabInstance.state == PrefabInstancingState.Instanced)


    In that case it could be an incompatibility with a visual effect, etc. in the scene. If you can email us a sample project, we can investigate the issue.

    As far as an official integration is concerned, GPUI only offers an integrated solution for MapMagic (both versions). However, GPUI also offers generic solutions for adding/removing items and terrains so it is designed to be compatible with most sensible solutions. However, some streaming solutions work by enabling/disabling mesh renderers and that would be incompatible with GPUI.

    The issue with the Quest is mostly based on the GPU limitations imposed by it which introduce complexities for GPUI's shader and buffer usages. As such the situation has not changed.

    Hi there,

    we have just submitted a version that will fix this issue, but for now, you can modify line 56 of the GPUInstancerDetailManager.cs

    from:

    keepSimulationLive = true;

    to:

    #if UNITY_EDITOR
    keepSimulationLive = true;
    #endif
     
    castor76 likes this.
  43. Calamitycal

    Calamitycal

    Joined:
    Jul 6, 2014
    Posts:
    36
    Hello! Making those changes didn't work. The tree still appears when I walk to its position.

    Also, I switched over to using MapMagic2 and the MapMagic2 GPUI Integration objects and I've run into a couple of errors (note the above issue was before I used MapMagic2 Integration and I tested your changes in a project that was set up without MM2, just to be clear)

    First issue with MM2 integration is I get this warning and this error when starting up:

    GPUInstancerModificationCollider does not have a GPUInstancerPrefabManager defined.
    UnityEngine.Debug:LogWarning(Object)
    GPUInstancer.GPUInstancerModificationCollider:Awake() (at Assets/GPUInstancer/Scripts/GPUInstancerModificationCollider.cs:24)

    NullReferenceException: Object reference not set to an instance of an object
    GPUInstancer.GPUInstancerInstanceRemover.Start () (at Assets/GPUInstancer/Scripts/GPUInstancerInstanceRemover.cs:25)

    Seems like those checks are occurring before everything is set up?

    In addition, when a new tile of the map is created by MapMagic, I get this error (attached as an image) and the grass and objects fail to draw. If I turn off GPU Instancer everything appears correctly.

    GPUInstancer_Bug.jpg
     
  44. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    Hi, does anyone have a demo for 7.0 android?
     
  45. V_R

    V_R

    Joined:
    Dec 5, 2015
    Posts:
    4
    Just responding to state our interest in this as well.
    For now we can manually put the relevant code into the generated shaders, but as it's rather user-unfriendly when it comes to artists potentially changing shaders down the line and needing to re-inject the code, we'd be very appreciative of a cleaner solution.
     
    castor76 likes this.
  46. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    @miknios
    @V_R

    I think the following workaround should provide a solution. Let us know if it works out for you. You can download the example shader from here. Here is how it works:

    1- Create a cginc file containing only the StructuredBuffer definition.
    GPUIVariationDefinition.cginc
    Code (CSharp):
    1. #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    2.     StructuredBuffer<float4> colorBuffer;
    3. #endif //UNITY_PROCEDURAL_INSTANCING_ENABLED
    2- Include this file in your Amplify Shader:
    upload_2021-6-15_20-29-19.png

    3- Create a Custom Expression node which outputs this buffer:
    upload_2021-6-15_20-31-2.png

    Code (CSharp):
    1. #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    2.     return colorBuffer[gpui_InstanceID];
    3. #else
    4.     return color;
    5. #endif
    I didn't test this on SRP yet, but it should work. We will make some test and prepare documentation for it in the future.
     
    DEEnvironment likes this.
  47. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    InstanceRemover clears instances on GPU memory only. You might get inconsistencies when you edit instances both through InstanceRemover and ModificationCollider. Since you need to do operations on your prefab instances on CPU, I would recommend to not to use instance remover for them.
    As for the error you get, these components expect GPUI managers to exist in scene beforehand to work. But MM integration adds/removes these managers while streaming.

    I recommend to use GPUInstancerAPI to manually add/remove or enable/disable instancing according to your needs.
     
  48. Calamitycal

    Calamitycal

    Joined:
    Jul 6, 2014
    Posts:
    36
    Makes sense about the first two errors, I was able to work around those by adding some additional code to the GPUI scripts to account for the order that things are loaded. Not ideal, but it works. Manually adding and removing the prefab instances is fine too.

    But I don't think either of those addresses the issue I am having with the terrain loading and not displaying details and trees. Is there something I am possibly doing wrong in the set up that would cause this? Is that also a timing issue?

    I'm really enjoying using GPU Instancer btw. Wanted to say that as I know I've been focused on the problems I'm having, but on the whole it's been working great and the performance has been amazing. Really appreciate the support too!

    Thank you!
     
  49. WeltenbauerRenn

    WeltenbauerRenn

    Joined:
    Jun 20, 2017
    Posts:
    40
    Hi just to let your know LOD calculation is broken when not using the AutoSelectCamera option on a GPUI manager.
    It was caused by a missing CalculateHalfAngle call.
    Code (CSharp):
    1. public void InitializeCameraData()
    2. {
    3.     if (autoSelectCamera || cameraData.mainCamera == null)
    4.     {
    5.         cameraData.SetCamera(Camera.main);
    6.     }
    7.     //CUSTOM CODE START
    8.     else
    9.     {
    10.         cameraData.CalculateHalfAngle();
    11.     }
    12.     //CUSTOM CODE END
    13. }
    Sometimes I change the camera fov. Is this need to be updated?
     
  50. V_R

    V_R

    Joined:
    Dec 5, 2015
    Posts:
    4
    Very much appreciate the rapid response, this did indeed do the trick! I'd tried something simlar myself, but I must've misconfigured something because while the entire thing compiled fine, it ended up rendering the spheres transparent. Not sure what happened there.

    Either way, this works, so problem solved. Thanks!
     
    Last edited: Jun 16, 2021