Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    904
    Hi there,

    SSAO effects in general are among the most taxing post processing effects in the GPU. Since GPUI also uses the GPU for all its operations, it would be expected to see better performance gains with GPUI without using AO than with.

    However, as far as I know Amplify Occlusion usually adds an average of 2ms to the GPU per frame. If what you see is considerably more than this while using AO, please do send us the details of your AO and GPUI settings (support@gurbu.com) so we can investigate.
     
  2. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    It's more of a rule of thumb than a minimum instance limitation: you will get more performance boost as instance counts are higher.

    We are in the process of creating a wiki (soon to be live) that will have detailed explanations on these issues, and it will have a "Best Practices" section which will help you get the most out of GPUI and GPU instancing in general.
     
    d-3 likes this.
  3. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Does this works on webgl
     
  4. LouskRad

    LouskRad

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

    No it won't: GPUI makes extensive use of compute shaders, and they are not available in WebGL.
     
  5. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    I know to use GPU Instancer as it is intended requires a platform that supports compute shaders but would it be possible for it not to for platforms that don't support it? We are attempting to render a dynamic streaming world and gameObjects are a big performance issue. GPU instancer allows us to easily render our world without gameObjects. Currently it appears we would have to branch the code's logic if an unsupported platform is detected. Any recommendations?
     
  6. LouskRad

    LouskRad

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

    GPUI is heavily dependent on compute shaders; all the visibility calculations, buffer management and shadows, LODs etc. are handled in the GPU by them. So it is not possible to use GPUI without them.

    However, if I understand you correctly, maybe you can branch your code so that you can use Unity's DrawMesh API where you detect an unsupported platform? I know it wouldn't give you the flexibility of GPUI, but that way you can at least still use matrices instead of GOs.
     
  7. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Yes that is exactly what I mean. How difficult will this be to add to GPUI? Is it as simple as changing the material and using the DrawMesh API? We are trying to be able to deploy to a wide spectrum of hardware and it would be nice if things failed gracefully. Currently OSX is giving us issues, we haven't had luck with Metal so far.
     
  8. Nihilus0

    Nihilus0

    Joined:
    Jan 25, 2017
    Posts:
    52
    @LouskRad
    Hi, I'm trying to add with my project a seasonal tree change. I knew at GPUI that Detail Instancing and Prefab Instancing were able to convert colors, but it wasn't for Tree Instancing. would you have any plans to update about this feature? I ask for your advice or ideas.

    What I want from GPUI is the following.

    1. The alpha cutoff and tint color on the each prefab billboard-tree must be changeable at run-time in billboard-tree instancing. This is to change into a no-leaf tree in fall and winter.

    2. The color of bark and foliage on the each prefab tree must be changeable at run-time. This is to give the sick tree or maple effect. For example, SpeedTree offers hue color and tint(main) color in particular.(Foliage Hue, Foliage Tint, Bark Hue, Bark Tint)

    3. The root ambient of the each prefab grass must be changeable at run-time in detail instancing. This is to darken the bottom of the wheat field or grass.

    Thanks.
    P.S. I am not an English speaker. I used a translator. I am sorry my poor English.
    and, Thank you for quick fixed the problem. GPUI is the best.
     
    Last edited: Dec 5, 2018
  9. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    103
    Would be great to have a small script to attach on every camera instead of call it on your code to GPUI render . I have around 30 cameras on my project, any plans to update with this feature? Thanks
     
  10. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    Was this ever checked by chance? Or better yet - is the imposter system for GPUI still a possibility? I've been thinking about trying Amplify's Imposter system but if it was to be added to GPUI in the nearish future I would prefer that instead.
     
  11. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    Running a standalone windows exe build, i got these errors in log file:
    WARNING: Shader Unsupported: 'GPUInstancer/VertexLit' - Pass 'Meta' has no vertex shader
    WARNING: Shader Unsupported: 'GPUInstancer/Standard (Specular setup)' - Pass 'META' has no vertex shader

    Building a windows runtime game i need to include some GPUI shader ?
    I tried including ALL the shader under the folder SHADER but shader compiling time become very very long.
    ( some shaders have 98000 variants):
    What is wrong ?
     
    Last edited: Dec 5, 2018
  12. LouskRad

    LouskRad

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

    What I meant was that you can disable GPUI when you detect a system that does not support Compute Shaders/GPU instancing, and use the DrawMesh API instead. GPUI cannot work without the compute shaders - they are tied in too much to its core system.

    However, Metal supports compute shaders; what is the problem you are facing?
     
  13. LouskRad

    LouskRad

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

    It is actually currently possible to do these; though they would currently require you to target some low level GPUI code in your script. You can update the instance material properties by using Material Property Blocks.

    1. GPUI billboards have _Cutoff and _Color properties. You can update these values, but in order to do so you need to access the MPBs in the runtime data fot the billboards. If you need help with this, send us a mail at support@gurbu.com and we can guide you.

    2. If you're using SpeedTrees, you can update their Hue color and tint properties (any property really) again in the same manner as above.

    3. This is a bit easier since the GPUInstancerAPI has a method to update the detail properties. You can check the UpdateDetailInstances method for this. You can also take a look at the AddModifyTerrainsRuntimeDemo scene for an example.
     
  14. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Noted. We will investigate this and see what we can do about it, thanks.
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Yes, we have tested GPUI with Apmplify Impostors and the results were quite good. You can currently use Amplify Impostors either directly or as a custom billboard in the GPUI billboard settings. For more info, you can take a look at this post:

    https://forum.unity.com/threads/released-gpu-instancer.529746/page-10#post-3912364

    and this for the result of our tests:

    https://forum.unity.com/threads/released-gpu-instancer.529746/page-6#post-3715432

    On GPUI billboards, the billboard system is intended to be simple and designed mainly for use with trees; and we don't have plans to turn it into a complicated impostor system such as the Amplify Impostors.
     
    StaticWave likes this.
  16. LouskRad

    LouskRad

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

    These errors are certainly not expected. Are you getting them only in the build? What is the Unity version you are having these on?

    On shader variants; you should not need to include anything that is not already included in the GPUI resources folder. With GPUI, we have avoided using the Resources folder for unnecessary files. However, GPUI comes with various shaders that are located in the GPUInstancer/Resources/Shaders folder. It is a good idea to remove the shaders that you do not use from this folder before building your game. Also, there are some materials in the GPUInstancer/Resources/Shader Variants folder. They are there to ensure correct builds in case you are using shader variants in your materials. You can remove the ones you do not need here as well.

    For example, if you are not using SpeedTrees at all, you do not need the GPUInstancer/Resources/Shaders/Nature/SPDTree_GPUI.shader and you can safely remove it before your build.

    We are currently in the process of expanding our documentation to discuss issues like this in a "best practices" section.
     
  17. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Yeah makes sense, I will look into implementing that tonight.

    Metal should work, I'll let you know how it goes. In the past we were using some assets that were OpenGL only so Metal wasn't an option.

    As for your previous suggestion on setting buffers to 0, unfortunately it had no improvement on FPS on low end devices :( I guess I will have to disable the GPUI component. Hoping simply drawing without the compute shaders performs better on these devices. Thanks for your help.
     
    LouskRad likes this.
  18. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    Awesome, thanks!
     
    LouskRad likes this.
  19. Lucas_Wei

    Lucas_Wei

    Joined:
    Jan 22, 2018
    Posts:
    14
    I think it is very good.But for me ,I want to know there are any restrictions on its use.If I put the machine model what i import to Unity as a prefab,how should i do?
     
  20. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    I'm using 2018.3.0b12 and the problem is present only in runtime build, and the materials of the prefabs "GPUIed" are not shown. I think the shaders are missing if I don't include them in setting/graphics panel
     
    Last edited: Dec 6, 2018
  21. LouskRad

    LouskRad

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

    You can check the Asset Store Description page for hardware restrictions. Other restrictions include tessellated shaders (Unity does not support them with GPU instancing) and skinned meshes (animated rigs).

    We're preparing new video tutorials and expanding the documentation at the moment, but to put it simply, you can create a prefab out of your machine model, add a Prefab Manager to your scene, add the prefab to the manager. The manager will then render all the instances of that prefab in your scene with GPUI.

    You can also check this video tutorial showing how to use GPUI with prefabs on your scene. It is a bit outdated, but the basics have not changed.

    Please feel free to ask if you have any further questions.
     
  22. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Well, GPUI creates the materials with the GPUI shaders at runtime, so it does not change your prefabs. You should not need to specify any shaders as long as the GPUI shaders are in the Resources folder. Did you change the folder location of GPUI? The shader include files are accessed relatively, but if you changed the folder structure - or if you are automating your build somehow to effect this - the shaders can throw errors.
     
  23. Joshua_strawchildgames

    Joshua_strawchildgames

    Joined:
    May 27, 2017
    Posts:
    60
    Hello there, using 2018.3.b12. I had a few issues getting started. One that I resolved, the other I can't seem to understand what the issue is.

    First, I am doing a multiscene setup using Sectr, but I am getting all these issues despite one or multiple scenes.
    I had to retarget the shader includes. GPUI added an HDRP/ to the prefix, which was either unnecessary or wrong.

    Second, when I play the scene, it takes ages to start (I think it took around 5 minutes to start), and all the trees are pink (missing or incorrect shader) with an error being posted in the log.
    Code (CSharp):
    1. Shader error in 'GPUInstancer/HDRenderPipeline/LitTessellation': undeclared identifier 'Use_Macro_UNITY_MATRIX_M_instead_of_unity_ObjectToWorld' at Assets/GPUInstancer/Resources/Shaders/Include/GPUInstancerInclude.cginc(82) (on d3d11)
    2.  
    3. Compiling Vertex program with UNITY_PASS_SHADOWCASTER PROCEDURAL_INSTANCING_ON
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
    5.  
    Code (CSharp):
    1. Shader error in 'GPUInstancer/HDRenderPipeline/Lit': undeclared identifier 'Use_Macro_UNITY_MATRIX_M_instead_of_unity_ObjectToWorld' at Assets/GPUInstancer/Resources/Shaders/Include/GPUInstancerInclude.cginc(82) (on d3d11)
    2.  
    3. Compiling Vertex program with UNITY_PASS_SHADOWCASTER PROCEDURAL_INSTANCING_ON
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
    5.  
    I'm fairly certain these errors are causing the shaders the crash, but I have no clue to what it's referring to. I can't find any reference to "Use_Macro_UNITY_MATRIX_M_instead_of_unity_ObjectToWorld". So I'm stuck at this point.
     
  24. MTandi

    MTandi

    Joined:
    Aug 4, 2017
    Posts:
    10
    Hello!

    I'm trying to use GPU instancer prefabs with MicroSplat Terrain Blending.
    When I hit play though, the editor just freezes with no errors displayed.
    Is it due to incompatibility with GPU instancer or I can work this out?

    The MicroSplat author said:
    Here's my setup:


    I've also noticed that GPU Instancer uses built-in Time and breaks the cross-fading when the timeScale is set to 0 (I do this to pause the game while having the ability to move camera).
     
    Last edited: Dec 7, 2018
  25. Nihilus0

    Nihilus0

    Joined:
    Jan 25, 2017
    Posts:
    52
    Thank you for your advice. I will try that and contact you by email if I need your help.
     
    LouskRad likes this.
  26. Joshua_strawchildgames

    Joshua_strawchildgames

    Joined:
    May 27, 2017
    Posts:
    60
    Okay, so I did a little bit of searching around, it seems that macro is defined that way because unity_ObjectToWorld and unity_WorldToObject is not supposed to be at all, and you should instead be using UNITY_MATRIX_M and UNITY_MATRIX_I_M. However, those values can't be used since they are constants and the .cginc code is setting and modifying the values here. I decided to go ahead and comment out that code to see if it would do something interesting, which it did. So I was able to keep the terrain from popping up as pink materials, but the now the trees and such are stuck on my camera (I see tree foliage and such as if it's in my face, but the terrain itself is empty of any trees).
     
  27. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    No i don't modify GPUI folder structure.
    I tried to add all the shaders in the folder SHADERS to the EDIT->PROJECT SETTINGS->GRAPHICS Build-in shader setting panel. But compiling time of the shaders in the building process is too long.
     
  28. Lucas_Wei

    Lucas_Wei

    Joined:
    Jan 22, 2018
    Posts:
    14
    First of all,thank you for your reply!
    I used it in my project since yesterday and it worked very well.But I think I have a problem.I will upload a screenshot to explain it.
    well,when I use the prefab called "RigidBodyFPSController" from the Standard Assets,if the rendering path of the main camera is forward or use Graphics Setting ,the problem is coming,as you can see in the picture,there will always be something more inexplicable.But if the rendering path is deferred,that is not going to happen.I can not solve the problem by myself.So I hope to get your help.
    By the way,the version of my Unity is 2017.3.0.f3.
    :)
     
  29. Lucas_Wei

    Lucas_Wei

    Joined:
    Jan 22, 2018
    Posts:
    14
    ok,I checked the picture just now.It do not work.look this.
     
  30. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904

    Hi there,

    GPUI's current version was designed to work with the 3.0.0 version of the HDRP/LWRP libraries and before. Unity has changed the way users access the Unity_ObjectToWorld and Unity_WorldToObject since then. We have updated GPUI for this, and the update will be available to download in a few days.
     
    ftejada likes this.
  31. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904

    Hi MTandi,
    Thank you for reporting these issues.

    Looks like MicroSplat (or you) use multiple materials without multiple submeshes. This could be causing an issue in GPUI; we will test this and make a fix - we'll put it in the next update as well if we can.

    As for cross-fading, you're right it would ignore the timescale 0. We'll fix this as well (and see if we can add it in the next update)
     
    MTandi likes this.
  32. steeloblk

    steeloblk

    Joined:
    Dec 27, 2014
    Posts:
    20
    Hi, why would I get a zero count in GPU instancer for a prefab that is clearly in the scene. There appears to be several objects that I have dragged into the GPU Instancer, there is a zero count and the prefab does not have the GPU Instancer component. Alternatively, It I add the component manually, then it says the object is not registered.
     
  33. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Can you please send us the modifications you made on your player/graphics settings so we can identify the problem? Also, please tell us which shaders you are using as well.
     
  34. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    I'm not sure I understand the problem - but I understood that you have a problem when using forward rendering and you don't have it when using deferred. You can try using the "Shadow with Original Shader" option in the manager, and if that doesn't solve it, please send a screenshot of the deffered and forward modes so we can compare to help you.
     
  35. LouskRad

    LouskRad

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

    it is either that the prefab references are broken in your scene - or you simply need to click the "Register Prefabs in Scene" button to register the scene instances.

    When you say you don't see the GPUI script on the prefab, do you mean the main prefab in the project folder, or the prefab instance in your scene? if the latter, then there is a good chance the prefab instance's reference is broken.
     
  36. Joshua_strawchildgames

    Joshua_strawchildgames

    Joined:
    May 27, 2017
    Posts:
    60
    Awesome! Thanks for the update. I hope to use again very soon.
     
    LouskRad likes this.
  37. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    126
    Hello there, I am getting following error while adding meedow environment grass with GPUI
    Material doesn't have a color property '_Color'
    UnityEngine.Material:get_color()
     
  38. LouskRad

    LouskRad

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

    We fixed this issue and it will be included in the next update. The update should be live in a few days.

    If you don't want to wait, send us an email and we can send the fix to you.
     
  39. LouskRad

    LouskRad

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

    We have prepared some wiki pages in our website that will serve as extensive documentation for GPUI.

    In these pages, you will find

    • A comprehensive Getting Started Guide which also explains all the tools and components GPUI comes with,
    • A Terminology page to give you detailed information on the concepts (such as GPU Instancing and Compute Shaders) that GPUI is using,
    • A Frequently Asked Questions page which also includes a troubleshooting section for most common problems/misuses of GPUI along with compatibility other asset with known,
    • and finally, maybe also most importantly a Best Practices page in which you can see detailed information about how you can get the most out of GPUI.

    There will be more in this wiki later on, and the existing pages will be constantly updated to give you more information. It will also reflect the changes/updates we make to GPUI. We have decided that it is better to use this wiki as a dynamic, always up to date source of information. So we will also improve it with the questions and reports you make about GPUI.

    We are also integrating this wiki directly into the GPU managers and tools so you will be able to visit the relevant parts of it directly form where you will need to get information.

    Please tell us what you think about it, and all your suggestions and comments are welcome.
     
    ftejada and AthrunVLokiz like this.
  40. Lucas_Wei

    Lucas_Wei

    Joined:
    Jan 22, 2018
    Posts:
    14
    OK,I have tried the solution you mentioned,but the problem still exists.Now I will upload screenshots of the forward and deferred modes .I hope you can get more information from them,and then you can help me solve it.Thank you!
     
  41. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Looks like a shader issue, what shaders are you using on your materials?

    If you use a custom vert/frag shader, it might be missing instance id setup. In that case, this might help you:
    https://wiki.gurbu.com/index.php?title=GPU_Instancer:FAQ#Vertex.2Ffragment_Shaders
     
  42. Lucas_Wei

    Lucas_Wei

    Joined:
    Jan 22, 2018
    Posts:
    14
    I used the material that comes with the imported model and checked the "Enable GPU Instancing" option. I will try this method as you said immediately, hoping to solve it.That is the screenshot of one of the materials.
     
  43. Lucas_Wei

    Lucas_Wei

    Joined:
    Jan 22, 2018
    Posts:
    14
    I'm sorry, I don't know how to modify the shader manually, which one should I modify? Is it inside the GPUInstancer or does it have a shader?
     
  44. mgwade528

    mgwade528

    Joined:
    Apr 24, 2017
    Posts:
    8
    Hi there,i use GPUI prefab manager optimize some props,and some mesh use stanard cutout shader.now i have a problem, shadows don't seem to support it.what can i do? hope to get your help, thx~
     
  45. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    533
    Hi there,
    Standard shader would not cause any issues for GPU instancing. But if some of your materials are using custom shaders, there might be one that does not support instancing. When you select the GPUInstancer/Resources/Settings/GPUInstancerShaderBindings file, you will see a list of shaders that is automatically converted by GPUI. If any of these shaders does not support instancing, you might need to make some modifications on them as described here.
    If you have trouble, send us an e-mail at support@gurbu.com with the screenshot of the shader list and we will guide you.
     
  46. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    533
  47. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi there, can you try turning off the second directional light (and any other lights that you might have) in your scene and see if the problem persists?

    If you don't see that artifact when there is only a single directional light in your scene in forward rendering, then it could be related to a bug in the Unity 2017.x and 2018.1 versions.

    In short: if you see that the problem is solved when you only leave a single directional light in your scene, then it means you need to upgrade to Unity 2018.2 or use deferred rendering in your scene.
     
  48. Lucas_Wei

    Lucas_Wei

    Joined:
    Jan 22, 2018
    Posts:
    14
    Ok,Yes.I tried according to your method and solved the problem successfully. And I still use the latest version of Unity, so there is no such problem. Thank you very much for your help. It's really a pleasant chat.
     
  49. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    I´m very disappointed with this asset. I purchased it thinking I could benefit of the promised optimization but then nothing works as expected.
    Practically only standard shader is supported and basic shaders as soft occlusion (trees) don't work properly making the prototype trees useless, (in some cases simply they are not rendered).
    The developer don't offer support. He asks for proofs of the errors and when I show them he only answer "it is working ok here" without offering any solution.
    I requested a refund, because the asset is not working as expected, but the developer is not accepting refunds.
    I suggest the developer to reconsider his attitude. I can´t understand how he prefers to keep discontent customers to avoid a little money loss.
     
    Last edited: Dec 12, 2018
  50. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Hello, happy to report calling the DrawMesh API directly and reusing the buffers has solved our performance issues on low end machines while keeping the code clean.

    Unrelated to that I am experiencing a rendering issue that causes water to flicker as the camera moves through the world. Also Unity projections fail to render correctly. In the picture below it should be projected onto the teal ring but it is seen everywhere else. Any tips on how to debug these issues?

    render bug projection.png render bug.png

    On closer examination I can see a silhouette of an inactive object in the gpui prefab manager causing the flickering on the water. It seems to be right in front of the camera. What is this?

    I've recorded a video of the behavior. Can clearly see an object following the camera is interfering with the water and projection. https://www.dropbox.com/s/bm9f5th9i8a4oin/render bug.mp4?dl=0
     
    Last edited: Dec 12, 2018