Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

[RELEASED] GPU Instancer

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

  1. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    When using indirect GPU instancing, instances are positioned within the shader using a procedural setup method, typically invoked through the UNITY_SETUP_INSTANCE_ID call. If your tree shaders lack this call, they won't support GPU instancing, resulting in instances positioned at the origin (camera). Refer to the shader setup guide for details on making custom shaders GPU instancing compatible. If issues persist, feel free to reach out to the support email with the shader file for assistance.
     
  2. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    for the moment I have abandoned this Asset. I've been trying to use it for months but it causes too many problems. This product is not finished.
     
  3. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    As I've mentioned several times before, I'm happy to investigate any issues you encounter with the asset. However, I can only do so if you submit a bug report following this guide, which should include a sample project or detailed reproduction steps. Continuously posting about issues without providing sufficient information doesn't benefit anyone.
     
  4. rajneeshadrack

    rajneeshadrack

    Joined:
    Feb 15, 2023
    Posts:
    10
    Is anyone using this tool for android or iOS?
     
  5. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    I tried to lighten my big project to send it but it didn't work. I will do another test
     
  6. ThemasterL

    ThemasterL

    Joined:
    Aug 30, 2019
    Posts:
    3

    There are 2 scripts, the "OcclusionRange" that goes as a "gameobject" inside the camera and the "Dinamyc_Add_Remove_Intancing" that is added to the object that seeks to be a GPU instance.

    The "OcclusionRange" has to have a "sphere collider" and a "rigidbody" for the objects to be collided to work, the "CounReseting" value is the update frequency of the objects it detects to add or remove in the GPU list.

    On the "Dinamyc_Add_Remove_Intancing" side I did it that way so that extra code can be added when the object is activated or not, you have to have the components of a GPUInstancerPrefab along with its dynamic activator that ends with "hander", with that and adjusting the physics so that the collide reacts only with the GPU objects, depending on the range the objects are activated and deactivated, the list you have and the LOD is to deactivate or activate them according to the function you are looking to use, just follow the process " step by step" to see what actions you want to perform, and if you want to improve performance with "quality level", create a script that has this:

    public class GPUInstancerImpostorManagerReload : MonoBehaviour
    {
    public GPUInstancerPrefabManagerManager;
    private int previousQualityLevel = -1;
    public SphereCollider Col, ColLow;
    public float MinRange, MaxRange;
    public float MinRangeLow, MaxRangeLow;
    voidStart()
    {
    // Initialize the quality level before starting
    previousQualityLevel = QualitySettings.GetQualityLevel();
    ApplyQuality();
    }

    voidFixedUpdate()
    {
    // Check if the quality level has changed
    if (QualitySettings.GetQualityLevel() != previousQualityLevel)
    {
    // Update the previous quality level
    previousQualityLevel = QualitySettings.GetQualityLevel();

    // Perform the actions you want when changing the graphic quality
    ApplyQuality();
    ReloadGPUInstancer();
    }

    void ApplyQuality()
    {
    int totalQualityLevels = QualitySettings.names.Length;
    float valRange = (float)QualitySettings.GetQualityLevel() / (totalQualityLevels - 1);
    Col.radius = Mathf.Lerp(MinRange, MaxRange, valRange);
    ColLow.radius = Mathf.Lerp(MinRangeLow, MaxRangeLow, valRange);
    }

    void ReloadGPUInstancer()
    {
    if (Manager != null)
    {
    Manager.ClearInstancingData();
    Manager.OnEnable();
    }
    }
    }

    This code updates the range of GPU objects and also the "LOD" setting since I had a problem that if you start the game on "low" and change it to "high" it uses the low level LOD, this will updates every time the graphic quality is changed including the range of objects to use with the sphere collider of the "OcclusionRange"
     
  7. ThemasterL

    ThemasterL

    Joined:
    Aug 30, 2019
    Posts:
    3
    I finally managed to solve the happy "LOD" crossfade problem.
    The solution is somewhat "tedious", it turns out that it does not apply the changes correctly since there are limits to transforming the original shader to one that the GPU instance has.
    Well, first they have to see if the shader uses the "Fragment" code right there, if not and it turns out that it uses Unity's own package, they have to do an extra step by copying the necessary file(s), among them would be in my case I use URP, the "LitForwardPass.hlsl", "LitGBufferPass.hlsl" and "ShadowCasterPass" those matter to me.

    If you don't find them, change the path from "Assets" to "Packages" and look for it there. Then paste it in a path where the files can be located, in my case I leave them in the same GPUI extension files and change the path The "Pass" to the shader, in my case with URP Lit, was from "#include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl"" to "#include "Assets/GPUInstancer/Shaders/ Include/LitGBufferPass.hlsl""

    This sounds cumbersome, but Unity usually restores changes that have occurred in the package so it is better to use this method. already having that. You have to make this change within the "Fragment" of the passes, or the shader's own Fragment if it has one. Search for the word "LOD_FADE_CROSSFADE" and you will get something like:

    #ifdef LOD_FADE_CROSSFADE
    LODFadeCrossFade(input.positionCS);
    #endif

    They just add this:
    #ifdef LOD_FADE_CROSSFADE
    #ifdef UNITY_APPLY_DITHER_CROSSFADE
    UnityApplyDitherCrossFadeGPUI(input.positionCS.xy);
    #else
    LODFadeCrossFade(input.positionCS);
    #endif
    #endif

    and problem solved, (well, yes or if it has to be the inputData.positionCS.xy so that it can take the position of the object).

    This happens because GPUI interprets the position of the objects differently compared to Unity, the package already has that constructor, but it is never using it, which is the "UnityApplyDitherCrossFadeGPUI" that converts the position of the Unity object to that of the GPUI.
     
  8. niallslater

    niallslater

    Joined:
    May 9, 2017
    Posts:
    8
    Hi, I've been happily using this asset for a while now for my VR game and it works wonders - however I'm running into a problem with a new feature I'm working on.

    I'm trying to render prefab instances which have a custom flipbook shadergraph on them. They're simple alpha-clipped quads with an animated texture. I update the frame of the animation in a monobehaviour like this:

    Code (CSharp):
    1. _materialInstance.SetFloat("_Frame", currentFrame);
    This works great without GPUInstancer, but one the prefabs are registered and instancing the animation no longer plays. In fact, any parameter I pass to the shader has no effect.

    Is there a proper way to work with material instances like this? Am I missing something obvious?

    Many thanks!
     
  9. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    GPU Instancer uses the original material properties to make draw calls. If you have different material property values for each instance, individual draw calls will be generated for each instance, and in that case, there will be no benefit in using GPU instancing.

    As a workaround, we use StructuredBuffers in the shaders to create material property variations. You can find examples of this in the Demos folder, such as ColorVariations and ShaderGraphVariations. Refer to the Material Variations documentation for more information.

    If you encounter difficulty setting it up, feel free to contact the support email with an example project.
     
  10. niallslater

    niallslater

    Joined:
    May 9, 2017
    Posts:
    8
    Thanks for the advice, I followed the example and got it working!
     
  11. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    GPU Instancer latest version MapMagic2 integration is broken for Objects specifically (it still works perfectly with Trees and Grass, it is only Objects that are broken).
    Using the default Lit Shader, I spawn a lot of rocks as objects that do not get GPU Instanced beyond the first terrain tile.
    Using Unity 6, but I don't think that has got anything to do with it.

    Adding them with prefab manager still works perfectly, but clearly it cannot be used in tandem with procedural generation that way.

    The problem is that beyond the initial center tile objects, the other tiles objects get spawned as 'Clones' even if said option isn't selected in the MM2 Graph.

    Cloned Objects display as:
    upload_2024-5-15_1-24-22.png
    upload_2024-5-15_1-22-48.png

    Normal Prefabs display as:
    upload_2024-5-15_1-25-10.png
    upload_2024-5-15_1-23-4.png
     
    Last edited: May 15, 2024
  12. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    The two examples use different prototypes (RockConcaveA and RockConcaveB). There might be an issue with the integration setup or the prototype references on the prefabs. If you can contact the support email with an example project following this guide, I can look into it.
     
  13. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    That "RockConcaveA and RockConcaveB" naming error was just me being sleep deprived and not double checking :oops:

    The MapMagic2 integration is still broken. Objects in new procedurally generated tiles will only get spawned and not instanced to the point they ignore the Culling Min-Max distance that you set up for them in the GPUI MapMagic 2 Integration Manager. You can see them spawning faraway in Main Tiles 'ignoring the culling distance' while the ones that were instanced obey the rules properly and do not spawn until very close to them.

    Sending a project is complicated but I will see what can I do... is it really that difficulty to check on your side?

    Oh, and I'd also like to recommend multi-editing of prefabs for the MapMagic2 integration the way you can also do with the Prefab Manager. Having to change object LODs and distance settings one by one can get tedious.
     
  14. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    Bad news.

    I checked a past project from Unity 2021.3 HDRP using GPU Instancer 1.7.5 and the MapMagic2 integration was already broken.

    Same issue: runtime generated tiles objects do not get added, only those that were pre-generated in the Editor do.

    It would be convenient to think there is something wrong with my setup, but I do not think that's the case.
     
  15. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    I checked it, and there does not seem to be an issue. The objects on the runtime generated tiles are added to the Prefab Manager.

    MM2-1.png

    MM2-2.png
     
  16. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    Sorry for wasting your time.

    I fixed it by adding the Prefab Runtime Handler manually to the prefabs.

    But why is that if I have the option "Add Runtime Handler Script" checked in the Prototype SO.

    In fact, after manually adding the Prefab Runtime Handler and checking "Add Runtime Handler Script", the Runtime Handler gets added twice. But if I do not add the Prefab Runtime Handler manually, then checking "Add Runtime Handler Script" does nothing.

    Glad the issue was on my end though :)
    And thanks to you for providing that image so I could learn the Prefab Runtime Handler is necessary.
     
  17. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    I am not sure why it wasn't added before. Normally the option should be automatically enabled. There might have been an error at some point that messed up the components on the prefab.
    Also using both original prefabs and variants with Prefab Manager can cause issues with the components. For example if you set up the components on the prefab variant and then add the original prefab on the Prefab Manager, the GPUI Prefab components might be duplicated on the variant and cause reference issues. You should make sure that there is only one of each component on the prefabs and the Prototype SO reference is correct.
     
    O_ likes this.
  18. shadow_tm

    shadow_tm

    Joined:
    Jul 2, 2014
    Posts:
    13
    Hi! What do you think, did the feature work?

    GPUInstancerPrefabPrototype DefinePrefabPrototypeAtRuntime(Mesh mesh, Material ...)
     
  19. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    34
    Hello, I'm having an issue where after increasing the culling view distance on some characters using the crowd animations, a kind of visual artifact appeared giving a slight black outline to all units even when really zoomed in. You can see it comparing these two pictures here:
    https://imgur.com/a/HlezSDg
    here it is without the artifact-ing:

    and here it is with it:

    do you know what could be causing this? I doubled the cull distance from 500 to 1000, and looking at the version control it looks like that also implicitly turned on something called checkedForBillboardExtensions. Could that be the issue?

    thanks for any help.

    edit: just further to the above, I'm not certain that increasing the cull distance is responsible, it just happened about the same time, and decreasing it back down again, and also testing turning shadows off, doesn't fix the artifacting. The same models with same textures just dragged into the editor also don't have this issue, only after passing through the GPUI. Thanks again for any help.

    further info: testing more, it's only against very far distance backgrounds, so I only saw it against the sky before, but I can also see it against distant hills, which makes me think it is some sort of distance related issue with the gpui culling or checkedForBillboardExtensions?
     
    Last edited: May 21, 2024
  20. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    It looks like a shader issue, not related to culling. It's probably something to do with the alpha or depth calculation. If you have trouble figuring it out, you can email me an example project, and I will look into it.
     
  21. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    350
    Hello, i found some strange LOD crossfading in Unity 6000.0.0 HDRP with GPU Instancer 1.8.1

    1.i'm using default HDRP lit shader for these plants.all of them are added in terrain detail and rendered by GPUI Detail Manager.
    it looks like GPUI loaded a big patch of the higher level lod mesh at far distance then fade back to lower lod mesh which is the proper lod mesh to display.
    but when you are near the plants the lod crossfading works correctly.
    i guess it's something about GPUI streaming its preloaded data?

    2.also i found there will be some small performance spikes when loading those patches,
    any tips i can lower the impact?
    (maybe i'm wrong about these spikes,it could be just too much polygons to render?)

    gpuilod.gif
     
    Last edited: May 22, 2024
  22. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    and thank you for reporting the issue.
    Please try making the following change in the code and see if it solves the problem.
    In GPUInstancerDetailManager.cs after line 856 (at the end of the MergeVisibilityBufferFromActiveCellsCoroutine method) add:
    Code (CSharp):
    1. isInitial = true;
    It should look like this:
    Code (CSharp):
    1. private IEnumerator MergeVisibilityBufferFromActiveCellsCoroutine()
    2. {
    3.     if (!initalizingInstances)
    4.     {
    5.         ...
    6.         if (_triggerEvent)
    7.             GPUInstancerUtility.TriggerEvent(GPUInstancerEventType.DetailInitializationFinished);
    8.         _triggerEvent = false;
    9.         isInitial = true;
    10.     }
    11. }
    If you have trouble, feel free to contact the support email and I can send you a unity package.
     
  23. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    350
    Thank you !
    the code fix works almost perfect.
    no more high lod mesh pop out at far distance and no more performance spikes now.
    i'm happy.

    just in case if you don't know:
    i guess it pushed the high lod mesh appears later?
    at a very rare rate some high mesh appeared too late so they poped out at the near distance which they should appeared already with lod crossfading.
    but this only happens at a random particular angle on particular mesh,if you change your view angle it will no more pop out.
    and it is very very rare,kinda hard to find too much,so i'm satisfied already with GPUI now.
    thank you for your work!

    (please ignore the small grass , i pushed the cull distance too close)
    gpui_lod2.gif
     
  24. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Since GPUI uses a custom GPU-based LOD system, there might be differences from the built-in Unity renderers. If the lower LODs are appearing closer than expected, you can increase the LOD Bias Adjustment value on the prototype.
    Additionally, the "Object Size" on the LOD component might have been modified, which can also cause differences in LOD behavior. If this is the case, click the Recalculate Bounds button on the LOD Group component to fix the bound sizes.
     
    LumaPxxx likes this.
  25. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    351
    How do I use GPU-Instancer along side Addressables?
    Right now it adds 100's of duplicate dependencies because you are referencing the Resources folder.
    Is there some place I set it to get those from addressables? Or do I need to adjust the code manually?

    Also how do I get it to use separate GPUInstancerBillboardAtlasBindings for different objects/scenes?
    Because it looks like it is storing prefab data in there.

    If scene1 uses tree1 then I don't need tree2 loaded.
    If scene2 uses tree2 then I don't need tree1 loaded.
     
    Last edited: May 25, 2024
  26. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there
    GPUInstancerBillboardAtlasBindings is used for loading billboards for prototypes generated at runtime and to avoid creating billboards for the same prefabs multiple times. If you have all the prototypes already added in the scene, you can clear the Billboard Atlas Bindings list to remove the references. The references to the billboard textures in the scene will not be lost.
     
  27. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    351
    Ok so I need to clear that before building the game. What about the others?
    upload_2024-5-27_9-6-33.png
     
  28. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Those will require code changes. I will look into modifying the code and converting them into addressables. If you contact the support email with your invoice number and I can send you the modifications when completed.
     
  29. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    When using the MapMagic2 integration, any separate scenes sharing the same MapMagic2 graph once imported using the GPU Instancer integration will break other scenes making use of the same graph.

    Isn't there a way to keep them all independent?
    Or at the very least being able to select Terrain Settings SO at will considering it is currently grayed out and you cannot place your own.

    My only solution right now is renaming the output Terrain Settings SOs to prevent overrides when importing in other scenes sharing the same graph.

    Also, I'd like to know: is there any Tree Shadow LOD Map documentation I could read? I cannot make any sense out of it and how it interacts with HDRP global volume Shadows and I am currently being forced to use a Custom Shadow Distance in order to get proper tree shadowing.
     
  30. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    You can add the scene name to the Terrain Settings asset to make it independent. Change the GPUInstancerMapMagic2Integration.cs line 348 from this:
    Code (CSharp):
    1. terrainSettings.name = "GPUI_MapMagic_" + mapMagicInstance.graph.name + "_" + mapMagicInstance.graph.GetInstanceID();
    to this:
    Code (CSharp):
    1. terrainSettings.name = "GPUI_MapMagic_" + mapMagicInstance.graph.name + "_" + mapMagicInstance.graph.GetInstanceID() + "_" + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
    Shadow LOD Map determines which LOD level to render the shadows from (see LOD N Shadow). The data looks weird because it has some padding for compatibility with older Unity versions (SetFloats/SetInts methods did not function correctly without padding). See the ChangeLODShadow API method to learn how the padding is implemented.
    GPUI uses the QualitySettings.shadowDistance to determine shadow culling distance. Since HDRP uses different shadow settings, GPUI might be culling the shadows too early. You can set the QualitySettings.shadowDistance value to your desired culling distance or use the Custom Shadow Distance property. For example:
    Code (CSharp):
    1. QualitySettings.shadowDistance = 150f;
     
    Frpmta likes this.
  31. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    What I don't get is why if I remove all entries from this menu the prototype suddenly disappears and won't render:
    upload_2024-5-29_10-28-41.png

    QualitySettings.shadowDistance = 150f; did work, but where do I set up those GPU Instancer LODs ranges?
     
    Last edited: May 29, 2024
  32. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    You shouldn't remove or add entries to Shadow LOD Map. It should always be fixed size 16. That is what the shader expects. This setting has noting to do with LOD ranges. It allows you to use a different LOD level for shadows (see LOD N Shadow).
    GPU Instancer reads the LOD ranges from the LOD Group component on the prefab. If you want to change the LOD distances see my explanation on this post.
     
    Frpmta likes this.
  33. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    Got any idea on this strange behavior that occurs on some GPU Instanced objects?
    GPU Instancer weird bug.gif

    Also, I wanted to ask: is converting the MapMagic2 integration into a GPUI no gameObject version a great challenge?
     
  34. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    It might be related to occlusion culling. For example, if one of the shaders depth pass is not correctly setup for GPU instancing, then it might cause incorrect depth calculation (e.g. rendering silhouettes on top of the camera). You can confirm this by disabling the Use Occlusion Culling option on the GPUI Managers.
    If this is the case, you need to modify the shader to support GPU instancing (see How can I convert shaders manually to support GPU Instancer?).
    If you have trouble fixing the shader or if it is another issue, contact the support email with a repro project and I can take a look.

    You would probably need to create custom nodes so that it generates a Matrix4x4 collection instead of GameObjects. You might want to ask the developer or other MM users; maybe someone has already implemented it.
    If you have components other than renderers on the prefabs such as colliders or custom scripts then it will be more complicated. Since you would need to implement a solution (e.g. Object Pooling) for those as well.
     
    Frpmta likes this.
  35. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    It is occlusion culling indeed. Using an occlusion culling distance of 20+ removes that, but then I made a test where I duplicated the scale of the same rocks and now 20+ doesn't do it. Does it have to do with collider bounding box?

    Guess I have to manually control the occlusion culling min. distance for objects beyond a certain scale. What does Bounds Size Offset do? A custom bounding box per prototype?
    Documentation reads: "Bounds Size Offset: This value can be used to increase the bounding box size of the prototype. This will effect the culling and LOD calculations on the prototype. It is very useful for prototypes with shaders that modify vertex positions." but are those Vector3 values multipliers of the current boundary box or the new boundary box size itself.

    Those rocks have the Lit shader so they are already converted to proper GPUI format btw.
     
    Last edited: May 31, 2024
  36. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    499
    Won't bother with Bounds Size Offset.

    Occlusion culling min. distance does the job perfectly. The editor is capped at a value 100, but the scriptableObject allows any value. Is there any issue with exceeding 100? Asking just for very extreme cases.
     
  37. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Having a very high minimum culling distance is not recommended. It is better to disable occlusion culling for that particular object if it has issues with it.
     
    Frpmta likes this.
  38. shadow_tm

    shadow_tm

    Joined:
    Jul 2, 2014
    Posts:
    13
    Hi to all! Maybe someone has GPUInstancer Lit shader with ColorVariants.
    I really need it, thank you.
     
  39. shadow_tm

    shadow_tm

    Joined:
    Jul 2, 2014
    Posts:
    13
    What shader do you use to combine lit and color variation in this example?
     
  40. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    If you contact the support email following this guide, I can help you out.
     
  41. Mackerel_Sky

    Mackerel_Sky

    Joined:
    Jul 24, 2018
    Posts:
    33
    Hey guys,

    Just have a quick question about floating origin stuff. I'm working on a flight simulation game which requires tracking of potentially millions of instances (not necessarily rendering them) - mainly trees, buildings, etc.

    I ran into some bottleneck issues with some other indirect instancing solutions where they struggled to update the positons of all the instances when the scene origin was updated - even if instances aren't being rendered their positions still need to be changed for them to render correctly after origin shift. I think part of the problem is the sheer amount of instances that were created, and Unity terrain not being very efficient with its tree settings.

    How does GPU Instancer approach this problem? Do you know if I'll encounter similar problems if I try approaching it with GPU Instancer?
     
  42. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    GPUI uses Compute Shaders to update the positions for floating origin. You can enable the Use Floating Origin option on the GPUI Managers, or use the API to manually make the updates (see SetGlobalPositionOffset).
    Since it updates the GPU memory with compute shaders, it works quite fast.
     
  43. Mackerel_Sky

    Mackerel_Sky

    Joined:
    Jul 24, 2018
    Posts:
    33
    Thanks Gurhan,

    I've downloaded GPU Instancer and it seems to be working well! However, I seem to be running into a problem regarding the initialisation of the scene. I use GPUInstancerAPI.SetCamera to set my camera and turned off AutoSelect camera for my tree managers - from the inspector I can see it is set correctly. However, when I build my game the offset is wrong:



    I've confirmed that the problem occurs when I load the game from the main menu, then load into the scene above. If I load directly into the scene from the editor, then the trees are fine. Obviously for build we would need the player to access the level via the menu (I also do some stuff about saving and loading aircraft between the menus and gameplay scenes - the scene is initialised then the player aircraft + camera is loaded in.) Do you have any idea as to what could be going on?
     
    Last edited: Jun 11, 2024 at 2:45 PM
  44. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    I cannot say without seeing it firsthand. It might be related to how or at which time the terrain transforms are modified. If the Use Floating Origin option is enabled, GPUI adds a component called GPUInstancerFloatingOriginHandler to the terrain when the managers OnEnable method is executed. This component checks if there is a transform change and calls the SetGlobalPositionOffset method.
    If you are unable to find the source of the issue, you can contact the support email with a repro project and I can take a look.
     
  45. Mackerel_Sky

    Mackerel_Sky

    Joined:
    Jul 24, 2018
    Posts:
    33
    Thanks Gurhan, I investigated with trying to enable tree managers after the camera is loaded into the scene, as well as running the entire thing via scripting, but I can't seem to figure out what exactly the problem is. If I load into the gameplay scene from another scene, then the offset is incorrect. If I enable my tree managers after the camera is spawned and set, then the same problem occurs regardless if I load into the scene or play it directly from the editor.

    I sent you a support email with a repro project - I cut out as much as I could but unfortunately it's still about 3.5GB, not sure if that's on your end. If you want it any smaller I will need to spend a lot of time figuring out what is safe to delete out of the Assets Folder.
     
  46. EgemenJP

    EgemenJP

    Joined:
    Oct 9, 2018
    Posts:
    6
    GPUI Crowd Setup shader subgraph has it's targent vector set to world instead of object space
     
  47. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Thank you for the feedback. I will modify the graph in the next update.