Search Unity

[RELEASED] GPU Instancer

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

  1. Nihilus0

    Nihilus0

    Joined:
    Jan 25, 2017
    Posts:
    52
    @GurhanHazinedar
    Thank you for your reply. I thought you would misunderstand my question with the wrong translation. But you gave me exactly what I wanted. I am grateful for this as well.

    and I have additional question.
    I found that you blocked Prefab Prototype addition and removal at runtime. If the infinite world dynamically repeats the drawing and disappearing of many kinds of (different shapes) items, should I register hundreds to thousands of Prefab Prototypes on the editor's inspector before the start of the scene? I would like to know what kind of problems can cause the registration / removal of Prototype to be done dynamically.
     
    Last edited: Oct 12, 2018
  2. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    You are welcome :)

    Add and Remove buttons for the prototypes are disabled at runtime at the Inspector Window, but it is still possible to add new prototypes from code for procedural systems, using internal variables of GPUI. There is an example code at this post:
    https://forum.unity.com/threads/released-gpu-instancer.529746/page-6#post-3715336

    We will add new API methods to make it easier in the future, so that you can send a list of runtime generated objects and get the new prototypes defined on the Manager or remove them safely with one API method call.
     
  3. Nihilus0

    Nihilus0

    Joined:
    Jan 25, 2017
    Posts:
    52
    Thank you.
     
  4. ebadier22

    ebadier22

    Joined:
    Jun 20, 2017
    Posts:
    9
  5. GurhanH

    GurhanH

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

    Yes, GPUI supports custom projection matrices. But you should make sure that GPUI Manager's LateUpdate function runs after you change the projection matrix, because we send this data to GPU to make various calculations (culling, LOD, etc.)
     
    ebadier22 likes this.
  6. ebadier22

    ebadier22

    Joined:
    Jun 20, 2017
    Posts:
    9
    Sounds good. Many thanks for your quick reply.

    What about the support of stereo rendering ? I currently use DX11 multipass stereo where I manually creates 2 cameras (1 per eye) and it works great on Windows 10 (not optimal but supporting nvidia Quadro Sync to manage a Cave system). Do you think GPUI will work as expected with the 2 cameras ?

    Best,
     
  7. LouskRad

    LouskRad

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

    The v0.9.1 update is live, and it mainly introduces HDRP and LWRP support with automatic SRP shader conversion. Here is the full changelog:

    v0.9.1:
    New: Added support for the High Definition Render Pipeline (HDRP)
    New: Added support for the Lightweight Render Pipeline (LWRP)
    New: Automatic shader conversion now also works for SRP shaders
    New: Added option to use custom Health/Dry noise texture for each detail prototype
    Changed: Further optimized Detail Manager memory usage for Android
    Fixed: Automatic shader conversion now creates shaders in an internal folder if the original shader is in "Packages" (Package Manager)
    Fixed: Error on shader conversion for ShaderGraphs
    Fixed: GPUIStandardInclude.cginc errors on some Unity 2017 versions

    We hope you enjoy the update.
     
  8. LouskRad

    LouskRad

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

    GPUI currently works with both single pass and multipass stereo modes. However, please have in mind that GPUI does culling calculations on a single camera. Thus the system works out of the box in cases where Unity internally uses two cameras in multi-pass mode, but this works because Unity supplies a unified projection matrix for the camera object. On the other hand, if you manually create your cameras and modify their projection matrices, you might need to manually supply the necessary projection matrices depending on your setup (we calculate the MVP matrix from the projectionMatrix and worldToCameraMatrix).

    If you'd like to see GPUI in action for multi-pass VR, you can download a demo from the following link:
    https://www.gurbu.com/demobuilds
     
  9. brunoj

    brunoj

    Joined:
    Oct 1, 2012
    Posts:
    2
    Hi LouskRad,

    when do you think you will have ready the support for SkinnedMeshRenderer, it is critical for my game.

    Thanks,
    Bruno
     
  10. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Skinned mesh support is in our roadmap as the next big feature update, but it is still too early to give a definite release date. We also have other improvements and smaller features that are lined up, but these are mostly designed to improve the core system and they will add to the power of instancing skinned meshes as well.
     
  11. PeterJK

    PeterJK

    Joined:
    Dec 2, 2012
    Posts:
    35
    I'm wondering if I've run into a bug, or am just doing something wrong.

    I have a an array of floats that I'm using to define a variation e.g.

    float [] sizes = new float[bufferSize];
    GPUInstancerAPI.DefineAndAddVariationFromArray(prefabManager, prefab.prefabPrototype, "sizes", sizes);

    Later, when I call

    GPUInstancerAPI.UpdateVariationFromArray(prefabManager, prefab.prefabPrototype, "sizes", sizes);

    I get this exception:

    InvalidCastException: Specified cast is not valid.
    GPUInstancer.GPUInstancerPrefabManager+<UpdateVariationsFromArray>c__AnonStorey9`1[T].<>m__0 (GPUInstancer.IPrefabVariationData v) (at Assets/GPUInstancer/Scripts/GPUInstancerPrefabManager.cs:689)
    System.Collections.Generic.List`1[T].Find (System.Predicate`1[T] match) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
    GPUInstancer.GPUInstancerPrefabManager.UpdateVariationsFromArray[T] (GPUInstancer.GPUInstancerPrefabPrototype prototype, System.String bufferName, T[] variationArray) (at Assets/GPUInstancer/Scripts/GPUInstancerPrefabManager.cs:688)
    GPUInstancer.GPUInstancerAPI.UpdateVariationFromArray[T] (GPUInstancer.GPUInstancerPrefabManager manager, GPUInstancer.GPUInstancerPrefabPrototype prototype, System.String bufferName, T[] variationArray) (at Assets/GPUInstancer/Scripts/API/GPUInstancerAPI.cs:258)

    Other variations that use arrays of float4 seem to work ok. Any help is greatly appreciated! This is on v0.9
     
  12. simonjacoby

    simonjacoby

    Joined:
    Oct 6, 2014
    Posts:
    14
    Hi,

    I just purchased your asset, and I'd like to thank you for sharing this, it really freed up some needed CPU time for me and gave me a really nice boost. That said, I found a couple of issues that I'd like you to know about:

    - It doesn't work well together with Aquas (which is a popular water asset here on the store). I've tracked it down to the caustics projectors in Aquas; if they're enabled each tree instance will take an incredible amount of time to render for some reason. The problem will show up in the profiler as Gfx.WaitForPresent taking a long time (in my case ~200ms). There's also a noticeable (but not as devastating) hit when the Aquas reflection script is active. Disabling Aquas completely gives the expected rendering boost.

    - The custom shaders for the Naturemanufacture assets (Advanced Foliage Pack, Mountain Tree Pack) doesn't seem to work with GPUI. The shaders are converted by GPUI (and can be found under the GPUI shaders), but nothing using them will be rendered (all my trees / foliage disappeared at first, switching to the GPUI foliage shader fixed the problem).

    You might want to look into the specific packs because they are often featured quite heavily on the store front page together with Gaia, so I'm guessing there's a lot of devs out there using these packs together.

    I'm happy to provide additional info on my setup if you need it.

    Thanks,

    Simon
     
  13. simonjacoby

    simonjacoby

    Joined:
    Oct 6, 2014
    Posts:
    14
    Hi again,

    I found a small bug in SetCamera() in GPUInstanceManager.cs, that will cause it to add three GPUInstancerHiZOcclusionGenerator components to the camera instead of one. If you change lines 480-485 from:
    Code (CSharp):
    1.  
    2. if (isOcclusionCulling)
    3. {
    4.   cameraData.hiZOcclusionGenerator = cameraData.mainCamera.gameObject.AddComponent<GPUInstancerHiZOcclusionGenerator>();
    5.   cameraData.mainCamera.depthTextureMode = DepthTextureMode.Depth;
    6.   cameraData.hiZOcclusionGenerator.mainCamera = cameraData.mainCamera;
    7. }
    8.  
    to

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


    There will be only one, which made the HiZ generation go from about 2ms to 0.67ms (Geforce 1080 @ 4k).

    :)

    /S
     
    GurhanH and Neviah like this.
  14. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi @PeterJK

    There was a missing type check on the new UpdateVariationFromArray API method, so when you have multiple variations with different types you get an invalid cast exception.

    To fix the issue you need to change GPUInstancerPrefabManager.cs on line 688 from this:
    Code (CSharp):
    1. PrefabVariationData<T> variationData = (PrefabVariationData<T>)_variationDataList.Find(v =>
    to this:
    Code (CSharp):
    1. PrefabVariationData<T> variationData = (PrefabVariationData<T>)_variationDataList.Find(v => v is PrefabVariationData<T> &&
    We will add the fix on the next update. Thank you for reporting it.
     
    PeterJK likes this.
  15. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi @simonjacoby

    Thank you for contacting us with the fix. We will add the necessary checks on the next update.

    We will look into the issues with the Aquas and NatureManufacture assets and contact you with the results.

    However, sometimes it is not possible to make the assets compatible on our end (for example when the asset uses scripts that change material properties or meshes at runtime). In these cases the integration must be on the asset that is making these changes. And since our Tree Manager is new and will be updating frequently for a while, it won't be productive to make an integration at this stage. But we are planning to make compatibility updates and provide a list of commonly used assets that we tested with on our web page, when the Tree Manager is out of beta. And contact other asset developers for possible integration with GPUI when needed.
     
  16. PeterJK

    PeterJK

    Joined:
    Dec 2, 2012
    Posts:
    35

    Fantastic, this fixes the exception. Thank you!
     
  17. simonjacoby

    simonjacoby

    Joined:
    Oct 6, 2014
    Posts:
    14
    Ok, sounds great! Thanks for the swift reply :)

    I managed to make a "quick fix" for Aquas to get (most of) it running without tanking the framerate. The changes made may depend on the project setup so YMMV, but here they are:

    - On the AQUAS Waterplane prefab there's a AQUAS_RenderQueueEditor script. This causes issues and can be disabled. The reflection script on the prefab can be kept.

    - For the reflection, I duplicated my landscape, put it in a separate layer and removed the trees/foliage. In the AQUAS_Reflection script, I changed "Reflect Layers" to the layer I put my duplicated landscape in.

    - The AQUAS camera which is added to the scene's main camera can also be disabled

    - The main culprits for the massive framerate hit are the Unity projectors on the Primary/Secondary caustics projectors. I disabled both (the AQUAS scripts, not just the projectors)

    Most of the look of the water is kept with these changes. The biggest visual change is the loss of caustics (but that could for example be fixed by using a separate shader on the ocean floor that projects two uv-scrolling textures). Something for later :)
     
    LouskRad and GurhanH like this.
  18. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Is it possible to script the wind effects on the supplied foliage shader? The game I'm working on has storm effects that can be triggered at anytime, I'd like to make the grass match the wind's power if a storm is active. The grass is being applied through the MapMagic integration.

    Btw the MapMagic integration is great. Initial testing shows smooth frame rates while other highly rated foliage assets had bad performance problems when they were initially initiating.
     
    ftejada likes this.
  19. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Hi @JohnTomorrow,

    There is an example about how to change detail prototype settings in AddModifyTerrainsRuntime demo scene. You can check for UpdateManagers method for an example usage under GPUInstancer/Demos/AddModifyTerrainsRuntime/Scripts/TerrainGenerator.cs

    For MapMagic integration easiest would be to keep a reference to the GPUInstancerMapMagicIntegration component and change the windWaveSize, windWaveTint, windWaveSway, windWaveTintColor prototype values for the detailPrototypes list.

    You can also change the wind direction from terrainSettings.windVector.

    Afterwards you will need to apply the changes to detail managers by calling:
    GPUInstancerAPI.UpdateDetailInstances(detailManager, false);

    Happy to hear it worked out well. We came up with an unusual way to initialize the grass instances. All the calculations are made in GPU with ComputeShaders without reading any data back. It took some effort to do the math for the terrain on the gpu but it was worth it :)
     
    JohnTomorrow likes this.
  20. simonjacoby

    simonjacoby

    Joined:
    Oct 6, 2014
    Posts:
    14
    I found a bug related to 2018.3 and forward rendering. It seems Unity has removed the fogCoord from VertexOutputForwardBase, and instead is passing it via eyeVec.w. This makes GPUIStandardInclude.cginc fail to compile when selecting the forward rendering path. A quick fix is to change line 27 of GPUIStandardInclude.cginc from:

    Code (CSharp):
    1. UNITY_APPLY_FOG(i.fogCoord, c.rgb);
    to

    Code (CSharp):
    1. UNITY_APPLY_FOG(i.eyeVec.w, c.rgb);
    Then should be working again :)
     
    LouskRad and GurhanH like this.
  21. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    Thank you for reporting it. We will add the necessary version checks on the next update.
     
    simonjacoby likes this.
  22. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    How well would this work with Oculus GO or mobile VR in general being both platforms are android as they get built in unity using the android API Levels. Really looking for a way to push mobile VR to a higher level so any info or an APK for mobile vr would be great to test out with. If I'm going to drop $65 on an asset I have to atleast know it has a chance of working for what I need. Specifically needing it for outdoor nature type environments with the unity terrain and all things vegetation needs.
     
    Last edited: Oct 20, 2018
  23. LouskRad

    LouskRad

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

    We have recieved quite good feedback from our users that target the mobile VR platforms. However, even though we have an Android demo and a PC VR demo seperately, we currently do not host a mobile VR APK.

    All the GPUI features work for target mobile VR platforms that support compute shaders and GPU instancing as well - with the exception of the occlusion culling feature; but it will also be added in a future update.
     
    Lars-Steenhoff likes this.
  24. Raystorm

    Raystorm

    Joined:
    Mar 28, 2016
    Posts:
    9
    GPUI have 1 draw call per prefab right?
    Does combining texture into 1 atlas have any effect for it?
     
  25. LouskRad

    LouskRad

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

    GPUI uses 1 draw call per mesh-material combination; so there will be more than one if the prefab has more then one mesh or submeshes with different materials. Also one extra draw call will be made for shadows if the prototype is set as shadowcasting.

    The textures set on the metarial(s) have no effect on the draw calls.
     
  26. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    How tricky will it be to pass a bounds to the foliage system to inform it not to render in that area? Would GPUInstancerDetailManager.GetInstanceDataForDetailPrototypeWithComputeShader() be the right place to plug in code?
     
  27. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    539
    We are actually planing to implement this feature quite soon. Currently there is no easy and general solution for this. It would break other systems like spatial partitioning if you change the methods in the Detail Manager. However, it is in our road-map to add API methods to make this easy. We have an update coming up in the next few days and we are planing to implement this feature right after that.

    One way to accomplish this right now without breaking other systems would be to change the detail data on the terrain with TerrainData.SetDetailLayer and then call GPUInstancerAPI.InitializeGPUInstancer. Manager will get the terrain detail data and reinitialize all the buffers. But this will cause some overhead and details will not render until the initialization ends. So, I wouldn't recommend this.
     
    JohnTomorrow likes this.
  28. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    I'll be patiently waiting :)

    Another question, is there any limitations or known issues with rendering on OSX? I haven't dug into it yet but I assume the machine will need support for compute shaders?
     
  29. LouskRad

    LouskRad

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

    There are currently no known issues or limitations for OSX. The MacOs requirement is that the target platform should support Metal API. If you'd like to test it out, you can take a look at the Metal build as well: https://www.gurbu.com/demobuilds
     
  30. ryanflees

    ryanflees

    Joined:
    Nov 15, 2014
    Posts:
    59
    Hi, however this might not be a question very related to using GPUI as I'm learning the solution for massive rendering in Unity and DrawMeshInstancedIndirect method and integrate the GPUI workflow more friendly to my project.
    All of these are tested in deferred rendering, shadow distance is 40, and two cascades.

    Seems that GPUI draws the mesh with ShadowCastingMode.Off and ShadowCastingMode.ShadowsOnly separatly.
    GPUI can draw 10000 of my objects in the scene with 150 fps. (An empty scene on my PC runs at 160fps)
    I've followed Unity manual and read the code of GPUI and try to do the similar thing.

    I made a much simpler instance shader for the mesh and a shadow caster shader. And some matrix transformation in procedural:setup. No compute shader involved. The matrice are passed to shader from C# with a simple Matrix4x4[] compute buffer.

    Code (CSharp):
    1.  Graphics.DrawMeshInstancedIndirect(m_TestMesh, 0,
    2.                                m_TestMaterial,
    3.                                m_TestBounds,
    4.                                m_TestArgsBuffer,
    5.                                0,
    6.                                m_TestMpb,
    7.                                ShadowCastingMode.Off, true, 0);
    Calling the method like above to draw 10000 objects can runs 150fps which is good.

    Code (CSharp):
    1.  Graphics.DrawMeshInstancedIndirect(m_TestMesh, 0,
    2.                               m_TestShadowMat,
    3.                               m_TestBounds,
    4.                               m_TestShadowArgsBuffer,
    5.                               0,
    6.                               m_TestShadowMpb,
    7.                               ShadowCastingMode.ShadowsOnly, true, 0);
    But by this calling, my framerate drops to 120.

    Use "GPUInstancer/ShadowsOnly" shader and try again (don't mind the StructuredBuffer for a sec), still 120 fps.

    And I tried to compare the difference how GPUI set the buffer, and I find that the "runtimeData.args[1]" and "runtimeData.shadowArgs[1]" are always 0 at the start of the game, which should be instanced count.

    In my manual test I set the instanced count as 10000 in the m_TestArgsBuffer which is an obvious difference.
    As if I set mine as 0, my shadow won't show up at all.

    And GPU prolier shows the difference that GPUI have very little GPU time in Shaodws.RenderShadowMap.
    TIM截图20181024005115.png TIM截图20181024005205.png

    Seems that the GPUI doesn't need to re-create shadow map every frame magically? I'm already very confused on this point.
    I haven't looked into the GPUI compute shaders yet as I'm already in a mess on the C# side. Can you explain a little bit about the basic strategy about rendering the shadows in GPUI.
     
    Last edited: Oct 23, 2018
  31. LouskRad

    LouskRad

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

    The difference in performance lies in GPUI's compute shaders. GPUI does various kinds of culling operations in these compute shaders - and in your case, you see the shadow distance culling in action. The first draw call draws the meshes and since no occlusion or frustum culling happens (as far as I see from your screenshots), the performance of this indirect call is the same. However, GPUI compute shaders cull the ShadowsOnly instances if they are beyond the visible shadow distance, so it draws much less then the 10k instances for shadows.

    Also, you see the instance counts as 0 in the args buffer because GPUI sets the actually desired instance counts after culling operations directly from the GPU.
     
    ryanflees likes this.
  32. ryanflees

    ryanflees

    Joined:
    Nov 15, 2014
    Posts:
    59
    Thanks for the explanation. I'm diving into GPUI compute shaders today. :)
    That's really smart to put as much work to GPU as possible :rolleyes:
     
    LouskRad likes this.
  33. ryanflees

    ryanflees

    Joined:
    Nov 15, 2014
    Posts:
    59
    OK, I just figured out how GPUI shadow lod works, it is so brilliant!!!
    The shadow distance can be set manually which can be any value and by default it's set as QualitySettings.shadowDistance.
    Correct me if I'm getting it wrong by the following

    Code (CSharp):
    1. lodNo = 9;
    2.     shadowLodNo = 9;
    3.     for (uint i = 0; i < lodCount; i++)
    4.     {
    5.         if (size > lodSizes[i / 4][i % 4])
    6.         {
    7.             if (!isCulled)
    8.                 lodNo = i;
    9.             if(distance < shadowDistance)
    10.                 shadowLodNo = i;
    11.             break;
    12.         }
    13.     }
    Code (CSharp):
    1. gpuiInstanceLODData[id.x].y = shadowLodNo;
    In compute shader, shadow lod is calculated and set to lod data's y to determine whether it should be culled.

    And each frame GPUI reset the shadow append buffer as 0
    Code (CSharp):
    1.   rdLOD.shadowAppendBuffer.SetCounterValue(0);
    2.                     visibilityComputeShader.SetBuffer(instanceVisibilityComputeKernelId, GPUInstancerConstants.VisibilityKernelPoperties.TRANSFORMATION_MATRIX_APPEND_BUFFERS[lod],
    3.                             rdLOD.shadowAppendBuffer);
    4.                 }
    and run the compute shader
    Code (CSharp):
    1. visibilityComputeShader.Dispatch(instanceVisibilityComputeKernelId,
    2.                 Mathf.CeilToInt(runtimeData.transformationMatrixVisibilityBuffer.count / GPUInstancerConstants.VISIBILITY_SHADER_THREAD_COUNT), 1, 1);
    and in compute shader, check lod data's y value and append the thread x as index if it's not culled

    Code (CSharp):
    1.  
    2.     if (gpuiInstanceLODData[id.x][lodAppendIndex] == lodShift)
    3.         gpuiTransformationMatrix_LOD0.Append(id.x);
    4. }
    Then copy the buffer count to shadow args buffer
    Code (CSharp):
    1.     ComputeBuffer.CopyCount(rdLOD.shadowAppendBuffer,
    2.                             runtimeData.shadowArgsBuffer,
    3.                             // LOD renderer start location + LOD renderer material start location + 1 :
    4.                             (rdRenderer.argsBufferOffset * GPUInstancerConstants.STRIDE_SIZE_INT) + (j * GPUInstancerConstants.STRIDE_SIZE_INT * 5) + GPUInstancerConstants.STRIDE_SIZE_INT);
    5.                        
    By the time of this the instanced count is already much smaller than the entire count of the objects.

    Then draw the shadow with DrawMeshInstancedIndirect :rolleyes:. Perfectly done!! Most calculations are done in GPU.
    Thanks for making such brilliant solution. ;)
     
  34. ebadier22

    ebadier22

    Joined:
    Jun 20, 2017
    Posts:
    9
    Hello,

    When I run GPUI with one camera and a custom projection matrix, it works great.
    When I run GPUI in stereo mode, 2 cameras (left and right eyes with custom projection matrices) there are some visual artifacts that are probably related to the fact that GPUI uses only the main Camera (left eye in my case) to do its calculations. Is there a way to setup GPUI to use two cameras simultaneously ?

    Thanks in advance,
     
  35. LouskRad

    LouskRad

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

    Currently GPUI managers don't support more than one cameras simultaneously. For multi-pass, you can either use the camera in "both" eyes mode - letting Unity do the matrix calculations on the background, or you can calculate a combined projection matrix and feed it to the GPUI system. However, the GPUI API currently does not provide a method to set the MVP matrix, so if you go this way you might need to alter the code a bit.

    Best wishes.
     
  36. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Yes, that's how it works. Glad to see you like it :)
     
  37. LouskRad

    LouskRad

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

    GPUI version 0.9.2 has been released on the Asset Store. This update is mainly focused on bug fixes and improvements.

    Among these improvements, we have integrated full Tree Creator support for the Tree Manager and the billboard generator system. Tree Creator billboards now have their own shader that supports their translucency. We have also fixed some linear color space issues with the billboard renderer.

    We have also added a few new API methods that you can use for adding and removing procedurally generated GameObjects without using prefabs. There is also a new scene that exemplifies how you can use these features.

    Here is the full v0.9.2 changelog:

    New: API Method to define prototypes for procedurally generated GameObjects without prefabs at runtime
    New: API Method to add instances to a prototype from a list of GameObjects at runtime
    New: API Method to remove prototype definition on the manager at runtime
    New: Demo Scene showcasing how to add-remove procedurally generated GameObjects on the Prefab Manager
    New: Tree Creator billboards now have their own shader that supports their translucency color

    Changed: Enable Auto. Update Transform by default if there is rigidbody on prefab
    Changed: Do not create runtimedata when there are no MeshRenderers
    Changed: Prefab Manager max distance editor limit increased to 10.000
    Changed: Memory optimization on Tree Manager initialization
    Changed: Improved SpeedTree billboards

    Fixed: UpdateVariationFromArray invalid cast exception for multiple variation with different types
    Fixed: Duplicate Hi-Z Generator components when SetCamera is called for the same camera multiple times
    Fixed: Tree Manager not calculating prefab scale
    Fixed: Missing reference exception when disabling manager for procedurally generated GameObjects
    Fixed: Prefab instances duplicating when dropped on the manager multiple times
    Fixed: Forward rendering GPUIStandardInclude.cginc fog error for Unity 2018.2.1 and later versions
    Fixed: Billboard mesh showing wrong atlas frames on some angles (Requires rebake of previous billboards)
    Fixed: Billboard colors and lighting corrected for linear color space
    Fixed: Tree Creator trees windzones now work correctly
    Fixed: Tree Creator billboards crossfading now works correctly
     
    JohnTomorrow likes this.
  38. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Hi, I'm trying this with my scene but i seem to get worse fps.
    My scene is setup so it is loading in at runtime with the player scene, not sure if this makes a difference. Also I'm using texture streaming for my materials, but i've tested with standard shader and it makes no difference.

    I added the prefab manager to the scene and it auto added the objects i have in my scene. Not sure if there is something i've missed or have to do. Cheers Jim

    On: 2215 batches, 50 fps, 1900 draw calls
    Off: 700 batches, 70 fps, 240 draw calls
     
    Last edited: Oct 30, 2018
  39. GurhanH

    GurhanH

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

    Looks like there is something wrong with the manager's setup. Can you check if you see the correct number of instances in the Prefab Manager:
    upload_2018-10-29_22-13-49.png

    Also if you have very few instances of some prefabs, it would be better not to include them, because GPU instancing helps in cases when you have a lot of instances of the same prefab. So if you have some prototypes with very low numbers here, it is better to not use GPU instancing with them.

    And in some cases there is one prefab that have all the repeating instances as children. We currently can not automatically detect the repeating instances that are children of a prefab (might be possible in the future after Unity 2018.3 release with nested-prefabs). If this is the case, you either need to change your workflow so that the repeating children are prefab roots, or register the instances that are children to a prefab manually by using our API.

    Please also check if you see any error or warning messages in the Console related to GPU Instancer.
     
    llJIMBOBll likes this.
  40. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Cheers, My scene are all prefabs and child to normal objects for tidiness, but i prob have average around 10 - 20 of the same object and some over 100. maybe not for my project my least got it for future :D, love the way this asset is aiming for and skinned mesh support really sounds good :D

    Cheers Jim
     
    LouskRad and GurhanH like this.
  41. MadAboutPandas3

    MadAboutPandas3

    Joined:
    Jul 3, 2017
    Posts:
    29
    Hi there,

    I am trying to build on android (currently on a pixel c tablet) I am getting following error message:

    Screenshot (10).png

    I only inserted the GPUI Detail Manager and when I try to simulate, all grass just plainly disappears (guess from the same error).
    Any ideas what could cause this ?
     
  42. GurhanH

    GurhanH

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

    Looks like the player settings are not correct. GPU Instancer requires OpenGL ES 3.1 or Vulkan for Android platforms. Please read the instructions at this page: https://www.gurbu.com/gpuinstancer/tutorials/androidbuildsettings

    Please inform us if there are still issues after you change the player settings and disable the emulation.
     
  43. potatojin

    potatojin

    Joined:
    Apr 11, 2012
    Posts:
    23
    First off, thanks for the amazing work on this asset. It's well designed, the code is easy to follow, and it's given me huge performance gains.

    One feature request, without knowing how difficult it might be:

    My game features a world that's completely procedurally generated, built from small mesh tiles that I stitch together. GPU Instancer has done an incredible job with this, and the included occlusion culling is incredible. However, whenever I pause the game in the Unity Editor, everything disappears. How hard would it be to get GPU Instancer to continue to render instanced geometry while the editor is paused?
     
    GurhanH likes this.
  44. GurhanH

    GurhanH

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

    Thank you for your kind words. Happy to hear that you like it.

    It requires to handle some editor events and switch the camera to Scene View and call the update methods when the game is paused. Then rollback when unpaused. We made something similar for the Detail Manager to simulate terrain detail rendering while in edit mode. We will look into this and add it in a future update.

    For now, you can disable the GPUI Manager when you pause the editor to enable default renderers. We designed the managers so that they can be enabled/disabled at runtime. But this won't be possible if you are using some of our low level API methods that manages the data directly in GPU.
     
  45. potatojin

    potatojin

    Joined:
    Apr 11, 2012
    Posts:
    23
    Thanks, I'll take a look, but I have a bad feeling I am using some of the low level API stuff, in order to build my procedural environment. I'll take a look at the Detail Manager stuff to see if I can pick up any hints.
     
    Last edited: Oct 31, 2018
  46. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Any chance to get an APK for mobile to walk around the terrain area with all the foliage rendering?

    Also can the alpha for the foliage have a softer alpha and not use the alpha cutout shader so it gets away from the harsher cutout alpha look and feel as well. So my question is can the shader that is used for vegetation be modified to have a softer alpha and still have the gpu system work correctly.
     
    hungrybelome likes this.
  47. LouskRad

    LouskRad

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

    We are working on various builds to showcase the detail and tree instancing features, and we will include a mobile build as well among these. We will be uploading these builds in the (not too distant) future.

    As for foliage shaders, GPUI offers the freedom to use any custom shader for rendering detail prototypes. The included foliage shader uses alpha cutout, but If you'd like to keep using it, you can also modify it according to your needs (It is written with Amplify Shader Editor, so if you have it you can modify it as a node network as well).
     
    hungrybelome likes this.
  48. ryanflees

    ryanflees

    Joined:
    Nov 15, 2014
    Posts:
    59
    Hi mighty developer.
    I have a few requests that I think you could take a look at :D

    1, GPUI automatically creates a new shader from my old shaders but I would like it to give me an option to use my original shader. And I'll add the required includes to my shader by myself.
    2, GPUInstancerPrefabManager can generate billboards at the start of runtime. But I'd prefer them to be saved on disk and I'll put it in the lod group as I could gain more control over the textures, materials and meshes.
    3, Billboard material's color appear a little bit dark at a far distance, darker than my original material. So I think you could give billboard shader a variable to adjust the brightness of color.
    4, GPUInstancerPrefabManager generate runtime data at runtime, but I think some of it could be serialized statically, and old GameObjects can be deleted to free more space (100k of game objects can make the scene file over 250M). Maybe this option could be provided.

    Just suggestions , I've already done 1,2,3 with my own modification, but I'll have to make them again with next updates. And can you tell us about the road map of your future features? :rolleyes:

    (Besides, the occlusion culling with compute shader is awesome :))
     
    Last edited: Nov 1, 2018
  49. potatojin

    potatojin

    Joined:
    Apr 11, 2012
    Posts:
    23
    Quick question about the occlusion/frustum culling:

    I've noticed that when doing very quick camera moves, like a fast 180, the culling seems to lag by about a frame before the culled items are rendered. Is there any way to force an update if I know I've done a fast camera move?

    Edited with a little more info:

    This happens in particular if making a camera "cut" with the Cinemachine package. I tried calling
    GPUInstancerManager.UpdateBuffers()
    when Cinemachine fires its CameraCut event, but I still see a frame of unrendered geometry.
     
    Last edited: Nov 1, 2018
  50. GurhanH

    GurhanH

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

    GPUI's automatic shader conversion checks your original shader for "GPUInstancerInclude.cginc" text. And if it finds the text, it does not generate a copy of the shader. So if you write the include directives yourself in your shader before adding them to the GPUI manager, it will not create a copy. But if you are adding the include directives in an external file, then all you need to do is to add a comment to your original shader that has "GPUInstancerInclude.cginc" text in it.
    We will improve the shader conversion to find include directives in external files in the future.

    Generated textures are saved on the disk, you can find them under GPUInstancer/PrototypeData/Billboard/Textures. We do not save the mesh and the material on the disk to not to clutter the system with unnecessary files. If you need to access the billboard mesh-material info, you can access them under GPUInstancerPrototype.billboard. If you generate your own mesh and material from this and add it to an LOD group you can disable the billboard generator in the manager. You can see an example code under GPUInstancerUtility.ShowBillboardQuad.

    Please keep in mind that GPUI's billboard generator is in beta and it's still being improved (we fixed a lot of the lighting issues in 0.9.2 update). Also the main purpose of it is to generate billboards for terrain trees which use SpeeTree, TreeCreator or Soft Occlusion shader. Using it for objects with other shaders might cause unexpected billboards.

    We are planing to add some customization options to billboards in the future where you can add custom meshes and materials or write your own billboard generator.

    If what you mean is to serialize the GameObject info in an external file and generate the scene from there on initialization, you can implement this and register the objects using our API at runtime. But then you will not be able to see and modify these objects in the editor mode. We are not planing to implement this into our core system since everyone has a different workflow.

    You can implement all of these changes without any modifications in the core system as I explained above. Then you won't need to worry about making updates.

    We are preparing a road-map page which will be published on our website.

    Happy to hear that you like it :) We will also add some other compute shaders in the near future that will make very fast runtime modifications.
     
    ryanflees likes this.