Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

[RELEASED] GPU Instancer

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

  1. Slick_Nick

    Slick_Nick

    Joined:
    Jan 4, 2014
    Posts:
    36
    Hello!
    Really impressive work!

    Im working on a split screen game and i noticed that culling is based on a single camera. Is there any plans on enable multiple camera culling?

    Best regards /Niklas
     
  2. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622
    Hi there, and thanks!

    We will investigate what we can do for multiple-camera support and see if we can integrate culling safely without compromising performance - it could turn out to be that culling calculations actually do more harm than good with a multiple camera setup.
     
  3. madsky

    madsky

    Joined:
    Aug 14, 2018
    Posts:
    3
    thx :D
     
  4. madsky

    madsky

    Joined:
    Aug 14, 2018
    Posts:
    3
    ok, maybe i have not to register it.:D
     
  5. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    621
    Hi @LouskRad

    Forgive me if it's been answered previously in the thread, but does SpeedTree support require a terrain? What if they are manually placed in a modeled environment? Thank you.
     
  6. GurhanHazinedar

    GurhanHazinedar

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

    You can use the Prefab Manager to define grass/tree prototypes which does not require any terrain. Prefab Manager works with prefab instances and also includes SpeedTree support.
     
    lod3 likes this.
  7. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    621
    Excellent. Thank you.
     
  8. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    444
    Hi GurhanHazinedar,

    i just make my firsts test using GPU Instancer, and while it works perfectly with terrain for both trees and details meshes, i can't make it work for my prefabs

    as you can see on the attached screenshots, i have an error message, and the result is displaying only few objects, not the others and the camera is displaying all of them, no frustrum.

    NullReferenceException: Object reference not set to an instance of an object

    so it doesn't work for an obscure raison.
     

    Attached Files:

  9. GurhanHazinedar

    GurhanHazinedar

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

    It looks like there is an LOD level without a renderer or missing a MeshFilter on the renderer. We will add a proper warning here on the next update.
     
  10. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    444
    Thanks GurhanHazinedar,

    you were right a LOD was empty. this corrected the problem.

    but i encountered another one, and this one is caused by Oclusion Culling.
    as you can see on this screenshots, when deactivated it 's perfect.
    activated there are holes, and debug camera is displaying large white areas here, activated or not by the way.
     

    Attached Files:

  11. LouskRad

    LouskRad

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

    Looks like this one is a shader issue. It also looks like it can be caused by the shadow pass of the shader since the rest of the geometry looks fine.

    This error usually happens where the vertex shader does not setup the instance ids properly. You can add the setup to the beginning of the vertex function of the shader to solve this, for example like:

    Code (CSharp):
    1. v2f vert(appdata_full v)
    2. {
    3.      v2f o;
    4.      UNITY_SETUP_INSTANCE_ID(v);
    5.      ....
    6. }
     
    blackant likes this.
  12. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    444
    i fund this part in the shader, don't know if it's the same as your code, i'm not a specialist in shaders

    v2f_surf vert_surf (appdata_full v) {
    UNITY_SETUP_INSTANCE_ID(v);
    v2f_surf o;
    UNITY_INITIALIZE_OUTPUT(v2f_surf,o);
    ...
     
  13. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622

    Probably there is a shadow pass where this setup is missing. If you send us an email at support@gurbu.com we can help you edit the shader.
     
    blackant likes this.
  14. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    119
    Hey @LouskRad. I see that your asset is on sale and am interested in getting it. I was wondering if this asset is compatible with Vegetation Studio.
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622
    Hi there and thank you for your interest in GPUI.

    GPUI uses indirect instancing techniques for rendering vegetation, and VS also uses GPU instancing internally. Because of this, a blend with both assets would not work out of the box in terms of vegetation. However, you can still use GPUI to render your non-vegetation prefabs (or some vegetation items as prefabs) with all the GPU culling and transform update features even if you use VS for your vegetation - they just won't work for the same objects.
     
  16. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    119
    Thanks for the reply. So what I understand now is, Vegetation Studio and GPUI can work together side by side, but on different objects.

    Ex.) Vegetation Studio on foliage and trees. GPUI on rocks.

    Is this correct?
     
  17. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622
    Exactly.
     
  18. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    55
    Any updates on an integration with Amplify Imposters yet?
     
  19. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622
    Hi there.

    We're in contact with the Amplify Team and still in the process of making this integration.

    Currently, if you have an Amplify Impostor as an LOD level in your prefab's LOD Group (or simply have a prefab that is an Amplify Impostor) GPUI will out of the box work with it.

    You can also currently use Amplify Impostors with the custom billboard option in the billboard settings of the managers:

    upload_2018-11-21_3-34-46.png

    That way, you can replace the GPUI generated billboard with the Amplify Impostor while still using GPUI's billboard settings.

    We will let you know when the full integration is ready.
     
    AthrunVLokiz likes this.
  20. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622
    Hi everyone,

    We've just uploaded a video that shows some of the features of GPU Instancer:

     
  21. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    107
    Hi, I've seen the video where you instance asteroids at runtime, I have a question: in the case of having to constantly instantiate and destroy asteroids, would your asset work with a pool of objects? As this: https://unity3d.com/es/learn/tutorials/topics/scripting/object-pooling

    Another doubt I have, think of a game like Minecraft, where the world is generated with pieces of land (chunks). If a chunk is instantiated with your asset that is a plain and, below it, another chunk that is an underground cave, would the cave not be rendered because is covered by the chunk of the plain?
    The same question would be for a mountain. Would the chunks be rendered behind a chunk that is a mountain?
     
  22. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    119
    Hey @LouskRad. I just watched the video of the GPUI features. I saw that it supports compute shaders. We currently use TC Particles as our GPU based particle system which uses compute shaders. Is GPUI is compatible with it?
     
  23. Sv3nSv3n

    Sv3nSv3n

    Joined:
    Dec 26, 2017
    Posts:
    1
    Hi, I've purchased this yesterday. But I'm wondering how to get it work with a Roughness-Material Setup. It say's I can't use it with this kind of Material.
     
  24. pannakakor

    pannakakor

    Joined:
    Oct 4, 2018
    Posts:
    3
    Hi, just wanted to let you know that there is a casting errors with Unity 2019.1.0a9.

    Assets\GPUInstancer\Scripts\Editor\GPUInstancerEditor.cs(176,36): error CS0029: Cannot implicitly convert type 'UnityEngine.GameObject' to 'Object'

    Assets\GPUInstancer\Scripts\Editor\GPUInstancerEditor.cs(180,37): error CS0029: Cannot implicitly convert type 'UnityEngine.Texture2D' to 'Object'

    Assets\GPUInstancer\Scripts\Editor\Integration\GPUInstancerMapMagicEditor.cs(400,132): error CS1503: Argument 3: cannot convert from 'GPUInstancer.GPUInstancerMapMagicIntegration' to 'Object'


    (quick update: this is an issue with my own project, not with the asset)
     
    Last edited: Nov 21, 2018
  25. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622


    Hi there,

    GPUI would work nicely with object pooling since it works with all cases whether you disable/enable, reposition or destroy instances.

    GPUI's occlusion culling works with the scene's drawn geometry, and hides all instances (that it is rendering) if those instances are not visible. So this would work for the chunk-like environment if those chunks are defined as prototypes. However, please have it in mind that GPUI uses the depth texture to do this in the GPU, so the precision of what will be culled depends on the precision of the depth buffer - so the instances that are very close to the actually visible geometry might not always be culled. Nothing would be culled of course, where it shouldn't be culled.
     
    Duende likes this.
  26. LouskRad

    LouskRad

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

    GPUI does not out of the box integrate with any third party compute shaders - but since all the instance data is handled by compute shaders in the GPU, you can manually integrate your own (or third party) compute shaders by manipulating this instance data further with them without reading the data back in the CPU and before rendering a frame.

    We will be adding an example scene in the near future that showcases this, but a generic integration solution is not feasible since it depends on too many custom factors.
     
  27. LouskRad

    LouskRad

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

    GPUI does not come with all the setup versions of the Unity built-in shaders. These shaders can be downloaded from the Unity web site and if they are in the project, GPUI automatically handles them.

    Or, if you send us a mail at support@gurbu.com, I can send you a setup version of the necessary shader that will work with a roughness setup.
     
  28. LouskRad

    LouskRad

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

    We have tested GPUI with Unity 2019.1.0a9 and did not see these errors.

    It looks like these errors are compiler related. Are you using any packages from the Unity Package Manager or any extensions which might interfere with the .Net compiler? Also, what OS are you using?
     
  29. pannakakor

    pannakakor

    Joined:
    Oct 4, 2018
    Posts:
    3
    Thanks for the lightning fast reply. You're right, it is an issue with my project. I put your asset in a new project under 2019.1.0a9 and it ran just fine.

    However, I don't have any packages that interfere with the compiler. I'm on Windows 10.

    I'll try to do some troubleshooting on my own with other installed packages.
     
  30. daniel-griffiths

    daniel-griffiths

    Joined:
    Jun 14, 2016
    Posts:
    27


    Many thanks for the detailed reply. will be picking it up in the sale! thanks again
     
  31. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    Hey, I'm implementing all of my prefabs into the scene with GPUI.
    And the results is not very impressive, seems the amount of tagged colliders in unity is slowing things down.
    Here I got some screenshots showing the status:
    upload_2018-11-23_19-30-2.png
    This is when recording, editor overhead and profiler speed is insane.

    By disabling the profiler record, the FPS can reach 30 unstably:
    upload_2018-11-23_19-33-36.png

    And here is a list of my prototypes:
    upload_2018-11-23_19-49-28.png
    upload_2018-11-23_19-49-42.png

    Am I putting too many prototypes into the system?
    How do I further optimize it?
     
  32. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,171
    not chance to make this work with android opengl 2? I've just checked google stats and about 55% of devices are still running on opengl3+2 (not 3.1) and about 25% on opengl 2, that means releasing something that only runs on opengl 3.1 would block half of the market :(
    maybe a possibility to auto detect what version of opengl is running and fallback to other method?
     
  33. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622
    Hi.

    From the screenshots it looks like the slowdown is caused by (a) the editor overhang while you do the deep profiling and (b) the physics update where you are not profiling. GPUI does not have anything to do with any of these operations, so I'm not sure I understand your question?

    As for the amount of prototypes, it is OK to use as many prototypes as you would need but you would not get the desired effect from GPU instancing from the prototypes where you have low instance counts (such as 0018_FlintSlate_TC where you have 2 instances in total). The performance gain would scale with the instance counts, so I would recommend adding the highest instance count prototypes first (those that are above 1k) and progressively adding lower counts while checking for performance improvement.
     
    Harekelas likes this.
  34. LouskRad

    LouskRad

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

    GPU instancing and Compute Shaders are not supported by the OpenGL 2 or 3 platforms, so it is not possible to use GPUI with those target devices. However, as you said, it is possible for you to implement a fallback system where you use GPUI for higher-end devices and do not use it if the target platform does not meet the requirements.

    One way to go about this would be to use the supportsComputeShaders API since if it supports compute shaders, it would also support GPU instancing.
     
  35. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    362
    Just purchased your asset, and it looks fantastic. Ignorant question: I have game I am working on,
    and I would like a large amount of traffic (one of the reason I purchased your asset) Thing is, the Startup code on each vehicle can change the colors of the asset, to give the illusion of more variety. My question is: is this an issue with your asset. If I drop one of my prefabs into your prototypes, does the fact that there will be different colors affect performance?

    Thanks kindly for your time.
     
  36. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622
    Hi there,
    thank you for supporting GPUI.

    Since GPU instancing works by batching each mesh/material combination to a single draw call, scripting material color variations would not work out of the box for the instances of the same prototypes when you use GPUI.

    However, you can use the GPUI API to send the color information in a separate buffer. We have an example scene that does this in the project as well; you can take a look at the ColorVariationsDemo scene for this.
     
    JamesWjRose likes this.
  37. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    362
    Thanks for the fantastically quick response. I will check that scene out.
     
  38. Tealeafpei

    Tealeafpei

    Joined:
    Nov 13, 2017
    Posts:
    4
    hi, when will the next release ? Looking forward to it!!
     
  39. johnlanz

    johnlanz

    Joined:
    Sep 2, 2016
    Posts:
    37
    is it properly working with gaia? because my scene runs 60fps then after I add GPUI Tree Manager and detail manager it drops to 27fps...
     
  40. LouskRad

    LouskRad

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

    We will probably submit an update next week, it will contain bug fixes and performance improvements as usual; and if it fits the schedule, we will add a new demo scene that exemplifies extending with compute shaders.
     
    JamesWjRose likes this.
  41. LouskRad

    LouskRad

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

    Gaia basically generates your scene objects at editor time, and apart from the method of building your scene, it does not change anything for the way GPUI works.

    If you can send us some details at support@gurbu.com (any errors you might be getting, and your manager settings, and some profiler data) we can help you.
     
  42. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    362
    I am thinking about my design issues; Which would be more performant, if I had 10 different prefabs, each with their own color, or one prefab that I affect the color via your api?
     
  43. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    622
    It would be more performant with one prefab using the color variations from the API - since you will be using a single draw call even with different colors.
     
    JamesWjRose likes this.
  44. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    362
    Awesome, awesome, awesome. Thank you. It's Saturday, go enjoy. My questions can always wait a day+
     
    LouskRad likes this.
  45. MattiHietanen

    MattiHietanen

    Joined:
    Nov 24, 2018
    Posts:
    14
    Hi, I ave some important questions.

    I build up a world where I use SceneManager.LoadSceneAsync(newScenePart) if the player reach another area in real-time. That works nice. Each scene contains about 1000 GO's. It takes about 100ms to load and display. Each scene contains trees, houses and other stuff as static prefabs or simple static game objects. But I do not use grass or terrain. All made by meshes. I want to use GPUI only for frustum culling for static objects.

    1) Would it possible to use you GPUI in one scene with these static objects for frustum culling?

    2) What happen if one instance of GPUI is placed in one scene, and 5-8 of these scenes are simultaneous open? No idea what happen to the RT hiZ.

    3) I'm not sure what happen if GPUI starts to collect and sort all relevant meshes and materials after LoadSceneAsync(). So would be there any way to serialize/save/load these objects with a scene, instead of calculate all the static objects in real time after SceneLoadAsync?

    4) Does GI work on static prefabs or meshes that are frustum culled with GPUI?

    Perhaps it would a solution to have GPUI in the main scene permanently... and after scene load.. push the local scene data into main ComputeBuffer like ECS does.
     
  46. johnlanz

    johnlanz

    Joined:
    Sep 2, 2016
    Posts:
    37
    It was the shadow and wind on terrain details that causes the frame drops. So by default details is manipulated by GPUI and activate features that is not needed on mobile. So how to use GPUI that it will not cause frame drops?
     
  47. johnlanz

    johnlanz

    Joined:
    Sep 2, 2016
    Posts:
    37
    Also at simulation the details height is at characters feet but when you play it goes at characters head.. what is going on here? I modified width and height but it doesn't work
    upload_2018-11-25_11-16-53.png
     
  48. Will-D-Ramsey

    Will-D-Ramsey

    Joined:
    Dec 9, 2012
    Posts:
    221
    Hello everyone. Just purchased this asset. Plan to use with MapMagic and Voxeland as well as a few other assets.
     
  49. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    79
    Is it possible to have different mesh on instances which shares the same prefab?
     
    Last edited: Nov 25, 2018
  50. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    79
    Also, I added 500 different prototypes each prototype sometimes change their mesh based on In-Game event but after that Gpu instancer is taxing too much on CPU. Is there any way to fix that
     
    P_Jong likes this.