Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

[RELEASED] GPU Instancer

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

  1. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    154
    I am afraid that didn't helped. still black boxes are appearing.
     
  2. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    233
    Well, OK. We made a version that you can toggle v-sync on and off. The default behavior is turned on. Can you toggle it off and see if this fixes the issue?
     
  3. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    154
    here, i made a screen record with vsync on and off. I think this is not your problem, may be its unity's bug that not yet resolved or my device lack some features.

    Please see.
     
    Last edited: Jul 19, 2018
  4. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    233
    Thanks for making that video. We are now investigating possible problems. This really looks like the issue is with some feature that Unity uses that is unsupported by your device.

    It can be the shader, texture compression, rendering path or something else. Can you send us a mail over at support@gurbu.com so that we can send you multiple builds with different settings?

    Cheers.
     
  5. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    154
    sent you mail. please check.
     
  6. mgwade528

    mgwade528

    Joined:
    Apr 24, 2017
    Posts:
    5
    Hi, I've Updated the new version 0.81 and 0.82, Now there's a problem. When i run the demo, I get an error
    Code (CSharp):
    1. RenderTexture.GenerateMips failed: render texture does not have mip maps (set useMipMap to true).
    Version 0.8 does not have this problem. My Unity version is 2017.1.2f1 .Hope to get your reply, thanks.
     
  7. LouskRad

    LouskRad

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

    Looks like this issue is related to a Unity 2017.1 bug that happens while using RenderTexture mip levels. We tested in your version of Unity (2017.1.2f1) and were able to reproduce this bug. The bug has been fixed in 2017.2.03f and it looks like the fix was not backported to the 2017.1 versions.

    You did not get this error in GPUI v0.8.0 because we introduced the occlusion culling feature in the v0.8.1 update; and this feature uses RenderTexture mip levels. However, given that this is a Unity Editor internal bug, we cannot offer you a fix other than upgrading Unity to a later version (I would recommend 2017.4 LTS if you want to use 2017)

    If you definitely do not want to upgrade your Unity Editor, here is a workaround that will turn off the new occlusion culling feature and will let you use GPUI without errors:

    (1) Turn off the "Use Occlusion Culling" toggle from all the managers in your scene (under "Scene Settings").
    (2) Surround the lines 374, 375 and 376 in GPUInstancerManager.cs with an if statement as such:

    Code (CSharp):
    1. if (isOcclusionCulling)
    2. {
    3.         cameraData.hiZOcclusionGenerator = cameraData.mainCamera.gameObject.AddComponent<GPUInstancerHiZOcclusionGenerator>();
    4.         cameraData.mainCamera.depthTextureMode = DepthTextureMode.Depth;
    5.         cameraData.hiZOcclusionGenerator.mainCamera = cameraData.mainCamera;
    6. }
     
  8. mgwade528

    mgwade528

    Joined:
    Apr 24, 2017
    Posts:
    5
    I see. Thank you
     
  9. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    15
    Hi, do you have plans to integrate this asset with playmaker? i mean make actions to spawn objects with the gpu in real time.
     
  10. LouskRad

    LouskRad

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

    We indeed have it in our roadmap to integrate GPUI with Playmaker - but this is scheduled for later on.

    However, for our next major update, we have a new feature scheduled that will automatically register selected prefabs with GPUI when they are instantiated (and of course remove them when they are destroyed/disabled). In principle, this should make GPUI play along with any third party plugin (including Playmaker) that instantiates prefabs. Thus with this feature, you will be able to use GPUI at runtime without writing any code if you already use a plugin that handles prefab instantiation.
     
    Lars-Steenhoff likes this.
  11. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    349
    Nice :D I made my own implementation of that extending from the GPUInstancerPrefab a while ago. It's working quite well for me.
     
    LouskRad and GurhanHazinedar like this.
  12. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    413
    Can any shader be used for the terrain detail instancing?

    Is there a way to easily set up instancing from our own custom array of Matrix4x4? Having thousands of prefabs in the scene would likely slow the editor down.
     
  13. LouskRad

    LouskRad

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

    Detail instancing by default works with our included foliage shader for texture details (i.e. grass) - but you can also choose to use almost any custom shader instead of this (excluding geometry shaders). Your custom shaders will be auto-converted to work with GPUI as well, so you don't need any extra steps. The detail prototypes that are prefabs (e.g. plants, rocks, etc.) use whatever shader is defined on the prefab.

    Currently, our API allows you to add runtime instantiated prefabs. There are two scenes included in the package that serve as examples of this (the asteroids scene and a scene that showcases how to add/remove extra instances).
    You can also take a look at how it works from this tutorial video. However, there is no method yet that allows you to input arrays of Matrix4x4 directly - but we have a feature planned in our roadmap to allow for instancing prototypes by using a custom struct without having to instantiate them first as GameObjects as well.
     
  14. tcmeric

    tcmeric

    Joined:
    Dec 21, 2016
    Posts:
    94
    Hi, I recently purchased your asset.

    Can you add mobile shader support? Seems like no mobile shaders are supported at the moment, which means even if this asset supports android, I dont want to use it. It looks like the default mobile shaders mostly already have GPU instance toggle option.

    If you need some assistance with the playmaker actions, feel free to ask me. I wrote the playmaker actions for post processing stack v1, textmesh pro, VRTK, etc. https://github.com/dumbgamedev
     
  15. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Hi,
    Thank you for supporting GPU Instancer.

    GPUI works with mobile shaders. To use Unity built-in shaders, you need to download these shaders from Unity Archive and add them to your project. Then they will be auto converted to use with GPUI.

    The reason for this is that the built-in shaders' source codes are not readable in editor. But when you add the source codes from the archive, they will become readable and automatically converted. We are working on a solution to make this process easier in the future.

    Note: Standard, StandardSpecular and VertexLit shaders are already included, so they work out of the box.

    Thanks for the offer. We will be working on playmaker integration on a later date as mentioned in this post. Because most of the required actions for GPUI Prefabs will be handled with a generic extension added with the next major update. Playmaker actions will be more beneficial to users when we expand our API with more complex run-time modifications. Then we will be happy to collaborate with you to make these playmaker actions.
     
  16. tcmeric

    tcmeric

    Joined:
    Dec 21, 2016
    Posts:
    94
    Thanks. I appreciate the quick response. I don't mind taking the few extra steps if I can get what I want :)

    Regarding playmaker, yeah give me a shout when you are ready. No hurry, I am around.
     
    LouskRad likes this.
  17. friuns3

    friuns3

    Joined:
    Oct 30, 2009
    Posts:
    261
    how it integrates with map magic is there big fps increase?
     
  18. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Hi there,
    With Map Magic the results are the same. For prefabs, the performance gain increases with the amount of instances in your scene. And for Terrain details, fps is stable and the performance gain depends on the quality settings (cross-quading, shadows, etc.). Both results change according to the scene setup and the hardware. GPU Instancer's performance increase with better GPUs.

    You can check the Benchmark Page to see our test results and you can also download our Demo Builds to see the difference between Unity's default gpu instancing and GPU Instancer.
     
  19. Adamantius

    Adamantius

    Joined:
    Apr 28, 2014
    Posts:
    4
    Hi Gurhan,

    I'm trying to integrate GPUInstancer with MapMagic. The Detail Prototypes work great but I get two errors when trying to add Prefab Prototypes and the Prefabs do not end up being frustum or occlusion culled:

    and:

    Any ideas what might be causing this? Thankyou.
     
  20. ScottSummers

    ScottSummers

    Joined:
    Jul 12, 2015
    Posts:
    26
    Looks awesome!

    Would this also increase performance for many moving sprite prefabs?

    Would it do so for both single-frame sprites, and multi-frame sprite animations?
     
  21. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Hi,

    In some cases prefabs are registered before prefab manager is initialized, then you get this error. It will be fixed with the next update. If you send an email to support@gurbu.com, we can send you the fix package beforehand.
     
  22. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Thank you!
    GPUI currently does not support Sprite Renderers. We will make the necessary improvements for sprites and share our test results in the future.
     
    ScottSummers likes this.
  23. ScottSummers

    ScottSummers

    Joined:
    Jul 12, 2015
    Posts:
    26
    Thanks!

    What if we use a mesh with a single quad, and the sprite is a normal material on the quad. (So no SpriteRenderer.)

    Would GPUI increase performance with many of those single-quads moving around?
     
  24. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    If you use a Mesh Renderer with a quad mesh, then you can use GPUI to render these instances. And to move them around at runtime you will need to call "UpdateTransformDataForInstance" method in our API. You will get a performance boost while rendering high instance counts. However moving every instance every single frame will cause some overhead. In most cases the performance boost for rendering beats the transform update overhead, so it improves your frame rates.

    We are also working on some improvements for our API to handle transform updates more efficiently and we will also add an optional feature that makes transform updates automatically. They will come out with a future update with other runtime modification features and will reduce the overhead for transform updates drastically.
     
  25. seille

    seille

    Joined:
    Jun 2, 2014
    Posts:
    3
    hello, LouskRad
    I use your tool on ios.But it is not very good.FPS is very low.And affected by GPU threads.The scene of the planet I have only 20FPS for 10,000 objects or 50,000 objects.Do you have any good solutions?
     
  26. seille

    seille

    Joined:
    Jun 2, 2014
    Posts:
    3
    Even if I initialize 10 objects, I only have 20FPS.
     
  27. GurhanHazinedar

    GurhanHazinedar

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

    We will need some more information to identify the problem. Can you mail us at support@gurbu.com with answers to the following questions so that we can solve this together?

    (1) Are you seeing the problem in an iOS device or are you seeing it in the Simulator?
    (2) If you're testing on the simulator, what are your settings for the simulator, and did you enable Metal API and select GPU device as written in this link: https://docs.unity3d.com/Manual/Metal.html?
    (3) If you are testing a build directly on a mobile device, what is its model?
    (4) What Unity version are you using?
    (5) In the Unity Editor, are you certain that you have Metal API selected in your player settings for your primary Graphics API?
     
  28. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    15
    what is the release date for the next big update?
     
  29. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Hi there,
    There will be a small update fixing some of the known issues before this. We are also currently working on the next major update. Although we can't give you an exact date, our purpose is to launch it as fast as possible.
     
  30. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    669
  31. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Hi,
    It is already in our to-do list to check Amplify Impostors' shaders for compatibility with GPU Instancer. We will soon make a detailed test and inform you with the results.

    Main features of the version 0.9.0 will be as follows:
    - Tree Manager for Unity Terrain Trees
    - Speed Tree and Tree Creator support
    - Option to Add/Remove or Update Prefabs automatically without API calls
    - Shadow rendering performance improvements and LOD settings
    - LOD crossfade support
    - Light probes support for version 2018.1 or later
    - Gaia integration

    We will also redesign our website to have more tutorials, examples and FAQs. In addition, we will include a roadmap page so that you can check our plans and make requests/suggestions.

    Collider optimization features will be included later on and is not yet scheduled for a release.
     
    therewillbebrad likes this.
  32. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    669
    Great! Really looking forward to it!
    Regarding collider streaming, since you have all the prototypes and the info of each of their instances, maybe just let us make a pure collider prefab for the prototype then you spawn them around main camera according to the prototype and set the transform the same to its instance. Can this be achieved through GPU workflow?
     
  33. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    The details for collider streaming will become clearer later, when we make some more improvements on our API. Our main purpose will be to provide the users with the tools they need to use the technique that fits their needs. It will be similar to our Rigidbody example in the Asteroid Demo Scene. We provided one solution for Rigidbodies as an example, but by using our API you can implement your own solution according to your needs.
     
  34. LouskRad

    LouskRad

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

    The 0.8.3 update has just been released. This is a minor update that comes with some small fixes. Also, the detail manager will now take Unity Terrains' density property into consideration and allow you to set (detail) prototype based density - so you can now have more flexibility for the quality settings of your instanced terrains.

    We hope you enjoy GPUI.
     
  35. EvalDaemon

    EvalDaemon

    Joined:
    Aug 8, 2013
    Posts:
    91
    Ok I have walls that I instantiate from an original prefab and move around in scene before start. In the manager I set the original prefab that it should use to replace the ones in the final scene. Problem is that the manager starts too early on start. I need to tell it to start and replace later when I need it to, several fraps after start so it can replace the already existing in scene prefab instances I created later. I tried setting manager to disabled and then enabling it but that seems to break it too.

    Also the wall prefab may have other objects child to it during my setup, such as wall torches, that are not part of the original prefab. Does that make a difference?
     
    Last edited: Aug 8, 2018
  36. EvalDaemon

    EvalDaemon

    Joined:
    Aug 8, 2013
    Posts:
    91
    About got it figured out, but just need to figure out how to register the prefab to the prototype list at runtime.
     
  37. LouskRad

    LouskRad

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

    Yes, registering the prototype list through the API is the better way to go for runtime instantiated prototypes. Usage is quite straightforward:

    (1) Add your instantiated instances to a list:

    Code (CSharp):
    1. List<GPUInstancerPrefab> instanceList = new List<GPUInstancerPrefab>();
    The class GPUInstancerPrefab is reference to a script added to the prototype instances when you register them in the prototype manager in the editor.

    (2) Register this list through the API:

    Code (CSharp):
    1. GPUInstancerAPI.RegisterPrefabInstanceList(prefabManager, instanceList);
    (3) Initialize the GPUI prefab manager:

    Code (CSharp):
    1. GPUInstancerAPI.InitializeGPUInstancer(prefabManager);
    That's all that is necessary to register your prototype instances at runtime. For more information, you can take a look at this video tutorial on how this is done.

    Hope this helps.

     
  38. EvalDaemon

    EvalDaemon

    Joined:
    Aug 8, 2013
    Posts:
    91
    GurBu,

    Ya I got all that but I was hoping to just add a script to my prefab that then automatically assigned itself to the prefab manager list of prototypes without needing to do the extra step of managing them in the editor itself. I'm constantly changing my prefabs, and there are thousands of them. I am trying to cut out the step of needing to then also manage them in the prefab manager.

    From what I grock so far of this, the prototype data is just an object with a YAML file and reference to the original prefab correct? So can we create this same object and YAML info at runtime and then start the GPU instancer?
     
    Last edited: Aug 8, 2018
  39. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Hi,

    Prototype definitions are ScriptableObjects that are created when you add a prefab on the Prefab Manager. They can be defined on editor or generated at runtime. If you want to generate the prototype definitions at runtime, you can use a script like this:

    Code (CSharp):
    1. using GPUInstancer;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class DefinePrototypesAtRuntime : MonoBehaviour
    7. {
    8.     // Reference to the Prefab Manager in scene (disabled and with no prefabs defined on it)
    9.     public GPUInstancerPrefabManager prefabManager;
    10.     // List of prefabs to define on the manager
    11.     public List<GameObject> prefabList;
    12.  
    13.     void Start ()
    14.     {
    15.         // Start coroutine to define prototypes after some time
    16.         StartCoroutine(DefinePrototypes());
    17.     }
    18.  
    19.     IEnumerator DefinePrototypes()
    20.     {
    21.         // Wait 3 seconds
    22.         yield return new WaitForSeconds(3);
    23.  
    24.         // Add the prefabs to the manager
    25.         prefabManager.prefabList.AddRange(prefabList);
    26.         // Define prototypes for the prefabs
    27.         prefabManager.GeneratePrototypes();
    28.         // Register the prefab instances in scene to the manager
    29.         prefabManager.RegisterPrefabsInScene();
    30.         // Enable Prefab Manager
    31.         prefabManager.enabled = true;
    32.     }
    33. }
    34.  
    Please not that there might be changes with future updates, because this code uses some internal variables and methods.
     
  40. EvalDaemon

    EvalDaemon

    Joined:
    Aug 8, 2013
    Posts:
    91
    Thanks! I have that working now. Is there a way or have you tried to make your occlusion culling method work with non GPU Instanced objects? It's very neat and would be a far better method then any of the other methods I have seen. I've been looking at the shader trying to make sense of how it is working but I don't know that much about shaders. Besides turning off the meshes in the video memory for culling could one use this technique to turn off normal objects texture rendering as well to reduce batch calls? I don't know if you could also signal objects to turn off rendering for culling too, but that would be supreme. Even though the GPU instancing is awesome and has it's place in certain situations I am not seeing a huge boost for the mid and lower video cards which I guess is understandable and eventually the 1000s will become the mid and the low levels. Right now I'm really trying to find the best performance options for at least the mid ranges 700s and 800 and trying to find every culling method that could help for procedural scenes.
     
  41. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Happy to be of help.

    Frustum and occlusion culling systems included with GPU Instancer are designed to work with GPU instancing only. What they do is to reduce the number of objects drawn for each prototype that you defined on the GPUI Manager. Let's say you have 1000 instances of a prefab and to draw these, GPU Instancer makes 1 draw call with the count 1000 (this count is stored in GPU memory). When you use frustum and/or occlusion culling, this count is modified in GPU according to culling results. So it makes 1 draw call with a count less than 1000 and speeds up the rendering. So, the culling does not reduce the number of draw calls, but instead reduces the number of objects drawn with each draw call. You won't be able to use the same technique without GPU instancing. You would need to read the culling results to CPU and this will slow down the culling process.

    We have some ideas about making a culling system which does not require GPU instancing. But it is too early to say if something will come out of it. And if we decide to make this in the future, it would be a different system and naturally would not be part of GPU Instancer.
     
  42. EvalDaemon

    EvalDaemon

    Joined:
    Aug 8, 2013
    Posts:
    91
    If you guys do come up with another package for normal occlusion culling as good as your GPU instance I would defiantly be interested in seeing it. Thanks.
     
    LouskRad likes this.
  43. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    154
    any update for mobile version? last time somehow it worked but later on we want it to be bug free. ;)

    Also can you add option for automated script conversion for intanced object at runtime? Would be cool.
     
  44. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    We do not have any reported unsolved mobile bugs since the last update. The issue you mentioned before was with the settings for our android demo build and a new build with different settings solved that issue. If you have encountered a bug with your mobile project, please provide us with some information about the issue with an e-mail to support@gurbu.com

    With 0.9.0 update there will be options to automatically handle adding, removing and updating instanced objects without API calls. There won't be any script conversions.
     
  45. NikhilUnity

    NikhilUnity

    Joined:
    Dec 28, 2015
    Posts:
    122
    There is a vertex bending shader for grass from Advanced Foilage 5, which has a script attached to the grass. It's material is ticked for GPU Instancing.

    -> When GPU Instancer is Enabled with your prefab added, it does not bend.
    -> When the prefab is removeed from GPU Instancer Script, it does bend.
     
  46. GurhanHazinedar

    GurhanHazinedar

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

    GPU Instancer comes with auto shader conversion feature that automatically creates a new version of your custom shader to be used with GPUI without any coding. However, shaders that have instance based unique property values that are set from scripts, will use their default value on the prefab's material when auto-converted to use with GPU Instancer.

    To have different property values per instance, shaders need to be edited as described in
    DefinePrototypeVariationBuffer API method's description. Then, with the use of DefinePrototypeVariationBuffer and AddVariation API methods, you can set different property values per instance. There is a demo scene called ColorVariations which has an example shader and script included in the package.

    When there are scripts involved which manipulate material properties, there is not much we can do on our side. The changes should be done on the shader and the scripts that set the material properties to make it compatible with GPU Instancer.
     
  47. DekkerC

    DekkerC

    Joined:
    Oct 7, 2017
    Posts:
    1
    I'm trying to render many altTree objects in my scene.
    I got it somewhat working with a decent fps. But the problem now is that each tree is instantiated and hogs memory when I use RegisterPrefabInstanceList.
    So much that my computer starts to use the swapfile on my hard disk extensively. This makes loading the scene take ridiculously long with 200k trees. It takes more then 5 minutes to complete.
    Is there a way to give gpu instancer 1 prefab + a list of transformations (or something like that)?
     
  48. ivabibliocad

    ivabibliocad

    Joined:
    Jan 11, 2014
    Posts:
    40
    When will 0.9.0 update be ready? I really need the speedtree feature!!
     
  49. NikhilUnity

    NikhilUnity

    Joined:
    Dec 28, 2015
    Posts:
    122
    Can you make it compatible with it? I will ask the developer. Since I do not know how to write shader code.
     
  50. GurhanHazinedar

    GurhanHazinedar

    Joined:
    Apr 24, 2017
    Posts:
    72
    Currently it is not implemented. However, we are working on adding new API methods to provide this feature. It will be an option to Prefab Manager prototypes to work without GameObjects through API calls by sending a list of transform information. It is planned for release after 0.9.0 update.

    Our current plan is to release the 0.9.0 update around end of September - beginning of October. It is a major update and the date might change depending on our test results and Asset Store approval times.

    We can not make it on our side alone. We will make some tests and get in contact with the developers to see if it is possible to provide a GPUI compatible version.