Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

[RELEASED] GPU Instancer

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

  1. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    432
    hi
    using U 5.6.6
    getting this error:

    Shader error in 'GPUInstancer/Standard': 'FragmentSetup': cannot convert from 'half4[3]' to 'float4[3]' at Assets/GPUInstancer/Shaders/Include/GPUIStandardInclude.cginc(153) (on d3d11)
    Compiling Vertex program with UNITY_HDR_ON _ALPHATEST_ON _SPECULARHIGHLIGHTS_OFF
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME

    any idea how to fix this?
     
  2. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    536
    Hi guys, we just purchased this awesome asset, we have been looking for your Discord channel but we can't find it, do you have one?
    Thanks!
     
  3. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    536
    Hi guys, I'm quite new into this.
    I set up the prefab manager and set the prefabs that are casting shadows following the manual. But in game I still see the shadow casters being rendered no matter where I set the camera.
    I've read in the thread some stuff about the shadow renderers and the shaders but I didn't understand too much what was about.
    Could you please guide me a little bit on this?

    PS: the Console is showing the error Target Graphics API does not support Compute Shaders.
    I set the Graphics emulation to "No emulation" but still shows the error. (Im on MacOSX)
    I don't know if this might be related to the problem


    UPDATE: After solving the problem of the Target Graphics API changing the API from the Build Settings now I find another problem.
    After adding the prefabs to the GPU Instancer and run it, I find the occlusion is working but just for the decoration tiles, seems the shader for the decoration tiles works with the occlusion but not the others.
    Why is this? how can I make the shaders I'm using work here?
    Thanks in advance

    UPDATE: I just realized a few new shaders has appeared in the project with the same name but with the prefix _GPUI, I tried to use the one finished as _GPUI instead of the one I'm using but still is not being rendered. Any suggestions?

    UPDATE: Finnally I changed all the shaders and still some tiles are not being rendered but I guess this is due to some problem with the prefabs because always are the same ones the ones not being rendered. One last thing that is worrying me is my FPS are extremely low, I saved so much rendering 1/10 triangles and shadow casters but my FPS and ms are 15 or 16, disabling the GPUinstancer FPS go to 260. Any ideas of why this is happening?? its so strange I leave a screenshot.



    Thanks in advance
     

    Attached Files:

    Last edited: Jun 20, 2019
  4. Ameng_c

    Ameng_c

    Joined:
    Apr 25, 2019
    Posts:
    7
    Hi, I'm here again.There's a problem with my custom shader. Shadows of objects can pass through them.
    Code (CSharp):
    1. Shader "Custom/diffuse" {
    2. Properties {
    3.         _Color ("Color", Color) = (1,1,1,1)
    4.     }
    5.     SubShader {
    6.         Tags {
    7.             "RenderType"="Opaque"
    8.         }
    9.         Pass {
    10.             Name "FORWARD"
    11.             Tags {
    12.                 "LightMode"="ForwardBase"
    13.             }
    14.          
    15.          
    16.             CGPROGRAM
    17.             #include "UnityCG.cginc"
    18.             #include "./../../../Shaders/Include/GPUInstancerInclude.cginc"
    19.             #pragma instancing_options procedural:setupGPUI
    20.             #pragma multi_compile_instancing
    21.             #pragma vertex vert
    22.             #pragma fragment frag
    23.             #define UNITY_PASS_FORWARDBASE
    24.             #include "AutoLight.cginc"
    25.             #pragma multi_compile_fwdbase_fullshadows
    26.             #pragma multi_compile_fog
    27.             #pragma only_renderers d3d9 d3d11 glcore gles
    28.             #pragma target 3.0
    29.             uniform float4 _LightColor0;
    30.             uniform float4 _Color;
    31.             #if SHADER_API_D3D11
    32.             #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    33.             StructuredBuffer<float4> colorBuffer;
    34.             #endif
    35.             #endif
    36.  
    37.             struct VertexInput {
    38.                 float4 vertex : POSITION;
    39.                 float3 normal : NORMAL;
    40.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    41.             };
    42.             struct VertexOutput {
    43.                 float4 pos : SV_POSITION;
    44.                 float4 posWorld : TEXCOORD0;
    45.                 float3 normalDir : TEXCOORD1;
    46.                 LIGHTING_COORDS(2,3)
    47.                 UNITY_FOG_COORDS(4)
    48.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    49.             };
    50.             VertexOutput vert (VertexInput v) {
    51.                 VertexOutput o = (VertexOutput)0;
    52.                 UNITY_SETUP_INSTANCE_ID(v);
    53.                 UNITY_TRANSFER_INSTANCE_ID(v, o);
    54.                 o.normalDir = UnityObjectToWorldNormal(v.normal);
    55.                 o.posWorld = mul(unity_ObjectToWorld, v.vertex);
    56.                 float3 lightColor = _LightColor0.rgb;
    57.                 o.pos = UnityObjectToClipPos( v.vertex );
    58.                 UNITY_TRANSFER_FOG(o,o.pos);
    59.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
    60.                 return o;
    61.             }
    62.             float4 frag(VertexOutput i) : COLOR {
    63.                 UNITY_SETUP_INSTANCE_ID(i);
    64.                 float4 col = _Color;
    65.                 #if SHADER_API_D3D11
    66.                 #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    67.                     uint index = gpuiTransformationMatrix[unity_InstanceID];
    68.                 col = colorBuffer[index];
    69.                 #endif
    70.                 #endif
    71.                 i.normalDir = normalize(i.normalDir);
    72.                 float3 normalDirection = i.normalDir;
    73.                 float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
    74.                 float3 lightColor = _LightColor0.rgb;
    75. ////// Lighting:
    76.                 float attenuation = LIGHT_ATTENUATION(i);
    77.                 float3 attenColor = attenuation * _LightColor0.xyz;
    78. /////// Diffuse:
    79.                 float NdotL = max(0.0,dot( normalDirection, lightDirection ));
    80.                 float3 directDiffuse = max( 0.0, NdotL) * attenColor;
    81.                 float3 indirectDiffuse = float3(0,0,0);
    82.                 indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light
    83.                 float3 diffuseColor = saturate(col).rgb;
    84.                 //float3 diffuseColor = _Color.rgb;
    85.                 float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
    86. /// Final Color:
    87.                 float3 finalColor = diffuse;
    88.                 fixed4 finalRGBA = fixed4(finalColor,1);
    89.                 UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
    90.                 return finalRGBA;
    91.             }
    92.             ENDCG
    93.         }
    94.         Pass {
    95.             Name "FORWARD_DELTA"
    96.             Tags {
    97.                 "LightMode"="ForwardAdd"
    98.             }
    99.             Blend One One
    100.          
    101.          
    102.             CGPROGRAM
    103.             #include "UnityCG.cginc"
    104.             #include "./../../../Shaders/Include/GPUInstancerInclude.cginc"
    105.             #pragma instancing_options procedural:setupGPUI
    106.             #pragma multi_compile_instancing
    107.             #pragma vertex vert
    108.             #pragma fragment frag
    109.             #define UNITY_PASS_FORWARDADD
    110.             #include "AutoLight.cginc"
    111.             #pragma multi_compile_fwdadd_fullshadows
    112.             #pragma multi_compile_fog
    113.             #pragma only_renderers d3d9 d3d11 glcore gles
    114.             #pragma target 3.0
    115.             uniform float4 _LightColor0;
    116.             uniform float4 _Color;
    117.             #if SHADER_API_D3D11
    118.             #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    119.             StructuredBuffer<float4> colorBuffer;
    120.             #endif
    121.             #endif
    122.  
    123.             struct VertexInput {
    124.                 float4 vertex : POSITION;
    125.                 float3 normal : NORMAL;
    126.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    127.             };
    128.             struct VertexOutput {
    129.                 float4 pos : SV_POSITION;
    130.                 float4 posWorld : TEXCOORD0;
    131.                 float3 normalDir : TEXCOORD1;
    132.                 LIGHTING_COORDS(2,3)
    133.                 UNITY_FOG_COORDS(4)
    134.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    135.             };
    136.             VertexOutput vert (VertexInput v) {
    137.                 VertexOutput o = (VertexOutput)0;
    138.                 UNITY_SETUP_INSTANCE_ID(v);
    139.                 UNITY_TRANSFER_INSTANCE_ID(v, o);
    140.                 o.normalDir = UnityObjectToWorldNormal(v.normal);
    141.                 o.posWorld = mul(unity_ObjectToWorld, v.vertex);
    142.                 float3 lightColor = _LightColor0.rgb;
    143.                 o.pos = UnityObjectToClipPos( v.vertex );
    144.                 UNITY_TRANSFER_FOG(o,o.pos);
    145.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
    146.                 return o;
    147.             }
    148.             float4 frag(VertexOutput i) : COLOR {
    149.                 UNITY_SETUP_INSTANCE_ID(i);
    150.                 float4 col = _Color;
    151.                 #if SHADER_API_D3D11
    152.                 #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    153.                     uint index = gpuiTransformationMatrix[unity_InstanceID];
    154.                 col = colorBuffer[index];
    155.                 #endif
    156.                 #endif
    157.                 i.normalDir = normalize(i.normalDir);
    158.                 float3 normalDirection = i.normalDir;
    159.                 float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
    160.                 float3 lightColor = _LightColor0.rgb;
    161. ////// Lighting:
    162.                 float attenuation = LIGHT_ATTENUATION(i);
    163.                 float3 attenColor = attenuation * _LightColor0.xyz;
    164. /////// Diffuse:
    165.                 float NdotL = max(0.0,dot( normalDirection, lightDirection ));
    166.                 float3 directDiffuse = max( 0.0, NdotL) * attenColor;
    167.                 float3 diffuseColor = saturate(col).rgb;
    168.                 float3 diffuse = directDiffuse * diffuseColor;
    169. /// Final Color:
    170.                 float3 finalColor = diffuse;
    171.                 fixed4 finalRGBA = fixed4(finalColor * 1,0);
    172.                 UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
    173.                 return finalRGBA;
    174.             }
    175.             ENDCG
    176.         }
    177.     }
    178.     FallBack "Diffuse"
    179. }
     
  5. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    536
    Scene Prefab Importer is not showing on Unity 2018.3.14 for MacOSX
     
  6. BenWilles

    BenWilles

    Joined:
    Mar 9, 2018
    Posts:
    41
    screenshot_1417.png screenshot_1418.png

    Hi Guys, just tested GPU Instancer and the result is vice versa as I hoped. In fact I got down from almost solid 60FPS to 17 when enabling GPU Instancer. Game/Scene/Device is exactly the same, only difference is that GPUI Prefab Manager is active/inactive. How can this be?
     
  7. BenWilles

    BenWilles

    Joined:
    Mar 9, 2018
    Posts:
    41
    screenshot_1421.png screenshot_1422.png

    Besides the bad performance, GPUI is like randomly hiding a huge number of Items for no reason. See especially western part the map.
     
  8. BenWilles

    BenWilles

    Joined:
    Mar 9, 2018
    Posts:
    41
    screenshot_1426.png

    That's Bosslevel of bad magic for me :) As you can see everything in Hierarchy is disabled. How can there still be trees/objects? They are only there when GPUI is actived oc.
    Truth be told, for a out of box solution this gives me a lot of headache. Please help!
     
  9. BenWilles

    BenWilles

    Joined:
    Mar 9, 2018
    Posts:
    41
    screenshot_1428.jpg screenshot_1430.jpg

    Hi again, tried with demo scene on a blank project now and its same there. Framerate drops heavily when GPUI is active
     
  10. RomBinDaHouse

    RomBinDaHouse

    Joined:
    Mar 18, 2015
    Posts:
    13

    \Assets\GPUInstancer\Shaders\Include\GPUIStandardInclude.cginc
    line 53

    try this one
    #if UNITY_VERSION > 201714 || UNITY_VERSION == 201730 || UNITY_VERSION == 201731 || UNITY_VERSION == 201720 || UNITY_VERSION == 201721 || UNITY_VERSION == 201722
     
    zelmund likes this.
  11. RomBinDaHouse

    RomBinDaHouse

    Joined:
    Mar 18, 2015
    Posts:
    13
    \Assets\GPUInstancer\Resources\Compute\Include\Camera.compute

    you can try this simple trick

    Code (CSharp):
    1.  
    2.     // Test for distance culling
    3.     dist = abs(distance(gpuiInstanceData[id.x]._14_24_34, camPos));
    4.     if (dist > maxDistance || dist < minDistance)
    5.         return false;
    6.  
    7.     // Cull odd objects farther than half the maxDistance, leave other 50% of them
    8.     if (   (dist >  0.5 * maxDistance)   &&   (id.x % 2 > 0)  )
    9.         return false;
    10.  
    You can set the pattern in a similar way. Of course, this will cause a popping of culled grass.
    So it needs some additional work to achieve a smooth transition before culling
     
    Last edited: Jun 24, 2019
    LouskRad likes this.
  12. horeaper

    horeaper

    Joined:
    Oct 30, 2013
    Posts:
    33
    Quick question: does the tree/detail feature works with Vegetation Studio/Vegetation Studio Pro ??
    (Maybe this has been asked before but reading through all 28 pages of reply is....)
     
  13. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    This might be caused by adding and removing LWRP packages to your project. Can you try creating a new project with the desired pipeline (directly from Unity Hub) and see if you still get shader errors like this?


    It would be reasonable, as long as you use billboards on your SpeedTrees.


    Yes, the reason for this has been the lack of CommandBuffers in SRP. We are working on an alternative solution, and we will keep you updated.
     
  14. LouskRad

    LouskRad

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

    The solution provided by @RomBinDaHouse would indeed work for the U 5.6.6 version. We will provide a general fix for this in the next update.
     
  15. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    @pistoleta @benjaminthorn

    Hi there,

    it looks like you are facing multiple issues:

    - About the trees still showing even when scene objects are disabled: GPUI Prefab Manager registers the instances in the scene internally and renders them from this internal reference at runtime. If you add or remove prefab instances to the scene after creating your prototypes, you need to use the Register Instances in Scene button to register these instance changes. Please take a look at the Prefab Manager video tutorial for more information.

    - About performance issues: there might be a few reasons why you face this issue. Firstly, there have been multiple Unity bugs related to GPU usage in metal in early 2019.1 versions. Can you please try the included mobile demo scene in a new project using the latest 2019.1 version (currently 2019.1.7f1) and with only GPUI added to this project? Please test this scene and making note of the results with GPUI on and off. And also with your own project files added to this new project and not. Please send the results you get to us with the technical specs of the devices you use so we can investigate based on these results.
     
  16. LouskRad

    LouskRad

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

    it looks like the problem is caused by the fallback line at the end. Your shader does not have a shadowcaster pass and Unity uses this pass from the Fallback shader you define in the end - and that shader (Diffuse) is not GPUI compatible.

    You can solve this issue by changing the line:

    FallBack "Diffuse"

    into:

    FallBack "Hidden/GPUInstancer/ShadowsOnly"

    Or:

    FallBack "GPUInstancer/Standard"

    The first one would be faster, but the second one would support alpha testing as well.
     
  17. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    No; since Vegetation Studio uses its own rendering system, it is not possible for GPUI and VS to work on the same objects. However, if you wish to use VS and GPUI together, you can still use GPUI for prefabs that you do not define in VS.

    We usually put the answers for the commonly asked questions into the F.A.Q wiki. You can check this page first instead of going through this forum.
     
    horeaper likes this.
  18. BenWilles

    BenWilles

    Joined:
    Mar 9, 2018
    Posts:
    41
    Our Project is made in 2018.3, used 2019.1 only for testing the demo in a clean environment but the problem is the same. Could it be related to that we run unity on OSX?
     
  19. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    We have users that use GPUI on OSX without problems so I don't think that is the issue. You can either do the test I mentioned above with 2018.3 or the newest 2019.1.x and send us the results, and we can investigate.
     
  20. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    536
    We also tried the built demo available for download for MacOS and was running at 10FPS, so I'm guessing is not just a Unity issue?
     
  21. GurhanH

    GurhanH

    Joined:
    Apr 24, 2017
    Posts:
    481
    What is the tech specs of the Mac you are testing with? It might be because of this:

     
  22. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    536
    MacBook Pro 2018 v 10.14.5
    2.2ghz i7
    16gb 2400 Mhz ddr4
    Radeon Pro 555x 4gb
    Intel UHD 610 1536MB

    PS: downloading last unity version at the moment to test on it
     
  23. miklelottesen

    miklelottesen

    Joined:
    Mar 7, 2015
    Posts:
    19
    I created a new non-srp Unity project (3D with extra), added GPUI, added a SpeedTree to the manager, imported the extra SPDTree8 shader and built the project. I got the exact same errors.

    Update: I made the above-mentioned build attempt in Unity 2019.2.0b5. Just now, I created the exact same project in 2019.1.4f1 and was able to build successfully. I really wish I could go back, but anything below 2019.2 has a bug that makes the editor practically unusable if the project contains a prefab with a SpeedTree. I'll try to upgrade to 2019.2.0b6 and see if it somehow fixes it.

    Update: After updating to 2019.2.0b6, I got the same errors. However, I was able to make it build after adding the following modifications to GPUInstancerInclude.cginc at line 36:

    Code (CSharp):
    1. #ifndef LOD_FADE_CROSSFADE
    2.     uniform sampler2D _DitherMaskLOD2D;
    3. #elif UNITY_VERSION >= 201920 // ADDED BY ME
    4.     uniform sampler2D _DitherMaskLOD2D; // ADDED BY ME
    5. #endif
    ..basically forcing _DitherMaskLOD2D to be defined, if using the version of Unity that I'm using - a thing that confuses me is why it's only defined if LOD_FADE_CROSSFADE is defined, but used on line 56 (where the error happened) regardless of wether it's defined or not?

    Well, I use billboards on all the trees, so that shouldn't be an issue. The weird part is that when I instantiate everything normally (as GPUInstancerPrefabs, but not no-GameObject instances), the FPS count is almost the same as if I had no trees at all (~100 FPS) while if I instantiate some of the trees as no-GameObject instances (I made a script that does this automatically for SpeedTrees without colliders, and also automatically increases/decreases the buffer size for each prototype as needed) the FPS suffers drastically (~35 FPS). I thought no-GameObject instances would be faster than, or at least equally as fast as a normal prefab instance?

    Update: So, it turns out that my script forgot to clear its list of Matrix4x4's to be updated, resulting in every buffer for every no-GameObject instance being updated every frame!!!

    Oh, and I know that 100 FPS isn't a good baseline to begin with, but that's because I need to find a better way to handle my terrain tiles. I'm assuming that GPU Instancer won't be of much help in that regard, since the tiles have different geometry (heightmaps) and uses a custom shader (MicroSplat)?

    Update: I'm getting an error when I play a build:

    Code (CSharp):
    1. Uploading Crash Report
    2. ArgumentNullException: Value cannot be null.
    3. Parameter name: shader
    4.   at (wrapper managed-to-native) UnityEngine.Material.CreateWithShader(UnityEngine.Material,UnityEngine.Shader)
    5.   at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00009] in C:\buildslave\unity\build\Runtime\Export\Shaders\Shader.bindings.cs:118
    6.   at GPUInstancer.GPUInstancerManager.AddTreeProxy (GPUInstancer.GPUInstancerPrototype treePrototype, GPUInstancer.GPUInstancerRuntimeData runtimeData) [0x00198] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\Core\Contract\GPUInstancerManager.cs:694
    7.   at GPUInstancer.GPUInstancerPrefabManager.InitializeRuntimeDataForPrefabPrototype (GPUInstancer.GPUInstancerPrefabPrototype p, System.Int32 additionalBufferSize) [0x000e8] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\GPUInstancerPrefabManager.cs:257
    8.   at GPUInstancer.GPUInstancerPrefabManager.InitializeRuntimeDataRegisteredPrefabs (System.Int32 additionalBufferSize) [0x0005c] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\GPUInstancerPrefabManager.cs:227
    9.   at GPUInstancer.GPUInstancerPrefabManager.InitializeRuntimeDataAndBuffers (System.Boolean forceNew) [0x001a6] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\GPUInstancerPrefabManager.cs:183
    10.   at GPUInstancer.GPUInstancerAPI.InitializeGPUInstancer (GPUInstancer.GPUInstancerManager manager, System.Boolean forceNew) [0x00001] in C:\UnityProjects\Sandbox\Assets\GPUInstancer\Scripts\API\GPUInstancerAPI.cs:23
    11.   at SpawningManager.Awake () [0x0003f] in C:\UnityProjects\Sandbox\Assets\Scripts\Spawning\SpawningManager.cs:60
    12. (Filename: C:/buildslave/unity/build/Runtime/Export/Shaders/Shader.bindings.cs Line: 118)
    ..basically caused by GPUI being unable to bind the GPUInstancer/Nature/SPDTree8 shader - it's as if the shader doesn't get included in the build at all (similar to the issues I had in the editor, before figuring out that I had to import the SpeedTree8 package), and as a result all trees seem to be instantiated as normal Unity prefabs, and the no-GameObject instances don't appear at all.


    Turns out that the error was caused by the TreeProxy shader. Adding it to always included shaders in project settings fixed the issue.
     
    Last edited: Jun 23, 2019
  24. Ameng_c

    Ameng_c

    Joined:
    Apr 25, 2019
    Posts:
    7
    It's amazing!Thank you very much.
     
    LouskRad likes this.
  25. farzaan090

    farzaan090

    Joined:
    Jul 23, 2018
    Posts:
    15
    Sent, thanks.
     
    LouskRad likes this.
  26. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    432
    works now
    thanks! :)
     
    LouskRad likes this.
  27. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    536
    We got it working
    First of all, thanks for your support.

    After upgrading Unity to 2019.1.8f1 we found out the GPUintancer demos and our project were running much better.
    But whenever we try to run on device the FPS are still the same. The device we are using is a high end one, an iPhone XS Max.
    We run our project on device with the GPUInstancer OFF and we get constant 60fps but with the GPUInstancer drops drastically to 15FPS.

    Another problem we are facing is random prefabs are not being rendered by the GPU Instancer, this is quite strange because right now we are using all the same with the same shader... so identical prefabs (regitstered by the GUI prefab manager) are being renderer and others are not. This happens both in laptop and device.

    Is there something we are missing? We are kind of lost and don't know what else to try to make the GPU Instancer work.

    Thanks again for your support.
     
  28. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,784
    I ended up going with the no game object approach and went from about 10 fps using the terrainTreeManagers on 8 terrains, to 50+ fps on those same 8 terrains. Pretty amazing! And when testing in a standalone build it's consistently over 60fps. (I have well over 500k tree instances :eek:)

    I have 20+ tree prefabs that I am using across my terrains, and for each tree prefab I am calculating a matrix4x4 array with tree positions and calling GPUInstancerAPI.InitializeWithMatrix4x4Array(). In the included demo this was the approach for the no game object workflow, however there was only one prefab in that case and I was wondering if there was a more efficient way to add multiple prefabs to the prefab manager...? Or is this the recommended approach? I'm just looking to squeeze as much performance out of this as possible. :D
     
    RomBinDaHouse likes this.
  29. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,784
    I also was encountering similar issues when trying to compile a build. In my case the error was due to both the Hidden/GPUInstancer/Nature/TreeProxy shader and GPUInstancer/Nature/SPDTree shaders not being included in the build. Registering a reference to them directly in the scene solved my problem, similar to your approach of using project settings, however this is an issue that should be looked at by the developer as I'm sure less experienced Unity users might have real trouble with this.
     
  30. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904

    Hi there,

    It is indeed the case that the Mac you are testing GPUI on is has an integrated GPU (as opposed to a dedicated GPU hardware). This would result in not getting the best out of GPUI since it relies on the GPU for its effect.

    However, the performance problem you get on the build should not be related to this. Did you try building the included mobile Asteroid demo to your device and see if you still have a performance issue?

    If you do, it could be because of a compute shader issue on the target platform (iPhone XS Max). Some prefabs not being rendered would also suggest this if this only happens in the build. We currently don't have access to iOS platforms, but we can try helping you if you debug the build for errors. Please send us any debug logs that could help us investigate this issue.
     
  31. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Thanks for reporting this issue.

    When you first add a prefab to a manager, GPUI adds the necessary shaders for the build to a Shader Variant Collection. This collection can be found under GPUInstancer/Resources/Settings/GPUIShaderVariantCollection and it contains references to shader variants that are used in GPUI Managers. This collection is intended to add the GPUI shader variants automatically to your builds.

    We will check the latest Unity versions (especially the bits about SpeedTree shaders and using a no GO workflow) again and make the necessary fixes/additions to the code for the next update if any are required.
     
  32. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Those are indeed good numbers :)

    Currently yes, that would be the recommended approach as far as draw calls and initialization are concerned. You could squeeze a bit more performance by playing with the prototype settings (e.g. LOD shadows, Frustum Offset, etc.) and also the use selected camera only setting on the manager (if you have any additional cameras in the scene).
     
    chingwa likes this.
  33. BenWilles

    BenWilles

    Joined:
    Mar 9, 2018
    Posts:
    41

    Hey, the Asteroids Demo works well on device.

    The missing Prefabs Problem is both in Editor and on Device. If a prefab should be there like 3000 times its only there 2000 times. So simply number of instances is reduced but in general its instantiated. The Shader is the unity mobile diffuse (a downloaded copy)

     
  34. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi Benjamin,
    if the Asteroids demo works on the mobile platform, that means it is most likely that the issue originates in your scene.

    Here are a few more questions to determine the potential cause for the missing prefabs issue:

    - Are you using multiple cameras? If so, it could be that GPUI using the wrong camera for culling operations. You could define the camera you intend to use with the manager and enable the use selected camera only option on the manager

    - There might be a shader issue, and if so it could also be causing issues with the occlusion culling feature. Can you try disabling occlusion culling and see if it changes anything?

    - Can you also make sure all the instances in the scene are registered correctly? The Registered Prefabs section should show the exact amount of instances in the scene. For example if there were 500 ARISphere instances:

    upload_2019-6-26_13-3-19.png

    - Can you also add the GPUInstancerGUIInfo component to a GO in your scene and enable the Show Rendered Amount checkbox. This will read data back from the GPU and show the actual number of instances that are being rendered overlaying on screen.
     
  35. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    500
    Hi there

    I think there's a bug in the prototype height settings of the detail manager. My detail meshes were all the same size and says here: https://wiki.gurbu.com/index.php?title=GPU_Instancer:GettingStarted#Detail_Properties that x is min, y is max etc. and that's how the prototypes are imported from the terrain. However the wiki image shows it switched, x is 1.4 and y is 1.3.

    So i switched the numbers and now my detail meshes are scaled correctly.

    Best regards
     
  36. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Thank you for reporting this. We will fix it in the next update.
     
    iddqd likes this.
  37. terapong

    terapong

    Joined:
    Mar 5, 2013
    Posts:
    17
    Automatic 2D Billboard generation system can support HDRP?
     
  38. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    I haven't spent too much time yet looking into this, but figure I should ask anyways. I have a simple custom LOD system for finer control over enabling/disabling meshes based on distance. My prefabs contain the different LOD meshes in children objects (same as Unity's LOD groups). When I plug these prefabs in as prototypes and toggle their visibility, the GPU instancer overrides this and displays all the LOD meshes. What's a recommended way to have GPU Instancer update the visibility?
     
  39. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    500
    I'm also working with infinite multi tile terrains, so I've been playing around with using the trees in the prefab manager and cannot see any issue with this. Are there any disadvantages over using the tree manager that I'm missing?
    Thank you!
     
  40. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,784
    I don't want to speak for @LouskRad but the only advantage I see in the tree manager is one of convenience. But if you're able to code and translate your terrain tree positions into the prefab manager then there is no reason I can see to use terrain TreeManagers at all.
     
  41. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    No. The generated billboards do not currently work in SRP, but you can use custom HDRP supported billboards instead of the generated one (e.g Amplify Impostors).
     
  42. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    If you use the Unity LOD Group component on the parent object, GPUI would automatically manage the LOD levels for your prototypes. However, if you wish to enable and disable the child transform under a parent game object without an LOD group, you need to define each child as a separate prototype, and the Auto Add/Remove Instances at Runtime feature would detect the active status changes and handle them for the instances.
     
    pixlweaver likes this.
  43. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Exactly. The only advantage of the Tree Manager is that of convenience. Actually, when using a multi-terrain setup, using the Prefab Manager would be more optimized since the draw calls would not be terrain based.
     
    iddqd likes this.
  44. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    500
    Perfect, thanks again for this amazing tool and support!
     
    LouskRad likes this.
  45. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    Thanks!
     
    LouskRad likes this.
  46. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Does it support Speedtree 8 now?
     
  47. Krealit-OOO

    Krealit-OOO

    Joined:
    Jun 13, 2013
    Posts:
    6
    Hello, man, your asset is absolutely great, but tell me please, why grass colors on the terrain is so bright, like you add a white color, can I do something with it?
     
  48. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Yes, GPUI will auto-detect if you add a SpeedTree8 model to a manager and extract the relevant SpeedTree8 shader from the included extra package.
     
  49. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi there, and thanks.
    Can you give a little more information on how you mean? Screenshots would help - please provide one for how your grass looks and one of your prototype settings. Also, which color mode (linear or gamma) are you seeing this brightness. You can mail the screenshots to us if you wish.
     
  50. Krealit-OOO

    Krealit-OOO

    Joined:
    Jun 13, 2013
    Posts:
    6
    Sure, take a look, in first picture you can see how it looks with the standart terrain visualisation, and on second, how it looks when gpui simulation was started. Color space is linear and all prototipes was sinchronised.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      3.5 MB
      Views:
      547
    • 2.jpg
      2.jpg
      File size:
      3.6 MB
      Views:
      537