Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] GPU Instancer

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

  1. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi Everyone,

    the v1.4.0 update for GPUI is now available in the asset store and it brings in various new features.

    First off, we have added the SRP versions of the GPUI demo scenes. This includes all the shaders as well that are used in the standard demos. You will find two new packages under the GPUInstancer\Demos folder: one for URP and the other for HDRP. Importing these packages will override the materials, shaders, and in some cases terrain and scenes in the Demos folder to replace them with the respective SRP versions.

    Along with the SRP demos, we have also added HDRP support for the GPUI Foliage Shader. You can now use the terrain details with the Detail Manager in HDRP without using a custom shader.

    HDRP-Detail-Scene.png

    We have also added a new feature where you can keep the detail manager simulation live in editor time while painting details on your terrains. This will be particularly useful in HDRP since Unity still hasn't provided terrain detail shaders and the painted details on the terrain are not showing. To use this new feature, you can start simulation from a detail manager by clicking "Simulate at Scene Camera" and enable the "Keep Simulation Live" and "Update Simulation on Change" options. With these enabled, the details on your terrain will be rendered with GPUI in the editor, and when you paint details on the terrain, the manager will update its buffers (when the mouse button is released) to show the painted details on your terrains.

    SimulationOptions.png
    In line with the new SRP additions, GPUI now also supports SpeedTree7 and SpeedTree8 in URP.

    We hope you enjoy the new update. Here is the full v1.4.0 changelog:

    New: Added HDRP foliage shader support
    New: Added an override package containing the Universal Render Pipeline versions of GPUI demo scenes
    New: Added an override package containing the High Defition Render Pipeline versions of GPUI demo scenes
    New: Added Universal Render Pipeline support for SpeedTree 7 and 8 trees
    New: Added Update Simulation On Change option to update terrain detail simulation when terrain is edited in Editor Mode

    Changed:
    Detail Manager now logs a relevant error message if the required pipeline version of the GPUI foliage shader is missing
    Changed: DefineAndAddVariationFromArray now allows to use an array smaller than the buffer size

    Fixed:
    Infinite import loop issue when using Unity 2019.3 or higher
    Fixed: Obsolete virtualRealitySupported API warning
    Fixed: URP foliage shader culling back of vegetation quads
     
    ftejada and docsavage like this.
  2. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    227
    I'm not aware of any errors at all but I'll make a build and double check.

    Do you mean it checks when the game is launched or when the prefab manager is initialized when a scene loads containing a GPUI manager prefab? Right now, GPUI instancer is only in a game scene and VR has already been initialized by the time a game scene loads. How do you create the manager again since it has a custom set of objects per scene? Should I just create a prefab of each scene's manager and instantiate that prefab?
     
  3. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Reloading the scene with the manager should be enough.
     
  4. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    227
    Reloading the scene is not an option since a VR change can happen in the middle of gameplay. In SP, that would cause a loss of their current progression and in multiplayer, that would cause all sorts of syncing issues.
     
  5. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,540
    I have a question about using colliders with the PrefabManager. I'm instantiating thousands of instanced objects at runtime, so the objects and their respective colliders do not exist in the scene. As such the given method of using a "Deinstancing sphere" and the GPUI Modification collider does not work to enable collisions on such objects.

    Is there a method within GPUI (either through the interface or code API) that would handle turning on collisions on such objects, or do I need to handle adding these colliders to my scene outside of GPUI?
     
  6. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    227
    I forgot to ask but you didn't answer about when the VR initialization is done. Is this at the game start or when the first scene that uses a GPUManager prefab? I would think this would have to be in the first scene to use a manager script but wanted to check. If so, the VR init has already been done at that point so that wouldn't likely be related to the issue.
     
  7. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    85
    of course, when creating sample project then it works :) have to get down to the basic with my main project see why it didn't work there...
     
  8. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    85
    hey good news, when I create the sample project it works because I import latest version, and now I import latest version for main project, and at same time some shader got reimported and now it works.
     
    LouskRad likes this.
  9. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    75
    Hi I was wondering if Tree Instancing support LOD Groups on Unity terrain HDRP?
    looks like the HDRP terrain not full support for detail paint.
     
  10. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,540
    After reviewing your video on using collider/rigidbodies with a DeInstancing Sphere I see that in your example you are instantiating instances at runtime as well, yet you have no trouble with physics on your instanced objects. Hmmm. I'm not sure why this is not working for me, however I do notice when I click the "enable runtime modification" on my object in the prefab manager that it gets automatically unclicked when I press play, and remains unclicked when I stop playing the scene. This seems like part of my problem. Do you have any insight why this option would be disabling itself?

    EDIT!: I dug a bit into the GPUI code and saw that the InitializeWithMatrix4x4Array() function (which is what I'm using to load instanced objects) is disabling the runtimeModification option. Further I saw that in your asteroid example you are instantiating objects into the scene before initializing the prefabmanager. I don't think this will work in my case due to the huge number of objects that would need instantiating. It looks like I will need to look into other options for getting physics colliders to work.
     
    Last edited: Mar 4, 2020
  11. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    25
    The instancer works badly on gameobjects with a negative scale. (for example x=-1), is there any way to quickly fix that?

    Here is an example. http://prntscr.com/rc4ltb
     
  12. hellstorm

    hellstorm

    Joined:
    Jun 29, 2015
    Posts:
    27
    Greetings! Im unable to make grass distance go further than 250, as it just stops drawing past that point.
     
  13. VirtusH

    VirtusH

    Joined:
    Aug 18, 2015
    Posts:
    20
    Hello! I was wondering what kind of support there is for feeding GPUI with native collections? I'd like to do some stuff in burst and pass the result to GPUI if possible. Sorry to bug you, searching the forums and google didn't yield anything.
     
  14. Black_Raptor

    Black_Raptor

    Joined:
    Nov 3, 2014
    Posts:
    147
    Hi !

    I recently use WorldStreamer because i got to much object and my editor dont like that, so before split my terrain in multiple scene i use GPU Instancer Prefab Manager, and everything work perfect. But since i split in multiple scene i loose performance wih that, maybe i dont have the best parctice with GPUI Prefab Manager i have 15 scene so i put GPUI Prefab manager on each scene, but when i stream 4 scene at the same time, i got 4 GPUI Prefab Manager at the same time too ... So that broke my performance.

    So my question is simple, how to manage GPUI Prefab Manager with scene streaming ?
     
  15. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    65
    @LouskRad
    I found what looks like a GPUI bug or maybe a limitation? It seems there's a LOD animate cross fade issue with GPUI trees.

    Steps:
    -If you paint some regular/non-GPU trees on a terrain with LOD animate cross-fading, their LODs cross fade correctly.
    -If you now add a GPUI Tree Manager, those trees no longer cross fade. Instead they hard pop between LODs.

    *Important* This issue only happens at runtime. Oddly, if you move the camera around in the Scene viewport, the GPUI painted trees HAVE correct cross fading, but at run time they do not.
    upload_2020-3-10_2-1-48.png
     
    Last edited: Mar 10, 2020
  16. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    142
    Sorry For The Late Reply , I will Get Back To You After Checking That .
     
  17. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    VR setup is initialized during the first manager initialization in the scene, where GPUI determines the required compute shaders to use. Currently GPUI does not offer a feature to auto-detect switches between VR and non-VR usage at runtime. We will look into providing an API to change this behavior in a future update.
     
  18. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi Chingwa,

    The "modification collider" is not named as such because it handles colliders, but rather it disables instancing for instances inside a given (trigger) collider.

    What you are asking for seems to be whether there is a collider pooling system that comes with GPUI, and the answer is no. That is, if you are using GPUI with the no-game object workflow, GPUI will only handle the rendering, and you will need to handle the colliders (and rest of the gameobject physics) yourself manually.
     
    chingwa likes this.
  19. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi,

    Yes, you can use LOD groups with prefabs. If you have your prefabs are trees that are defined as tree prototypes on the Unity Terrain, GPUI takes the reference prefab object and renders it as it would any prefab. The same is true for prefab type detail prototypes on the Unity Terrain.
     
  20. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Negative scaling is not supported. This is a hacky solution which has further complications for detailed operations on matrices. So, this limitation is related to how matrix calculations work on GPUI's compute shaders.
     
  21. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    227
    While that is important and a needed feature, that's not what's causing the issue as this happens even when the VR headset is turned on prior to the scene loading. Can you help diagnose what's going on here? It looks like some sort of culling issue related to the VR fov but I'm not certain. If you can give me some areas to check or things to try, that would be great. When it happens, very slight movement of the headset causes the geometry to disappear and re-appear.

    Also, is there a way to reach you via Discord or e-mail as it seems you only respond here once a week and we're dealing with a number of issues and we need a little better way to work through these.

    Currently we have a PS4 game in development and the port of a different PS4 game to PC VR and we're having a number of issues ranging from incompatibility with Horizion Based AO, issues with real time lights, and a crash when using the tree manager. These all occur only the PS4 and not on the PC and it would be ideal if we could get a response faster than once a week.

    Thanks,
    Reggie
     
  22. LouskRad

    LouskRad

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

    Please check that all your prototypes show the correct max distance setting in the Detail Manager.
    If the prototype values are correct, and if you are using a custom grass shader, it can be limited from inside that shader as well.
     
  23. LouskRad

    LouskRad

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

    You can use the API to get the GPUI data buffer (GetTransformDataBuffer) and use Unity's ComputeBuffer.SetData to set the buffer as you wish.
     
    Bzuco likes this.
  24. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,540
    Thank you for the clarification. Since I was already storing my instanced object data in a List, I wrote some functions that parse the list for nearby objects and automatically combine their collider meshes into a dynamic local collider object as I move around the scene. It works great as long as the colliders aren't too complex. Now I have the benefits of instancing hundreds of thousands of objects (physics and all), with very little impact on the scene, something I would not have thought possible in Unity a couple years ago. Thanks!:)
     
    LouskRad likes this.
  25. LouskRad

    LouskRad

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

    If you are using the same prototypes in all your scenes, you can persist a single Prefab Manager and use the Auto. Add/Remove Instances option on your manager. This would be better in terms of performance then having a Prefab Manager in each scene.
     
    Black_Raptor likes this.
  26. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi Dobalina,

    GPUI integrates into Unity's build in shader cross fading system and uses that. Can you tell us which Unity version and which tree shader you are facing this issue with?
     
  27. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    Hi Reggie,

    Did you check this wiki F.A.Q and see if it solves your problem?
    As for HBAO, it might be related to how the depth texture is handled with your rendering mode, which is explained in this wiki F.A.Q.

    If you are having further issues, please email us detailed explanations of how to re-create them (and if possible, a sample project) and we can investigate these issues.
     
  28. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    65
    @LouskRad I'm on 2018.3.8f1. The shader I've mostly used was the 'Standard_GPUI' shader. I've tested this issue with a couple different shaders that support cross fading, those too stopped working when the tree manager is added.
     
    Last edited: Mar 10, 2020
  29. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    227
    Thanks, those Wiki links look like they may help with the less serious issues. I've e-mailed you about the crash as that's the critical one right now. Can you check and make sure you received it? Sometimes my e-mails end up in spam.
     
  30. jb106

    jb106

    Joined:
    Jul 25, 2017
    Posts:
    2
    Hello ! I have a weird bug. Recently, i updated my project to Unity 2019.3.4f and when i try to add trees with the GPUI Tree Manager, it works with just one tree added as a prototype. But as soon as i have more than one tree in the prototypes (and painted on my terrain) he just won't render more than one tree prefab.

    It was working before, maybe it is because of the version, but after many test i cannot find a solution. So to resume, if i add one prefab to the prototype i can paint it as many times i want on my terrain, it works just fine. But if i add a second one and paint it with the first one on the terrain, it won't be rendered. Now if I erase all first tree in my terrain, the second who was invisible at first will be renderer. I hope this was clear.

    Unity 2019.3.4f1
    High Definition RP 7.1.8

    If you have an idea about that, it would be great. Thank you in advance !
     
  31. ManaPotionStudios

    ManaPotionStudios

    Joined:
    Dec 26, 2016
    Posts:
    11
    Hello!

    I've purchased your instancing assets and they work very well! I get significant performance boost. But I have a question. Is it possible to get positions of bones transforms at some point? While using unity default animator I was able to create ragdoll by adding rigid bodies, colliders and joints to selected transforms when agent dies. Or even better, is they a way to convert instanced object back to gameobject at some monent? Thanks alot!
     
  32. hellstorm

    hellstorm

    Joined:
    Jun 29, 2015
    Posts:
    27

    Greetings ! My prototypes are set to all try to use larger than 250 distance .

    The grass is default unity grass . Just added a texture and painted it. Then added gpu instancer to the scene. This is in a brand new 2019.3 project .

    The editor veiw shows it stops at 250 as well.
    I'll double check the example scenes. Maybe im missing something...
     
  33. Corvostudio

    Corvostudio

    Joined:
    Jul 19, 2015
    Posts:
    8
    Hello. I'm using your assets to try to replace unity grass only for the moment. Following your tutorial, I added the Terrain Proxy to a configured terrain and the GPU detail manager. Everything is working exactly as expected in the editor and I can get a nice preview in the debug mode.
    But at runtime grass is not showing at all.
    What could I am doing wrong?
    A couple of times I was able to make it working at runtime, first time i managed to change many settings and then suddently without any cause it started working, and the second time I was testing it on a Nintendo Switch and after 30-60 seconds of nothing working some giant grass started spawning and then it crashed after a few seconds.
     
  34. ManaPotionStudios

    ManaPotionStudios

    Joined:
    Dec 26, 2016
    Posts:
    11
    Nvm I figured it out. If anyone will need something like this, you can get current animation clip and time from GPUICrowdPrefab.crowdAnimator.currentAnimationClipData[0] and then just fill it into regular unity animator
     
    LouskRad likes this.
  35. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    268
    Hi

    I bought GPUInstancer a long time ago. My goal was to optimize vegetation as my scenes have lots of trees and plants.

    So far I have used VEGETATION STUDIO PRO to do it. But lately product quality has dropped and SPFs have dropped dramatically. So I have started using GPUi to see how it was going.

    I have to say that in the first tests everything seems to indicate that the optimization of the scenes is much better than with VS. However, I find a series of problems that I will be counting on in this forum (as long as I do not already find the solution)

    The first is performance in the editor. He is "dead". I have added, between trees and plants, about 25,000 objects. Now it occurs to me that to do anything, even move a stone, the editor is slowed down.

    Is there any way to avoid this?

    Thank you.

    Unity 2019.2.21f1
    GPUInstancer 1.40
    i7-4790 / 32Gb RAM / NVIDIA GTX1060 6Gb.
     
  36. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    268

    Okay.

    If I deactivate the grass objects that I have created, it works fine again.

    I lose the reference of the place where I have put them, but well ...
     
  37. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    268

    Although this seems like a monologue, I continue.

    I can work in the editor if I disable all objects that are grass. About 30,000 approximately.

    The problem is that it takes a long time to start editing tests, and it takes a long time to stop.

    And, even worse, is that when I test the game with the standalone build (windows 64) the scenes take a long time to load with what the feeling of the game is not good.

    Let's see if someone can help.

    Thank you.
     
  38. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    142
    I am Facing a very serious problem right now , when i add tree manager and play the scene the billboards of the trees seems very wrong , instead of 1 billboard of the size of tree i see two small billboards for every tree , also if i add any small plant smaller then trees on the terrain then the plant disappears from the screen on play mode , and cant even see their billboards from the main camera , to see the billboards i havr to go in scene view and then had to find the billboards manually lol , I Regenerated the billboards also ticked billboards always face player option , but still no solution , For Experimenting i put the plant close to the trees and in play mode if i go and stand on the position of the plant then on the plant shows otherwise it disappears. How to fix this ,i am using trees and plants from Ultimate Nature Pack From Black Horizon Studio. Help me guys.

    I am Using Unity 2019.3.3f1 with GPUI v1.4.0
     
  39. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    80
    Hello, I am not having much luck with MapMagic and GPU instancer. I have a simple scene with a MapMagic terrain with many trees rocks and grasses. When I run the MapMagic integration everything works as expected. Hit import, looks good. Using a standard "Main Camera tagged MainCamera" .

    However when I build and run it is showing a slower frame rate (using this script). I tried to make sure that I am using metal in the editor and build (see screens) any help is appreciated.

    [Update] I remembered an old thread where you had mentioned that the advantages of GPU won't be seen unless there is large number of objects. I upped the trees to a huge number. Without GPU instancer 6fps with GPU instancer 4gps. As a second test, I went into all of the materials and tried all plant and tree shaders with and without "Enable GPU Instancing" no difference]

    TY!!!












     
    Last edited: Mar 14, 2020
  40. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    65
    @LouskRad I figured out the terrain tree LOD cross fade issue. My tree prefabs had crossfade enabled, but the GPU prototype had it disabled.

    I found another puzzling issue. When the GPU tree manager is enabled, my tree LODs shift, bringing unwanted higher LODs into view. I noticed this shift in LODs became lessened if the camera was lowered to the floor, greater if higher in the sky. Here's an example only using GPUI assets and materials. Yellow is the LOD0, Red is LOD1, Grey is LOD2 and LOD3 is green. When the GPU tree manager is disabled, LOD0 is out of view which is the desired and expected result. But when the GPU tree manager is enabled, LOD0 now jumps into view which is undesired.

    The issue demonstrated in this gif is minor compared to the extreme shift I see with my own tree prefabs. So much so, my LOD0 are showing from thousands of units away! But looks correct when I turn off the tree manager. 'Use Prefab Scale' in the prototype made no difference. Any ideas?
    I'm on the latest GPUI and Unity 2018.3.8f1

    LODdistance.gif
     
    Last edited: Mar 16, 2020
  41. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    142
    Ya Something is Wrong , Is MY Scenes Also The Plants LOD Is Messed Up , Plants Get Culled Unless Player Is in 1 cube Range.If Player is More Than 1 meter away from Plant Then It Disappear which means LOD Culls And When Player Get Close Under 1 Meter Then Plant Reappear Means LOD0 Appears. However This only Happens When GPUI Is Enabled For Trees From Either Tree Manager Or MapMagic Integration , But When I Disabe GPUI Then All Becomes Fine All LODs Work Normal . This Is a Serious Issue For Me , Any Help Fixing this is appreciated.
     
  42. LouskRad

    LouskRad

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

    we have made some tests with these Unity and HDRP versions and could not replicate this issue. Are you getting any console errors when this happens? If so, please email them and a sample project that shows this issue to us so that we can investigate the problem.
     
  43. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    A GPU readback of the bone matrices would not be ideal performance-wise. You can disable instancing for the instance using the API, but another way would be to remove the instance and instantiate the ragdoll prefab at the same position and use ragdoll as you normally would.
     
    ManaPotionStudios likes this.
  44. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    The issue is probably that your target platform does not meet the minimum requirements. GPUI does not support Nintendo Switch.
     
  45. LouskRad

    LouskRad

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

    unlike VS, GPUI does not offer a dedicated editor design toolset, so it would not provide you stable editor time instancing. Having said that, GPUI provides you some tools to implement your own design workflow; such as the "Serialize Registered Instances" and "Disable Mesh Renderers" options under Advanced Actions in the Manager. You can also utilize the Editor Only API methods to further customize your workflow.

    Please note, however, that if you have that many objects, it would be ideal to use a no-game object workflow for the best performace. This would also help with load times since Unity will not be instantiating GameObjects for your instances.
     
  46. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    818
    I'm not sure if I understand the problem, can you provide a video or email us a sample project showcasing this issue so that we can investigate it?
     
  47. LouskRad

    LouskRad

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

    There might be various reasons for this. I can't tell much without the project details, but If you can email us a sample project that shows the problem, we can investigate the issue.
     
  48. LouskRad

    LouskRad

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

    for internal reasons, GPUI uses a different LOD calculation algorithm than Unity's which might in some cases result in different LOD distances. You can adjust the LOD Bias Adjustment setting in the manager for your prototypes to get the desired LOD switching distances.
     
  49. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    65
    @danteswap @LouskRad

    Lod bias or grouping size didn't fix this issue. Even if I make LOD1 fill the entire group, I'm still seeing LOD0 from a great distance.
    upload_2020-3-16_23-56-1.png
    Fortunately, by luck I found part of the issue. For some odd reason, if any of the models within the LOD group are not positioned close enough to 0.0.0 of the prefab, then this issue would happen. In my case, my last LOD was positioned a few units up in the air. Once I re-centered it, my LOD distances with the GPUI tree manager started to work as desired.
     
    Last edited: Mar 17, 2020
  50. ManaPotionStudios

    ManaPotionStudios

    Joined:
    Dec 26, 2016
    Posts:
    11
    Hello! Is it possible to update Terrain details layer at runtime? As I have dynamicly generated and removed grass on my terrain. I can update grass in unity terrain, but to update it in SetDetailLayer I need to disable and then enable script wich leads to immage flickering.
     
unityunity