Search Unity

[RELEASED] GPU Instancer

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

  1. LouskRad

    LouskRad

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

    Glad to hear the DrawMesh API is working out.

    Looks like this problem might be caused by the projectors. There is a weird behavior of Unity projectors when used together with the DrawMeshInstancedIndirect API - and since it is in the internal Unity code, we don't have access to it. You can try setting GPUI prototypes to a layer and ignore that layer in your projectors - that can actually improve your performance as well.

    You can take a look at this wiki document; it is about the AQUAS asset's projectors for water caustics, but the idea is the same when using any projector.

    Please let us know if this solves the issue.
     
  2. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    100
    Ok thanks for the info. I am actually not using projectors for Aquas. There seems to be something else happening. Particles are also affected. Any other ideas?

    draw order.jpg
     
    Last edited: Dec 12, 2018
  3. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    Ok, I can also think of two other things:

    - If you are using vert/frag shaders (not surface or standard shaders), one of the shaders might be missing instancing setup. If this is the case, you can take a look at this: https://wiki.gurbu.com/index.php?title=GPU_Instancer:FAQ#Vertex.2Ffragment_Shaders

    - The other possibility is that you could be using a particle effect that works by adding another material to a mesh with a single submesh. If this is the case, we have fixed this for the next update which should be live soon.

    If these cases are not true for you, please send us an email with your shader and particle effect details (and if possible, a sample package that shows this) so that we can investigate this in more detail.
     
  4. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    740
    Hi, I've met an issue with SetGlobalPositionOffset function:
    After I called this function, all instances not using speedtree shader are not rendered though their are marked as instanced in the prefab manager.
    All speedtree can be rendered correctly with the offset.
    This can be reproduced in my editor.

    PS: I also got this null reference error when calling the method:

    ArgumentNullException: Value cannot be null.
    Parameter name: buffer
    GPUInstancer.GPUInstancerUtility.SetGlobalPositionOffset (GPUInstancer.GPUInstancerManager manager, UnityEngine.Vector3 offsetPosition) (at Assets/GPUInstancer/Scripts/Core/Static/GPUInstancerUtility.cs:2572)
    GPUInstancer.GPUInstancerAPI.SetGlobalPositionOffset (GPUInstancer.GPUInstancerManager manager, UnityEngine.Vector3 offsetPosition) (at Assets/GPUInstancer/Scripts/API/GPUInstancerAPI.cs:89)
    MainManager.GameManager+<ShiftWorld>c__Iterator0.MoveNext () (at Assets/_SuperTrampers/Scripts/Runtime/MainManager/GameManager.cs:474)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
     
    Last edited: Dec 13, 2018
  5. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    100
    Figured it out, you were right. I missed an unrelated projector not even near the water or waterfall. It was causing all sorts of unpredictable behavior throughout the scene. Super weird! Its a shame projectors don't work with the DrawMeshInstancedIndirect API.
     
    LouskRad likes this.
  6. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,118
    Trying to use the soft occlusion shaders on palm trees I get these results without GPU instancer Without GPUi.JPG


    and after using GPU instancer on the palm trees.

    With GPUi.JPG


    PalmTree Materials.JPG


    The developer is not able to solve this issue and refuses to accept a refund. Unacceptable.
     
  7. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    100
    Feature request: ability to tune min culling distance per prefab prototype.

    Currently we have to increase the the min culling distance to prevent large geometry from flickering when the camera is very close to it. This works but this also causes smaller objects that should be culled to not be. We've added this to our source, seems like it would be a good addition to the tool :)
     
    Last edited: Dec 13, 2018
    Alex3333 and AthrunVLokiz like this.
  8. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    333
    Request feature. Add exception objects to each type when replenishing with a mower. the mower now clears all the grass. Add an array to exclude from the list. For example, 1-3 grass remained after the passage by the mower. (translator) I hope you understand me))
     
    AthrunVLokiz likes this.
  9. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537

    Hi there,

    Looks like you might be getting this error because the GPUI buffers are not yet ready when SetGlobalPositionOffset is called.

    If you're using the prefab manager, you can surround the call for SetGlobalPositionOffset inside a control running it only if the manager has initialized its buffers:

    Code (CSharp):
    1.  
    2. if (manager.isInitialized)
    3.      GPUInstancerUtility.SetGlobalPositionOffset(manager, offsetPosition);
    4.  
    Note that this would not update positions for prototypes in disabled prefab managers. Also, for the Tree and Detail managers, this would work only after the TreeInitializationFinished and DetailInitializationFinished events are ready respectively (before these events are fired, the managers will be initialized but the buffers will not be ready in Tree and Detail Managers).
     
    Harekelas likes this.
  10. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    Both are noted - they make sense. We will integrate them into GPUI in a near future update. Thanks for the feedback :)
     
    Alex3333 likes this.
  11. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    740
    Thanks! Will try this method tomorrow!
     
    LouskRad likes this.
  12. LouskRad

    LouskRad

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

    The 0.9.8 update is live on the asset store. In this update, we have made various bug fixes and introduced a number of new features as usual:

    Firstly, as I have previously mentioned, we have created a wiki site with extensive information on using GPUI. This site contains information on the best practices on using GPUI along with documentation. Furthermore, with this update, the GPUI managers and tools now have wiki links that you can click to simply view the relevant documentation in this site.

    upload_2018-12-13_16-4-29.png

    We have also decided upon request that moving the GPUI menus under /Tools will be better.

    Next, we have made the necessary changes to the core code so that GPUI now renders your instances in the editor scene view when the game is paused as well. You will also notice that because of these changes, the Detail Manager simulation mode will be considerably faster.

    GPU instancer is now compatible with the 4.3.0 version of the LWRP and HDRP SRP shaders. This should fix the shader conversion problems some of you have pointed out in the previous version.

    We have also fixed some problems with the preview icons in the managers that were apparent in certain Unity versions. The prototypes should now consistently show their icons regardless of the Unity Editor version.

    Another bug we have fixed is related to the meshes with a single submesh count but many materials. This was reported to be particularly causing issues with some particle systems in the Asset Store. GPUI should now work with this scenarios without any performance loss or rendering problems.

    We have also revamped the GPUI versions of the Nature/Soft Occlusion shaders and their corresponding billboard shaders to match the original look of your Soft Occlusion trees better. If you were having color mismatches previously when using such trees, it should be fixed with this update.

    Here is the full v0.9.8 changelog:

    New: Managers can now continue rendering in Scene View camera while the editor is paused
    New: All managers and tools now have "Wiki" buttons that will take you to their respective documentation pages
    New: Tree Managers now have an option to disable the random rotation of trees on Unity terrains

    Changed: Automatic shader conversion update for LWRP/HDRP 4.3.0 version
    Changed: Menu items moved under Tools
    Changed: The way prototype previews are displayed
    Changed: The GPUI Soft Occlusion Shader is renewed to match the original Nature/Soft Occlusion Shaders better
    Changed: Billboard Generator brightness option has been modified to match the original colors better when brightening

    Fixed: GPUIStandardInclude.cginc errors on some Unity 2017.2 versions
    Fixed: Standard Shader Cutout variant not showing in build
    Fixed: Meshes with a single submesh but multiple materials causing issues in rendering
    Fixed: LOD cross-fading results changing with time scale
     
    ftejada, Bzuco, MTandi and 2 others like this.
  13. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,118
    "We have also revamped the GPUI versions of the Nature/Soft Occlusion shaders and their corresponding billboard shaders to match the original look of your Soft Occlusion trees better. If you were having color mismatches previously when using such trees, it should be fixed with this update."

    Tested and it doesn't work. Now directly the trees using this shader (soft occlusion) are not rendered. (They are invisible)
    I sent an image to the developer that proofed that but he ignores this case.

    TreesNotVisible.JPG
     
  14. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    812
    What version of unity are you using?
     
  15. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,118
    Unity 2018.2.17
     
  16. Ancient76

    Ancient76

    Joined:
    Nov 12, 2018
    Posts:
    19
    Hi,

    So, this GPU Instancer is more effective then Unity GPU Instancing?
     
  17. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    As we have told you in response to your email, this screenshot does not help us understand the problem; we need more information. Please email us the package we have asked for in the email: a unity package that shows this problem. If you are unable to provide this package, please tell us the steps to recreate this problem in a new scene.

    Setting up the Tree Manager to use Soft Occlusion trees is actually very easy. You can take a look at this video to see how it is done:

     
  18. LouskRad

    LouskRad

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

    GPUI uses Indirect GPU Instancing methods, and Compute Shaders for GPU culling operations. By doing so, some of the limitations that apply to Unity's default material instancing are bypassed.

    If you are not familiar with these concepts, you can take a look at this part of the wiki.

    You can also download demo builds to test GPUI in your system for comparison.
     
  19. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,118
    I do not recommend using GPU Instancer asset, it has a lot of compatibility problems with other assets (water shaders, post image effects, etc..) and it only works with a few shaders. Also, as you can see in this forum, it is very tricky and prone to errors.
    Frankly for that price it is not worthwhile. I purchased it and I am very regretful.
     
    Last edited: Dec 14, 2018
  20. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    740
    I've checked the isInitialized before calling the offset glocal position. But it still thrown a null reference of the buffer to me.

    Edit: I added a debug line to the method, and found those prototypes without instances got this null error.
     
    Last edited: Dec 14, 2018
  21. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,118
    I have showed your asset is not working in some scenarios, I informed you about all the other assets I was using in my scene and they are not strange assets (Gaia, Gena 2, Amplify Color...). None of them are causing problems on one another, and if your asset is so tricky and prone to errors it is not my fault. These limitations and compatibility problems of GPU Instancer with other current assets are not warned in the asset store description so if the problems are present, the customer has a right to get a refund.
     
    Last edited: Dec 14, 2018
  22. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    Hi Harekelas,
    Thank you for reporting this issue.

    We have fixed the case with SetGlobalPositionOffset when there are prototypes with no instances. I have sent you the fix package by email. Please let us know if this solves the issue.
     
  23. Ancient76

    Ancient76

    Joined:
    Nov 12, 2018
    Posts:
    19
    I'm familiar with instancing. The idea is to reduce draw calls as much as possible. Actually i'm not new to game design, i have worked with UE4 and Cryengine. But Unity is different, mainly because without these exterior assets it's useless, for me at least.
    I'm gonna have a lot of vegetation in my project, so something like this is must have.

    What about this shader compatibility? Do i need to have specific shaders?
    Also i have my own trees that i made in 3ds max. I should be able to use them with your utility?
     
  24. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    Shader compatibility is most of the time not an issue. GPUI auto-converts a copy of the original shader to work with its setup at runtime - most shaders are automated as such, and if not you can take a look at this for manual setup. Tesselation and Geometry shaders are not compatible since they don't work with GPU instancing.

    GPUI also comes with its own foliage shader if you want to have that for terrain details, but you can use a custom shader for that too if you'd like.

    If you're an advanced user, you can also make use of the no-game object workflow features through the GPUI API for refined control and better performance; there are methods that take in matrix4x4s and use GPUI's core instancing features.

    Having your own trees with your own shader is not a problem; you can use GPUI's Prefab instancing features if you don't want to define your trees on the Unity terrain. There is also an automatic billboard generator which is designed mainly for trees - it basically generates single quad billboards with atlas maps. The billboards are automatically rendered as the final LOD of the prototype. If the billboard system cannot bake the maps for your custom tree shaders, you can also use this billboard system to define your own billboards with a custom mesh and material.
     
  25. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    740
    Great! Thanks!
    And I've noticed the 0.98 version is online on assetstore, does this version support single prefab manager for all mapmagic object output? You mentioned it will be done with a bigger plan in your roadmap, cuz I'm using my own methods to register all generated instances to a global manager when a terrain is enabled and remove all instances within the rect of a terrain when it's disabled.
    And this required me to change some of the code in the script GPUIMapMagicIntegration. If the new update still need one manager for each terrain tile, then I'll wait for the new feature before I update my modified version.
     
    JohnTomorrow likes this.
  26. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    79
    Hello, I am also using external assets as you mentioned(Adams assets, Amplify etc) and gpui works fine for me. Are you sure it is not your fault because 90% of the times I asked for help, It was my fault that I didn't understand How and Whento use the gpui(read gpui wiki). Also as you said in the previous message about the developer being unresponsive that's not true whenever I asked for any query He replied within a day also Implemented some feature required for my project instantly(You can read same from other customers too on review section )
     
    Harekelas likes this.
  27. Ancient76

    Ancient76

    Joined:
    Nov 12, 2018
    Posts:
    19
    Thanks for clarification.

    HDRP has great shaders, but it's not fully ready if i'm correct? And your Instancer is compatible with HDRP.
    What i like about this is that it works with Map Magic, and i need something like this.
     
  28. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,118
    In my case, I have read the docs and followed the videos. About using GPU instancer, it is claimed (as the developer assures) it is very easy to setup. However in a simple scenario, as in my project, the Nature/soft occlusion tree shader is not working well. I showed it to the developer and I give him all data he asked to me. Even he sent me the new update (0.98) but after try it the result was worst because the palm trees were not rendered (the trees are not visible).
    As can be seen in the previous screenshots I have posted, the colors are changed and make the tree prototypes useless.
    Really I wanted to benefit of GPU instancer and I have tried to fix the problems, without success.
    The developer is not able to solve this issue, so I 'm very disappointed because I have purchased an asset and it is useless for me.

    Anyway thanks for your help.
     
  29. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    The single manager for MapMagic did not make it into the v0.9.8. We're working on this, we'll let you know when it's done.
     
  30. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    Yes, Unity still defines HDRP and SRP in general as preview and experimental. GPUI is compatible with HDRP, it can auto-convert HDRP shaders as well. However, please note that the included foliage shader does not have a HDRP version, so you will have to use your own shader for foliage.
     
  31. hassonhamo3

    hassonhamo3

    Joined:
    May 25, 2018
    Posts:
    37
    hey , great asset , i have two questions ,
    1-Do I have to use Astroid Generator to instance my prefabs ? can't I just drag them to the scene ? I tried to drag them and that didn't work , but when using Astroid Generator worked fine , but I'd like to place then where ever i want .
    2- i'm using Gaia and can't see the option for Gpu instance in Gx window , i'm placing bushes all over my terrain and this drop my fps , I added "Detail manager for terrain " and generate the bushes (I don't know if i have to do that) , ran the game in run time all bushes disappeared and fps is the same as before but after one minute (more or less) fps goes up the double .from 7 fps to 14 .
     
  32. hassonhamo3

    hassonhamo3

    Joined:
    May 25, 2018
    Posts:
    37
    do i need to add something to my camera ? or player ? i feel like i'm missing something , even if i use Astroid Generator to instance my prefabs the render will never turn on , it keeps being off and objects are invisible even if player comes closer and touches them , nothing at all ;(
    and if i don't use Astroid Generator to instance my prefabs and drag them to the scene
    the render will be on all the time and never turn off weather the player is near or far .
     
  33. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    115
    Hi !

    How i can register Prefabs in scene Realtime ?
    ( i want created new objects then call register Prefabs in scene to reload all objects in scene )
     
  34. RyanNguyen

    RyanNguyen

    Joined:
    Jul 20, 2016
    Posts:
    7
    Is there a way to use prefab that has animation on GPU Instancer?
     
    Last edited: Dec 17, 2018
  35. nrodemund

    nrodemund

    Joined:
    Sep 15, 2018
    Posts:
    14
    Did you already resolve the 2018.3 crash on MatrixBuffer size changes*? I could do some kind of quick-and-dirty workaround, but that may not be the right way to do, not even sure if that causes a memory leak when happening too often...


    change in: public static void UpdateVisibilityBufferWithMatrix4x4Array(GPUInstancerPrefabManager prefabManager, GPUInstancerPrefabPrototype prototype, Matrix4x4[] matrix4x4Array)

    Code (CSharp):
    1.            
    2.  if (matrix4x4Array.Length > prefabRuntimeData.transformationMatrixVisibilityBuffer.count)
    3.             {
    4.                 prefabRuntimeData.transformationMatrixVisibilityBuffer.Dispose();
    5.                 prefabRuntimeData.transformationMatrixVisibilityBuffer = new ComputeBuffer(matrix4x4Array.Length, GPUInstancerConstants.STRIDE_SIZE_MATRIX4X4);
    6.                 GPUInstancerUtility.SetAppendBuffers(prefabRuntimeData);
    7.             }
    *) Reproduce:
    2018.3.x, according to Support Forums this also occurs in >2019.1.0a4
    GPUInstancerAPI.InitializeWithMatrix4x4Array(prefabManager, key, matix4x4buf);
    // later do this with a matix4x4buf that has a bigger size than before (i.e. more trees in this region)
    GPUInstancerAPI.UpdateVisibilityBufferWithMatrix4x4Array(prefabManager, key,matix4x4buf);
     
  36. LouskRad

    LouskRad

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

    The Asteroid Generator in the package is intended to be only an example of runtime generated prefabs, and it is not a tool that you should use for GPUI in general.

    Setting up GPUI is for your prefabs is quite easy; you simply add a Prefab manager and drag/drop your intended prefabs on the manager. When you add new prefab instances or remove them from your scene, you can click the Register Instances in Scene button to update GPUI. You can take a look at the getting started wiki page for more information.

    Also there are a few video tutorials that could help you. If you want to use GPUI with your prefabs, particularly Prefab Manager Part 1 can help you.

    If you have Gaia, the GPUI menus should be under "GurBu Technologies" in the GX menu. If they are not there, there could be a compile error in your project.

    As for the Detail Manager, you can add the manager after you generate the foliage with Gaia, or click on the Generate Prototypes button if you added it before generating them.

    I would strongly recommend watching the tutorial videos. If you have any further questions, please feel free to ask.
     
  37. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    Hi there!

    You have a few options to do this, but the easiest is to use the Enable Runtime Modifications and Auto-Add Remove Instances options to let GPUI auto-manage this. You can take a look at this wiki document for details.
     
    thanhle likes this.
  38. LouskRad

    LouskRad

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

    If you mean simply a Mesh Renderer with an animation component on its game object, using the Enable Runtime Modifications and Auto-Update Transform Data options will let you use GPUI with the animated prefab.

    However, if you mean a rigged and animated prefab with a Skinned-Mesh Renderer, this is currently not supported by GPUI.
     
  39. LouskRad

    LouskRad

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

    I'm not sure I understand the case that you are referring to, but:

    If this represents the issue, the problem seems to be that you are trying to change the buffer sizes without re-initializing the buffers. If you need to use dynamic buffer sizes, you either need to define a bigger array size than you need initially (and let the unused instances be zero-ed out) or re-initialize the buffers with the new size before updating them.

    You can call GPUInstancerAPI.InitializeWithMatrix4x4Array(prefabManager, key, matix4x4buf) with the new buffer sizes if you'd like to re-initialize the buffers.

    In short, you can call the GPUInstancerAPI.InitializeWithMatrix4x4Array when you new up an array, and call the GPUInstancerAPI.UpdateVisibilityBufferWithMatrix4x4Array when you update the array members.
     
  40. LouskRad

    LouskRad

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

    We're proud to say that GPU Instancer has been nominated for the Best Development Tool category in the Unity Awards 2018.

    Thank you all for supporting GPUI!

    UnityAward2018-Nominee.png
     
    838nHex, thanhle, Alex3333 and 5 others like this.
  41. kblood

    kblood

    Joined:
    Jun 20, 2012
    Posts:
    76
    Just bought this tool as I have been trying to optimize a few things in a concept I am experimenting with.

    Sure works great, the performance went from having trouble getting 60 fps, to getting 70 to more than 100 fps. So I figured I would try the next step, trying to do it in VR. But... some of the main benefits seems lost?
    • Out of the box solution for complex GPU Instancing.
    • VR compatible. Works with both single pass and multipass rendering modes.
    • Mobile compatible. Works with both iOS and Android.
    • Easy to use interface.
    • Tens of thousands of objects rendered lightning fast in a single draw call.
    • GPU frustum culling.
    • GPU occlusion culling (non-VR platforms only).

    From the first post in this thread. So fair enough, GPU occlusion is a problem, but what about the frostrum culling? It seems to have trouble figuring out what to actually cull. I cannot find much in the Wiki or anywhere about how to properly use this asset with VR.
     
  42. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173
    In have a problem: some GPUI prefabs are rendered ok in editor, but in runtime the assigned material is not rendered. Only the prefab using wireframe shader is rendered. The bad rendered prefabs use standard specular shader.

    Look at the little spaceships and the spheres (material not rendered), and the little prisms (material rendered ok).
    First image is grabbed playing in editor, the second image is grabbed playing runtime 1920x1080.
    Editor_Image_02.JPG Runtime_Image_02.JPG
     
  43. LouskRad

    LouskRad

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

    In general, VR should not need any special treatment. The only consideration is related to multiple camera usage. If you enable XR in your project, Unity by default uses your camera to render "Both" eyes. This results in a single camera matrix that GPUI already uses, so you should not have to change anything in the default setup.

    The problem with occlusion culling in VR is related to the depth texture calculations on the Camera MVP matrix; which is irrelevant for frustum culling. So frustum culling should work as expected in VR. The only scenario that I can think of where frustum culling could be an issue is the FPController in the package - where the mouse and head movements contradict and effect the camera matrix at the same time. But that's because that controller was not designed for VR.

    What is your setup that you had problems with this in?
     
  44. MTandi

    MTandi

    Joined:
    Aug 4, 2017
    Posts:
    5
    Hello!

    I'm using `GPUInstancerDetailManager` to display details, and `GPUInstancerInstanceRemover` to remove them. I need to get the result detailMapLayer after the removal, but I can't find a settings that would write the map onto Unity terrain in runtime.

    How should I apply the GPU Instancer detail changes to the Unity terrain details map?
     
  45. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    Hi Frank,

    This looks like a shader variant problem. Can you take a look at this wiki link and see if it helps?
     
  46. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    537
    Hi Mtandi,

    GPUI currently does not persist the removal changes. Applying the changes to the Unity terrain itself at runtime would be too slow, and also persisting changes like this would require you to keep the terrain data which would take up too much memory. So there is currently no generic solution to persist these changes that is fast and optimized.

    You can place GPUInstancerInstanceRemover objects at the removal points to persist them; GPUI would immediately cull the details under them when these are present. However, if you want to remove objects while moving (like in the grass mower example) you need to manually implement a solution for this (like recording the movements of the remover each frame) and use the API instead.
     
  47. MTandi

    MTandi

    Joined:
    Aug 4, 2017
    Posts:
    5
    Well, I don't plan to update it frequently.
    Is there a way to get something like terrainData.GetDetailLayer(...) with GPUInstancerInstanceRemover modifications but from the GPUInstancerDetailManager, so I could write it by myself?
    I just need to get the modified detail layer because I calculate the detail density depending on the splatmap layer alpha.
     
  48. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173

    This sentence solved the problem:
    "This can be solved by changing the material on your prefab to use the GPUI version of the shader (e.g. "GPUInstancer/Standard (Specular setup)") instead of the original (e.g. "Standard (Specular setup)")

    You are a GENIUS !!! TNX !!!
     
    LouskRad likes this.
  49. gww2

    gww2

    Joined:
    Jan 13, 2017
    Posts:
    15
    I'm working on a project where we are streaming a large dynamic world using Map Magic and I've been doing some optimizations to the cell data generation from the detail layer, including creating pools for the spatial partitioning data and the cell lists. Since our terrains are always equally sized this went together fairly well, but I had to change a good number of checks if a list/array was null.

    The biggest hit initially was the MirrorAndFlatten<T> function in GPUInstancerUtility. The pooling system meant I didn't need to instantiate a new array every time, as well as being able to cache the sizes of the 2d array coming in. I also changed the terrainData calls (GetHeights() and GetDetailLayer()) to pull the whole arrays, and cache them, then run the mirrorandflatten on a subsection of the array.

    We're reaching a limit on the optimization at this point, so now I'm looking at threading this process after getting the data arrays.

    Is there anything I might be missing in this process that I should look at?
     
    LouskRad likes this.
  50. kblood

    kblood

    Joined:
    Jun 20, 2012
    Posts:
    76
    First off the issue was with the FP Controller, which I figured made sense, so I tried replacing it first with a VRTK setup and when that did not work I tried a regular camera. The problem did seem to become different though, because now it did not just do the frostrum in a decoupled direction from the direction you are looking with your VR setup but instead it does not seem to show the stuff that had been instanced at all, it just showed 2 or 3 trees. Hmmm, if it was two trees I guess that might have been the first two trees and the rest was supposed to be made from instances.

    Maybe the setup does something to the camera when its first setup? I will try to experiment a bit.