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. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    I have a list of trees and rocks and many have a missing script because I had used GPUI then deleted the tool in order to reorganize my list (my GameObjects were in different folders). This is probably why the instances are at 0.
    As Unity does not support multi-editing, it takes a long time to remove calls to the missing script. I'll come back later to say if that solved the problem.
     
  2. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Hello there, I am using Unity 2022.3 and URP 14. When using The Vegetation Engine and after adding new details in the detail manager, I sometimes get this error

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. GPUInstancer.GPUInstancerUtility.AddDetailInstanceRuntimeDataToList (System.Collections.Generic.List`1[T] runtimeDataList, System.Collections.Generic.List`1[T] detailPrototypes, GPUInstancer.GPUInstancerTerrainSettings terrainSettings, System.Int32 detailLayer) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:1011)
    3. GPUInstancer.GPUInstancerDetailManager.InitializeRuntimeDataAndBuffers (System.Boolean forceNew) (at Assets/GPUInstancer/Scripts/GPUInstancerDetailManager.cs:163)
    4. GPUInstancer.GPUInstancerEditorSimulator.EditorUpdate () (at Assets/GPUInstancer/Scripts/GPUInstancerEditorSimulator.cs:135)
    5. UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <78fe3e0b66cf40fc8dbec96aa3584483>:0)
    6.  
    And now it happened again when trying to add a flower prefab, and I cannot load any scene with the detail manager, even on different terrains with different detail prefabs. this error is thrown every frame. It was working flawlessly before that to I doubt it was a setup issue. Tried to delete and a fresh GPUI reimport but no luck. Any help? thanks.
     
    Last edited: Feb 5, 2024
  3. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    Using colliders would be too expensive when dealing with millions of instances. The most efficient approach would be to perform a distance check and set the matrices to the buffers based on the distance.

    You can employ a Compute Shader on the GPU side or a Parallel Job on the CPU side and update the buffers accordingly. Utilizing a Compute Shader is preferable as it allows you to minimize the amount of data sent to the GPU.

    For instance, for each index, based on distance, one buffer/array can hold the correct Matrix4x4 value, while the same index on the other buffer/array can be set to zero and culled.

    Hi there,
    I was not able to reproduce the issue. Could you please email a bug report, either with an example project or a step-by-step description of how to reproduce the issue, following this guide?
     
  4. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Hello, so I was able to fix this by removing all the prefabs from both de the detail manager and terrain, and importing them back to the detail manager. But there is still only one prefab that always cause this. The weird thing is that I made this prefab the exact same way as the others, but whenever I add it, The error is thrown when entering play mode, also it only throws' the error every frame if "error pause" is set on the console otherwise it's just one error and the scene loads normally, but that one prefab will be invisible, and it has a chance of having the effect of breaking the rest of them in edit mode, if so I need to remove them all and re-do the process again. So we can consider it solved, probably there is some error in blender to unity process on that one grass.
     
    Last edited: Feb 5, 2024
  5. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    So now I am having this small issue with trying to change the Detail Density and Detail MaxDistance at runtime. I saw that you recommend to check the TerrainGenerator to use the UpdateDetailInstance call. So I made a simple function to change it in my detail manager.
    Code (CSharp):
    1.         public void UpdateGPUIDetailManager()
    2.         {
    3.             gpuiDetailManager.terrainSettings.maxDetailDistance =  MaxDistanceSettingValue;
    4.             gpuiDetailManager.terrainSettings.detailDensity = DensitySettingValue;
    5.             GPUInstancerAPI.UpdateDetailInstances(gpuiDetailManager, true);
    6.         }
    And I can see the values changing on the detail manager inspector but they do not reflect in the game view, grass density and draw distance remain the same. Is there another step required to update the runtime detail manager? Thnaks!
     
  6. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    I also had a single prefab that prevented all the others from working.
     
  7. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Each prototype has an individual distance and density setting. You can change the max. distance value at runtime by setting the maxDistance property of each prototype:
    Code (CSharp):
    1. foreach (GPUInstancerDetailPrototype p in gpuiDetailManager.prototypeList)
    2. {
    3.     p.maxDistance = MaxDistanceSettingValue;
    4. }
    However, the density setting is used at initialization. So when changing the density value, the Detail Manager needs to be re-initialized for the changes to take effect:
    Code (CSharp):
    1. foreach (GPUInstancerDetailPrototype p in gpuiDetailManager.prototypeList)
    2. {
    3.     p.detailDensity = DensitySettingValue;
    4. }
    5. GPUInstancerAPI.InitializeGPUInstancer(gpuiDetailManager);
     
  8. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Thanks it works perfectly!
     
  9. DeidreReay

    DeidreReay

    Joined:
    Oct 28, 2019
    Posts:
    50
    So having an issue using unity settings Graphics we have basic game options menu that can change the Quality Settings options (Low to Ultra) . In game when we change graphics settings to a lower setting GPUI Prefab instances will change, but when we try to change graphics back higher the textures look horrible. Are there any known issues with changing Graphics at runtime or any idea what to maybe look at?
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      26.4 KB
      Views:
      24
    Last edited: Feb 11, 2024
  10. Tanknspank

    Tanknspank

    Joined:
    Oct 25, 2017
    Posts:
    3
    Hello Gurhan,
    currently using GPUI on HDRP 2022.3.10f1

    Trying to paint terrain details but simulation is not updating at all. I have to disable and reenable it for each detail I'm trying to paint to see the changes made which makes it impossible to work with it.

    have you or anyone here encountered this before and any possible fixes for this?
    (I am aware of the warning in the simulation kept alive field, but it's not just sometimes - it's always)

    I am using 1.8.1 but had the issue on 1.8.0 as well
     
  11. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    This is most probably a Unity bug, as GPUI does not handle anything related to texture quality. I would recommend trying the latest LTS Unity version to see if the bug persists.
    Hi there,
    I am unsure why the simulation is not updating in your case. Here is how it works:
    The Detail Manager is updated using the OnTerrainChanged method inside the GPUInstancerTerrainProxy component. The GPUInstancerTerrainProxy component is automatically added to terrains that use the Detail Manager, and the OnTerrainChanged method should execute when you make a change on the terrain.

    If this information is insufficient for you to determine why it is not working, you can email me an example project, and I can investigate further.
     
    Tanknspank likes this.
  12. OneFoxStudio

    OneFoxStudio

    Joined:
    Dec 26, 2023
    Posts:
    6
    Hi !
    I'm trying to chop down trees; using GPUI TreeManager to manage them; so i'm using

    Code (CSharp):
    1. GPUInstancerAPI.RemoveInstancesInsideBounds(treeManager, collider.bounds, 0f);
    To remove them; which works fine ... except the collider is still there; but not all the time (which is really odd).

    I can't even detect the collider from the tree nor show it using Gizmos.

    Ideally i'd like to be able to interact with a collider and do my stuff.

    Seems there's some dark magic going underneath; could you please explain how to deal with it ?

    Thank you

    Cheers!
     
  13. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    The RemoveInstancesInsideBounds method only removes instances from GPU memory. It will not modify the TerrainData.treeInstances or update the terrain collider. You need to implement a tree removal solution for Unity terrain and then use the RemoveInstancesInsideBounds method to notify GPUI to update the GPU memory.
    I attached a simple example I made a while ago to this post. It should give you an idea about how to implement your own solution.
     

    Attached Files:

  14. tcn5150

    tcn5150

    Joined:
    Dec 1, 2012
    Posts:
    26
    I was wondering if GPUI instances are able to cast shadows in HDRP volumetric fog? My tests would indicate that they can't, but I'd like to make sure. Thanks!
     
  15. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    I conducted a quick test on 2022.3 with Volumetric Fog, and there don't appear to be any issues with the shadows. The shadows might be getting culled due to distance. Please try enabling the Use Custom Shadow Distance option and set a high Shadow Distance value on your prototypes.
    If this doesn't resolve the issue, please email a sample project, and I'll investigate further.
     
  16. tcn5150

    tcn5150

    Joined:
    Dec 1, 2012
    Posts:
    26
    It was definitely culling the shadows at distance. "Use Custom Shadow" let me fix it. Thanks!
     
  17. Simunek

    Simunek

    Joined:
    Jul 15, 2016
    Posts:
    49
    Hi! Is DLSS supported? I have tried it, and it almost works, but sometimes small objects disappear randomly. What should I do? thanks!
     
  18. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    Please try disabling the Use Occlusion Culling option under Scene Settings.

    GPUI utilizes the camera depth texture for calculations in Occlusion Culling (see Hi-Z Occlusion Culling). However, when dynamic resolution is enabled in HDRP, the camera depth texture becomes inconsistent and unreliable for culling purposes. Unfortunately, it is a technical limitation that Occlusion Culling is not supported with HDRP dynamic resolution.
     
  19. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    Hi,
    prefabs are not saved in GPUI. I must have missed something?

     
  20. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    It appears that the Bamboo GameObjects in the scene are not prefab instances. They seem to have lost their connection with the prefab object. Prefab instances are typically displayed in blue color in the Hierarchy window. Please refer to the AsteroidHazeQuad in the picture below for an example:
    upload_2024-3-15_20-6-29.png

    To convert these Bamboo GameObjects into prefab instances, you can use the The Prefab Replacer tool. However, make sure to backup your scene before using this tool, as it will overwrite the existing GameObjects in the scene.

    After you turn these GameObjects into prefab instances, you can use the Register Instances in Scene button to register them to the Prefab Manager.
     
  21. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
  22. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    34
    Is there a list somewhere of any good (free or paid) asset store assets for textures, terrain details (grass etc..) and trees (of a few types) that are compatible with the GPUI tree/detail managers and URP? It seems most trees are not URP and/or can't be billboarded by the tree manager on GPUI (I tend to get the message "the prefab for this prototype does not use any of the default unity tree shaders...)
     
  23. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    34
    My other question concerning the tree manager is tree view distances. They show up at a large distance in the editor, but only as billboards in the build. Is that some setting somewhere? https://imgur.com/a/qhETduF
     
  24. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    34
    I get a similar problem, here showing in editor and in game, for the billboards/distance and for a topographic plane I put over the map at a sufficient height. It's almost like the map is blurrier? https://imgur.com/a/Zdls81j

    the grass is also much taller in the build or in play in editor than it is in the editor without playing: https://imgur.com/a/oYpbwKm
     
  25. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    The Billboard Distance setting functions similarly to the LOD Group component's selection bar. It's based on the ratio of the GameObject's screen space height to the total screen height. For example, when you set the billboard distance to 0.9, it behaves similarly to 10% on the LOD Group selection bar; when it's 0.8, it's like 20%.

    The resulting value can also be affected by the QualitySettings.lodBias value. This is likely why you're experiencing different results in your build. You may be using a different Quality setting in the build.

    The Detail Manager uses a custom noise map for determining the height/width of the detail instances. As a result, it will not precisely match the Unity built-in terrain details. If you wish to minimize the difference between the minimum and maximum height of the detail instances, you can adjust the Detail Scale value under Detail Properties.
     
  26. Rail9

    Rail9

    Joined:
    Feb 21, 2020
    Posts:
    28
    Hi.
    I set up a node as shown in the image to use a shader in GPUI that uses a creator's shader graph called SineFX, but an error message is displayed as shown in the lower left.

    How can I solve this problem?
     

    Attached Files:

  27. ArIaNFury008

    ArIaNFury008

    Joined:
    Dec 22, 2019
    Posts:
    29
    Hi, Thanks for your assets it's amazing! I have some questions: (Simple answers is enough don't want to take your time)

    1- I serialize Rigiestred Instances and works fine but is this like Non-GameObject Cause Colliders and game object not visible in Hierarchy during playmode?

    2- is there any way to get data like position/rotate/scale of specific instance from prototypes? especially in Tree and Detail Manager?

    3- Can we set the GPU Prefabs on the ground and then with codes convert them to Non-GameObject Matrix and save memory and performance? and also again convert it to GameObject whatever needs?

    4- is there any way when you culling a Prefab (GPUI Prefab Manager) also disable the Object (Set active to false)? cause when we can't see the object it doesn't need to have the collider turn on. I saw the "PrefabInstancingDemo" where the Culled Rock still had Collision and game object Enabled. isn't better to turn off Colliders and objects where we don't need it?

    5- I want to use GPUI Prefab Manager and place all of my objects manually. Would 500000 GameObject in Hierarchy cause me problems and What do you suggest for maximum performance in this situation? (Non-Gameobject doesn't support the colliders but I need for most of them, also 500000 is for multi objects or all of my vegetation and trees)

    6- if I have like 5000 object of Fern or bushes in my scene and only render 100 of them near the player should I use Unity default render or Gpu Instancer? (~400 Tringles with LOD and Amplify Imposter, Also I'm Currently using The vegetation engine and it doesn't support Static Batching) What is the best approach here?

    Thanks sir have great day! (Sorry if some of my questions noob)
     
    Last edited: Mar 22, 2024
  28. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    I was unable to reproduce the issue. If you could contact the support email with a sample project by following this guide, I'll be able to investigate the issue.
    However, please note that Shader Graph currently does not support GPU instancing in the Built-in render pipeline. If you're using the Built-in render pipeline, GPU instancing will not function with Shader Graph shaders.
     
  29. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,
    and thank you for your kind words.

    1- The "Serialize Registered Instances" button removes the GameObjects and renders them using the No-GameObject workflow. Any components previously attached to the GameObjects, such as Colliders or custom scripts, will no longer function.

    2- The Tree and Detail Manager store transform data in GPU buffers, which are not accessible on the CPU side. Compute Shaders are used when modifying the buffers, such as with the RemoveInstancesInsideCollider API method.

    3- When using the No-GameObject workflow to render instances, you can still add GameObjects for other functionality, like Colliders. Ensure to disable or remove the Mesh Renderers on these GameObjects to avoid rendering them twice.

    4- GPUI performs culling operations on the GPU, and this information is not available on the CPU side because reading back data from GPU is a slow process.

    5- 500k GameObjects can lead to performance issues. One potential solution is to adopt a hybrid approach. For example, use the No-GameObjects workflow to render the 500k instances and implement Object Pooling to add Colliders to a limited number of instances.

    6- Performance can vary based on multiple factors. It's advisable to conduct testing to determine which option yields better performance. If there's no noticeable performance improvement when rendering instances of a prefab with GPUI, it's generally better not to use GPUI for rendering.
     
    ArIaNFury008 likes this.
  30. ArIaNFury008

    ArIaNFury008

    Joined:
    Dec 22, 2019
    Posts:
    29
    Thanks this was really helpful, I completely forgot all of the Implementation is on the GPU side and we can't read data on the CPU!

    useful information :p
     
  31. ArIaNFury008

    ArIaNFury008

    Joined:
    Dec 22, 2019
    Posts:
    29
    Hey me AGAIN, I found a bug I don't know if it's because of the GPU instancer or TVE (UNITY HDRP 2022.3.21f, GPU Instancer, The Vegetation Engine)

    Issue Detail: LOD CROSS Fade with TVE (HDRP)

    reproduce the issue:
    Enable the LOD CROSS fade and Enable Runtime Modification for vegetation (The Vegetation Engine)
    then using "GPU Instancer Modification Collider" for Removing Instances and converting them to Gameobject.

    when you reach the object, the object disappears even LOD GROUP turns on but the material is invisible
    (if you disable the LOD Cross Fade everything works fine)

    I can send a video if you need it. I don't know if I should report the bug here or TVE Forum.
     
  32. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Hi there,

    Enabling the cross-fading keyword on the material might be causing issues when the instancing is disabled. Please go to Edit -> Preferences -> GPU Instancer and disable the Use Original Material When Instanced option and see if it solves the issue.
    You might need to close and reopen the project after disabling this option to reset the material keywords.

    upload_2024-3-24_4-3-36.png
     
    ArIaNFury008 likes this.
  33. Rail9

    Rail9

    Joined:
    Feb 21, 2020
    Posts:
    28
    I'm using built-in and will not be using them this time, but do you have plans to support built-ins in the future?
     
  34. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    It's not a lacking feature in GPU Instancer; rather, Unity's Shader Graph currently doesn't support GPU instancing in the Built-in render pipeline. Unfortunately, to my knowledge, there's no information available about when Unity might add support for it.
     
  35. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    Some rocks lose their collider with GPUI and the player passes through. For what ?
     
  36. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    GPU Instancer does not control colliders. However, if rendered objects change position at runtime and the GPU buffers aren't updated, they might appear in their old positions, causing a mismatch with collider positions.
    If you are using the Prefab Manager, make sure to enable the Auto. Update Transform Data option for moving objects. If you are using the Tree or Detail Manager and the terrain is moving at runtime, please enable the Use Floating Origin option.
     
  37. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    I can't find the Auto option. Update Transform Data!
    Where is she ?
     
  38. ArIaNFury008

    ArIaNFury008

    Joined:
    Dec 22, 2019
    Posts:
    29
    Thanks now it works great!

    I'm sure you heard of GPU Resident Drawer which is accessible in Unity 6, is that the same as GPU Instancer?
    Can we work with both of them and gain more performance?
    As much as I read about GPU-driven Driven Rendering it seems like it does have too many issues and does not support many cases but I want to know your suggestion.
     
    Last edited: Mar 26, 2024
  39. heartingNinja

    heartingNinja

    Joined:
    Mar 26, 2015
    Posts:
    36
    I have been thinking of an easy way to do a no game object work flow.

    My idea, keep an dictionary of each position and each mesh. Make a pool of the meshes with a collider.

    Only look at position that are on the terrain the player is on to limit the position that are checked. Or have boxes that split the scene and only look at positions that are in the box. To limit distance checks. When the player is in a box have the the mesh colliders go to the place it is needed.

    Some editor script to record these meshes and positions to be able to destroy them when building the game would make things easier.

    On my test making a large city I have gone from under 50 fps to over 70 just deleting game objects. I have over 70 protypes with almost none at 100 in the scene. Decreasing the game objects alone has been a huge performance increase. I am thinking of making this solution for an easy no game object work flow but what do you think?

    Record and remove all game object to be rendered on build. When a player is close move a collider to the position.
     
  40. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    upload_2024-3-27_9-46-25.png
     
  41. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Based on my understanding, GPU Resident Drawer is a new GPU instancing solution with several optimizations. It serves a similar purpose to GPU Instancer. However, you cannot use both GPU Instancer and GPU Resident Drawer for the same objects, as they are two distinct rendering systems. At present, performance-wise, GPU Resident Drawer does not appear to match the performance of existing indirect GPU instancing solutions. However, it's too early to make a definitive judgment on its capabilities.
     
    ArIaNFury008 likes this.
  42. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    You can follow those steps to address performance issues related to GameObjects. However, it's important to note that GPU Instancer is specifically designed to optimize the rendering of many instances of the same objects. If you have very few instances, using GPU Instancer may result in unnecessary resource usage. In scenarios where there are very few instances but you still wish to eliminate GameObjects, it might be more efficient to use the Graphics.DrawMesh or Graphics.RenderMesh methods directly.
     
  43. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
  44. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    I checked the Auto.Update Transform Data option but the rock still has no collider!

     
  45. Rail9

    Rail9

    Joined:
    Feb 21, 2020
    Posts:
    28
    I understand.
    Sorry for the late reply.
     
  46. ThemasterL

    ThemasterL

    Joined:
    Aug 30, 2019
    Posts:
    3
    I don't know if my answer will be useful when the introverted habit that I have about messages does not help much, I used the GPUI package together with Nature render, until I saw that in other sader it does not apply and they become "invisible", analyzing it turns out that nature render uses the "Lod Cross Fade" formula as "void" within the fragment output FRAG", I must assume that in this way the value of "unity_LODFade.x" becomes "persistent" than in other shaders with the GPUI and the cross fade activated, it always returns 0 now for better use of performance since I see people who do worse using the GPUI, it does not work miracles including the use of JOBS that it has, it renders objects but considers that each 1 is checked and analyzed if It is visible to the player's camera, the distance of the shadows, the position with the original transform, and although it is deactivated, it still counts as an object in the list of objects, it is best to set its automatic activation with the "GPUI prefab" component handler" and script a sphere colider and when you enter and exit the sphere, you save a lot of object loading. and to go further in performance the GPUI for the prefabs you have to invoke the "ClearInstancingData()" function after changing the graphic quality, with that it adjusts the objects to the current "LOD BIAS", and if it adjusts to the script range of objects, much better, fewer objects to take into account. for example my 2 codes for limit object in GPUI is:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using GPUInstancer;
    using System.Linq;

    public class OcclusionRange : MonoBehaviour
    {
    public LayerMask layerMask;

    public List<Dinamyc_Add_Remove_Intancing> ObjectsAdd, ObjectLess;
    public float CounReseting;
    private float ReservCoun;


    void Start()
    {
    ReservCoun = CounReseting;
    }

    void Update()
    {
    if (CounReseting < 0)
    {
    CounReseting = ReservCoun;
    if(Manager.enabled)
    {
    if (ObjectLess.Count > 0)
    {
    var sortedObjectLess = ObjectLess.OrderByDescending(obj => obj.prefabObject.gpuInstancerID).ToList();
    List<GPUInstancerPrefab> ListRemoved = new List<GPUInstancerPrefab>();
    foreach(Dinamyc_Add_Remove_Intancing target in sortedObjectLess)
    {
    target.PrefabHandler.enabled = false;

    ListRemoved.Add(target.prefabObject);

    }

    ObjectLess.Clear();

    }

    if (ObjectsAdd.Count > 0)
    {

    foreach (Dinamyc_Add_Remove_Intancing target in ObjectsAdd)
    {
    target.PrefabHandler.enabled = true;
    }
    ObjectsAdd.Clear();

    }
    }

    }
    else
    {
    CounReseting -= Time.deltaTime;
    }
    }

    private void OnTriggerEnter(Collider other)
    {
    if ((layerMask.value & (1 << other.gameObject.layer)) > 0)
    {
    var instancer = other.GetComponent<Dinamyc_Add_Remove_Intancing>();
    if (instancer != null)
    {
    if (!ObjectsAdd.Contains(instancer))
    {
    ObjectsAdd.Add(instancer);

    if (ObjectLess.Contains(instancer))
    {
    ObjectLess.Remove(instancer);
    }
    }
    }
    }
    }

    private void OnTriggerExit(Collider other)
    {
    if ((layerMask.value & (1 << other.gameObject.layer)) > 0)
    {
    var instancer = other.GetComponent<Dinamyc_Add_Remove_Intancing>();
    if (instancer != null)
    {
    if (!ObjectLess.Contains(instancer))
    {
    ObjectLess.Add(instancer);

    if (ObjectsAdd.Contains(instancer))
    {
    ObjectsAdd.Remove(instancer);
    }
    }
    }
    }
    }

    } and:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using GPUInstancer;

    public class Dinamyc_Add_Remove_Intancing : MonoBehaviour
    {

    public GPUInstancerPrefab prefabObject;
    public GPUInstancerPrefabRuntimeHandler PrefabHandler;
    public List<GameObject> RenderList;
    public LODGroup Lod;
    public bool StartDisable;

    private void Start()
    {
    if (StartDisable) DisableRender();
    }
    public void DisableRender()
    {
    if (Lod) Lod.enabled = false;
    for (int i = 0; i < RenderList.Count; i++)
    {
    RenderList.SetActive(false);
    }
    }

    public void EnableRender()
    {
    if (Lod) Lod.enabled = true;
    for (int i = 0; i < RenderList.Count; i++)
    {
    RenderList.SetActive(true);
    }
    }
    }
     
  47. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    How to use these codes?
    You should use tags to post your code.

    It would be good to integrate these corrections into the asset because I bought this asset months ago and I still can't use it. And the price is not cheap!
     
    Last edited: Apr 2, 2024
  48. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    558
    Please contact the support email with a sample project attached so that I can investigate the issue.
     
  49. 1841

    1841

    Joined:
    Jan 20, 2020
    Posts:
    1
    Hello, there have appeared multiple tree artifacts at the position of the camera. May I ask how to solve this?
     

    Attached Files:

  50. marcell123455

    marcell123455

    Joined:
    Jun 18, 2014
    Posts:
    275
    @GurhanH
    Hey just wanted to let you know that I wrote a mail to the support mail yesterday. Just for your Information.

    Thanks