Search Unity

[RELEASED] Impostors - Runtime Optimization

Discussion in 'Assets and Asset Store' started by MUGIK, Oct 11, 2019.

?

What dependencies you are ok with using in your project?

  1. Unity 2019.4+

    77 vote(s)
    84.6%
  2. Jobs (+ Collection and Mathematics)

    78 vote(s)
    85.7%
  3. Burst (+ Mathematics)

    79 vote(s)
    86.8%
Multiple votes are allowed.
  1. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480

    roboto font bad cover 1950x1300.png
    1 before.png 3 final impostors.png 2 impostors highlight.png comparing plus inspector.png



    Please, read the description on the Asset Store page for a detailed overview.
    It's hard to maintain up-to-date descriptions both here and on the store page.

    Links:
    Documentation
    Tech stuff - I have no connection to this article, but it covers a big chunk of how Impostors work.
     
    Last edited: Jul 17, 2022
    tree_arb, JBR-games, LeFlown and 3 others like this.
  2. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
  3. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    LukeDawn, elpinguinofrio and Neviah like this.
  4. flyingaudio

    flyingaudio

    Joined:
    Dec 3, 2010
    Posts:
    98
    Does this version support full VR?
     
  5. flyingaudio

    flyingaudio

    Joined:
    Dec 3, 2010
    Posts:
    98
    If I buy your current version, will it include your new one for free?
     
  6. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    I didn't test it actually but might work. VR support is in plans but can't promise anything right now

    There will be an upgrade price, but for the first week after release upgrade will be free
     
  7. pokruchin

    pokruchin

    Joined:
    Apr 24, 2019
    Posts:
    38
    Hello! The asset looks amazing. I’m trying to figure out if I can use it for my project so I’d like to clarify a few questions:
    1. Will this asset increase memory usage on mobile platforms?
    2. Is it possible to unload gameobject’s mesh and texture from memory when the gameobject switches to impostor?

    In my game I have a city which I’d like to be seen even far away from it. So I think this asset is quite good for this purpose. But the main question for me is memory usage. Do you think I can use it for this case?

    Thanks
     
    HolyBlue likes this.
  8. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Hi!
    1. Yes, the system requires additional RenderTextures to store Impostors.
    2. It depends on what you are trying to achieve. If you know that your camera view angle will not change then yes. In another case, the system will need to update(re-render) impostors' textures whenever your camera moves.

    I had already tried to optimize city scene with another customer for mobile devices. We failed because of the way the camera moves in his game. It was a first-person free-flying camera and it was impossible to optimize with Impostors because it required to constantly update impostors' textures. To be true, I achieved a quite performance boost but with a trade-off that there was a noticeable difference between impostors and normal objects.

    The main requirement for Impostors to really improve performance is - camera must move slowly(or just not fast) relative to Impostors. So if you know your camera will not move fast, then it might work. At the end of the day, impostors are just one of the ways to hack hardware limitations, they can't replace the standard rendering.
     
    JBR-games and pokruchin like this.
  9. Zappyy

    Zappyy

    Joined:
    Jun 9, 2018
    Posts:
    40
    Looks very interesting. When do you plan to release this? :)
     
  10. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Hi. Sorry for the late reply. For some reason missed your message.

    I'm planning to release it before 1 of February.
     
    Last edited: Jan 15, 2021
    biscito and Zappyy like this.
  11. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Hi everyone.
    Happy to announce the upcoming release to the Asset Store!:)
    Currently working on setting up the store page.

    If you would like to try this before release, please reach me in DM.

    5.5m triangles, 6500 draw calls.
    upload_2021-2-3_17-32-54.png

    ~700k triangles, ~300 draw calls
    upload_2021-2-3_17-33-41.png
     
    AthrunVLokiz and hopeful like this.
  12. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    That was long two days...

    The package has just been submitted to the Asset Store for the review!

    Coming soon;)

    upload_2021-2-4_18-23-53.png
     
    AthrunVLokiz likes this.
  13. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    The Impostors will work with VR projects.

    Stereo-rendering is supported.

     
    AthrunVLokiz likes this.
  14. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Made a quick overview of the Impostors package and how it works.

    If you don't know what impostor is then this video will answer this question.

     
  15. m-orchestrate

    m-orchestrate

    Joined:
    Oct 10, 2019
    Posts:
    2
    Does it support animation system? I want to create thousands of zombies in vr(quest2)
     

    Attached Files:

  16. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Thanks for the question!
    No, Impostors are not meant to be used with animated objects.
     
  17. NikolaGR

    NikolaGR

    Joined:
    Jun 25, 2018
    Posts:
    2
    Hello, I have a question:

    Are there shader limitations? I need to know will it work with my own shaders made in Shader Graph.

    I'm using URP for a VR project.

    Thanks.
     
  18. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Hi
    Good question. Unfortunately, I don't know will it work, didn't test that yet.
    But there is a limitation: shader must write to Z-Buffer. Which means no transparent objects.

    Is there something special in your custom shader?
     
  19. NikolaGR

    NikolaGR

    Joined:
    Jun 25, 2018
    Posts:
    2
    Thank you for the reply. I don't think there is anything special in my shaders and I don't intend to use it with transparent objects, I just wanted to ask since I previously tried to use Amplify Impostors and wasted a lot of time because it was very constrained about shaders.
     
  20. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101

    Hi. Can you please create apk with same scene for test on mobile devices. Preferably with some benchmark-style movement.

    Also, can it work with skinned meshes ?

    upd. Is the update time only global or can it be made local?
     
    Last edited: Mar 10, 2021
  21. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Hi. Just tested Impostors with a custom shader made with Shader Graph. Nothing fancy, just vertex displacement:
    upload_2021-3-16_12-13-14.png

    It works fine(despite the look of corrupted objects). Green tinted object is an impostor:
    upload_2021-3-16_12-20-1.png

    I can't guarantee you that it will 100% work with your shader, but we can try:)
     
    AthrunVLokiz likes this.
  22. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Hi. It's a good idea, so here you have it:
    https://drive.google.com/file/d/1SneMKl0rV3GsjArAA9O7-Y3m8_vo00sq/view?usp=sharing

    It's not intended to be used with animated objects.

    I'm not sure I understood your question correctly. Each impostor updates independently when an update is needed.
     
    Hobodi likes this.
  23. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    The strange thing is when I use the left stick to move the FPS drops from 60 to 40, and this problem has appeared on several phones I have tried.

    upd. Thanks for the opportunity to profile with the developer build. There are suspicions that this is a URP problem that is absolutely impossible to use on mobile devices. Couldn't make a build with built-in graphical pipline?

    https://i.gyazo.com/887d39056bd398c628752e87fd17b217.png

    In the video, it was possible to set the update rate in the manager but not in a separate object. I was thinking about updating depending on the distance and speed of the camera. How difficult is it going to be?

    Also, all object in test are unique or using GPU instancing?
     
    Last edited: Mar 17, 2021
  24. wbn1993

    wbn1993

    Joined:
    Sep 15, 2020
    Posts:
    2
    Hi, I have trouble using imposter on some android devices and have not figured out why. The imposters work perfectly on PC and android phones using Quacomm CPU; however the imposters do not show up on android devices that use Mali CPU (I've tested on 3 phones).

    I used the frame debugger to check what is going on while rendering the imposter and found an error message when I click the Draw Mesh call to render the imposter saying
    "Failed setting triangles. Some indices are referencing out of bounds vertices. IndexCount: 384, VertexCount: 4"
    .

    I was trying to render one object with imposter so the DrawMesh call uses 4 vertices. The index count looks wrong to me because one imposter uses 6 indices. I guess 384 indices come from the max imposters count from my quality setting, which is 64 imposters and 6 * 64 = 384. Therefore I checked the code and added the following code in
    BufferedImpostorsChunkMesh
    's
    GetMesh()
    to submit less indices. I tried to added the following code to set index buffer after setting the vertex buffer.
    Code (CSharp):
    1. _mesh.SetIndexBufferParams(maxImpostorsCount * 6, IndexFormat.UInt32);
    2.  
    3. using (var indexBuffer = new NativeArray<int>(maxImpostorsCount * 6, Allocator.TempJob))
    4. {
    5.       var jobFillIndexBuffer = new JobFillIndexBuffer() {indexBuffer = indexBuffer};
    6.       jobFillIndexBuffer.Schedule(counter.Count* 6, 32).Complete();
    7.       _mesh.SetIndexBufferData(indexBuffer, 0, 0, counter.Count* 6, MeshUpdateFlags);
    8.  }
    Now, while rendering one imposter, the frame debugger shows 4 vertces and 6 indices, but the imposters still do not show up on the phones using Mali CPU.

    I am not very sure is this a hardware problem or I'm missing any settings.Is there any way I could fix this problem?
     

    Attached Files:

    Last edited: Mar 17, 2021
    Hobodi likes this.
  25. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    Never mind, I bought it. At first, something was going wrong and I couldn’t build on android, it seemed normal now.
    But a lot of questions come up in the course of work.
    For example, how do I add and remove objects while playing? This is needed for asynchronous scenes.
     
  26. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    That's expected behavior. When camera moves impostors require to update their textures.
    But in the build I sent a lot of things are wrong. I spent this day profiling android builds and got some big improvements.
    Here is a new build:
    https://drive.google.com/file/d/1vodc7JXSnH9qbWHx99dLoAgf0DsaS1Qg/view?usp=sharing

    What I've changed:
    1. Created a new project with a built-in pipeline.
    2. The most important change is that I dragged OpenGLES3 on top of Vulkan graphics API. I think Vulkan really doesn't like to change render targets... Need to investigate this deeper.
      upload_2021-3-17_17-28-30.png
    3. Second important change: set atlas resolution to 1024x1024 on the ImpostorableObjectsManager. On mobile GPUs changing render target is quite an expensive operation
      upload_2021-3-17_17-35-10.png
    4. Changed Standard shader to Mobile/Diffuse.
    5. Removed Procedural skybox which works terribly on mobile devices.
    6. Disabled v-sync from settings.
    7. Disabled both Multithreaded Rendering and Graphics Jobs
    8. Changed scripting backend to IL2CPP and API to .NET 4.x
    9. Disabled shadows for clear profiling image.

    Results:
    In the previous build there was only 1 impostor update per frame which led to terrible performance.

    In the new build you can select how many updates per frame you want using slider. On my smartphone, I got 60FPS with 20 updates per frame. Even for me, that number is shocking!
    upload_2021-3-17_17-40-35.png
     
    Hobodi likes this.
  27. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    You can control how often impostor will be updated on the object by changing settings on ImpostorLODGroup component:
    upload_2021-3-17_17-47-11.png

    For now each impostor that needs an update is getting a weight value which indicates how important this update is.
    The "importance" depends on object's screen size (similar to distance from camera) and time from the last impostor update. Then system grabs X most important impostors and updates their textures(where X is "MaxUpdatesPerFrame").

    Could you please clarify how you think to use the speed of the camera?


    Original objects don't use GPU Instancing.
    Impostors are combined in meshes so they don't need GPU Instancing.
     
    Hobodi likes this.
  28. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Are you sure it's a Mali CPU and not GPU? Because I can't find any information about Mali CPU devices.

    Yes, that's how it meant to work. Mesh buffer always contains a maximum vertex capacity to prevent memory allocations. This shouldn't be an issue.
    However, the error in console is strange. It's hard to track all these issues with different render pipelines:D

    For me, it looks like a hardware problem. I will try to find a device with Mali GPU
     
  29. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Just instantiate and destroy them:)
    You can look at ExampleSpawner.cs for a direct example.
    In that poorly written code, you will find only Instantiate() and Destroy() methods.

    Under the hood, impostor initialization/deinitialization goes in OnEnable/OnDisable in the ImpostorLODGroup component.
     
  30. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    This greatly reduces the FPS.

    And this, unfortunately, is a required standard, which greatly slows down the assembly.

    But in general, this is probably the silver bullet that I have been looking for all these years and it works very good. I also use this in conjunction with another asset that culling objects, which gives even more frames. I hope enabling/disabling rendering for objects does not affect the imposter update queue in any way?


    Asynchronous scenes are set up to add and remove new objects over time. It seems to me that it will be a high overhead, to reinstantiate the entire scene while slowly adding objects.
     
    Last edited: Mar 18, 2021
  31. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Today I've made additional performance tests on my device (Xiaomi Mi 9 Lite) with different project settings.
    upload_2021-3-18_14-25-59.png

    From my synthetic tests, these settings do nothing.
    Moreover, Graphics Jobs with Vulkan API freezes the app and requires device reboot. (With disabled impostors it doesn't freeze)

    Also, for some reason, Vulkan shows worse performance than OpenGLES3. I have no clue why...
    But with 10 updates per frame, it has a stable 60 FPS. For the scene with 3000 high poly objects it's a good result, I believe.
     
  32. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    I think so. All object settings and data are cached within OnEnable on ImpostorLODGroup. That also includes rendering commands for creating impostor texture. If you want to add/remove Renderer from the impostor texture than you need to change LODs using ImpostorLODGroup.SetLODsAndCache() method.

    I'm sorry, I don't understand your problem. What I can say is that enabling ImpostorLODGroup is a quite heavy operation, it does some caching and allocations. But it is cheap in comparison to instantiating gameObject.
     
  33. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    Perhaps because I use it for VR, or for some other reason, but these settings affect me. Here is a screenshot of the check on Samsung s7.
    On the left is a static state, on the right is camera movement and a drop in performance when redrawing imposters.





    In the second case, FPS drops dramatically with Graphic Jobs and Multithreaded Rendering disabled.
     
    Last edited: Mar 19, 2021
    MUGIK likes this.
  34. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Yep, that's the downside of using this technique. If camera moves fast and requires a lot of imposter updates, then performance will struggle. I can suggest you decreasing MaxUpdatesPerFrame.

    Do you have 2 cameras?
     
  35. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    In general, yes, but I am trying to fit into one for the possibility of larger-scale renderings.
    https://forum.unity.com/threads/graphics-blit-in-vr.1076780/

    In this particular case, yes, one camera for each eye.

    Is it possible to reduce the load when moving?
     
    Last edited: Mar 19, 2021
  36. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Yes!
    First of all, you don't need to set up separate ImpostorableObjectsManager for each VR eye. Impostors for each of them are identical, but every frame you do culling and other stuff two times, while you can do it only once.
    You can speed up system by 2x just by using only one ImpostorableObjectsManager. It requires a bit of coding to make it work this way.
    Code (CSharp):
    1. namespace Impostors.Managers
    2. {
    3.     public class ImpostorableObjectsManager : MonoBehaviour, IMemoryConsumer
    4.     {
    5.  
    6.         //...
    7.  
    8.         [SerializeField]
    9.         private Camera _mainCamera = null;
    10.  
    11.         // added
    12.         [SerializeField]
    13.         private Camera _secondEyeCamera = null;
    14.  
    15.         //...
    16.  
    17.         private void OnPreCullCallback(Camera cam)
    18.         {
    19.             //...
    20.  
    21.             // added
    22.             if (cam == _secondEyeCamera)
    23.             {
    24.                 Profiler.BeginSample("Draw Impostors for second eye");
    25.  
    26.                 for (int i = 0; i < _chunks.Count; i++)
    27.                 {
    28.                     ImpostorsChunk chunk = _chunks[i];
    29.                     if (chunk.IsEmpty == false)
    30.                     {
    31.                         Graphics.DrawMesh(chunk.GetMesh(), Vector3.zero, Quaternion.identity, chunk.GetMaterial(), 0, cam,
    32.                             0, _emptyPropertyBlock, castShadows: false, receiveShadows: false,
    33.                             useLightProbes: false);
    34.                     }
    35.                 }
    36.  
    37.                 Profiler.EndSample();
    38.             }
    39.             // end of added
    40.  
    41.             if (cam != _mainCamera)
    42.                 return;
    43.  
    44.             //...
    45.         }
    46.     }
    47. }
    If you have trouble implementing this, let me know.


    Also, you can decrease MaxUpdatesPerFrame, and try AtlasResolution _512x512 and _1024x1024.
    On tiled GPUs, a big atlas resolution can kill performance.
     
  37. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101

    I didn’t explain myself correctly, sorry. The camera is one, but makes two passes for each eye.
    Your code works once in a late update, as I understand it, so this technique will not help.
    The bad thing is that it wins FPS in static but loses in motion.

    Even worse, the FPS is even lower than without imposters. This can be seen in the test for 576 objects + 20 updates. FPS in motion falls more than without imposters at all.

    Here 3 test on samsung s7 with 5 updates and 512x512 texture

    static imposters

    movement with imposters

    without imposters



    It is also a strange picture that the number of draws increases slightly in motion , I do not quite understand why this is happening.
     
    Last edited: Mar 19, 2021
  38. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    I don't understand... Impostor System in profiler took too much time. On my device, it's about 2ms with a static camera and about 6ms with a moving camera and 20 updates per frame.

    What Graphics API are you using?
    upload_2021-3-19_17-19-46.png

    And can you confirm that the Burst compilation is enabled?
    upload_2021-3-19_17-20-11.png

    Also, looking at your timeline I can't see anything running in the Working threads.
    For example, this is my timeline where you can see Jobs executing on several threads.
    upload_2021-3-19_17-22-27.png


    This is because impostor textures are being rerendered. Or are you talking about your last test without imposters?
     
  39. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    OpenGL ES 3.0
    Burst enabled
    that's was stats from my scene.
    Here are the stats from your application on Blackberry Priv. 20 updates + 576 objects.

    On the left, there are spikes in motion, in the middle there is static and disabled impostors at the end.



    I'm talking about the SetPass Call Count in the render line, which rises when the camera moves.
     
  40. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Looks like old devices cannot handle 20 updates. I think from 5 to 8 updates would work in your case. Or even less...
     
    Last edited: Mar 19, 2021
  41. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    Not only the old ones, here is the Oculus Quest 2 profiler, also statics on the left, movement in the middle and disabling imposters at the end.



    The system behaves the same on all my devices.

    Another thing is the manual call to OnPreCullCallback. How to use it, imposters are cleared if you do not do it every frame.
     
    Last edited: Mar 20, 2021
  42. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Looking at your profiler I can easily say, that in the presented scene there is no need in using Impostors package.
    At the end I see a stable 90 FPS with big performance budget (I believe bottom part is smth like VSync on mobile devices, which means 60% of the time CPU and GPU do nothing).
    Impostors are meant to use with GPU bounded projects, where you have performance budget on CPU and want to dramatically decrease draw calls and vertices count.

    However, I still don't understand why Impostors System takes so much time on your devices. May I get a project that represents your issue? It will be much faster for me to iterate and find pitfalls.

    Impostors package can and will improve its performance with further development, but again 7ms is too much...

    I'm sorry... Yes, I've just checked, it doesn't work right. It will be fixed in the next release. Would you like to have a quick patch?
     
  43. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    Your application produces exactly the same data. Just increase the number of updates and move camera.
    Usually the biggest delay is in UpdateImpostorTextures ();

    I was thinking of making a few manual updates to the 13 frames per second with but decided that it would not help.

    Also I checked your last application on Samsung s8 plus and s7, imposters didn't show up at all.
    On s7, I checked the assembly with URP, I forgot the second one. I am sure that this is due to the project settings, everything is displayed in the builds of my project.
    Here are the profiler stats from it on s7, I tried to load the scene with objects as much as possible. With imposters, i get fast and beautiful rendering, but a heavy load on the CPU.


    I also have questions about the angle, I indicate 90-180 so that objects do not disappear, at 45 imposters simply do not appear.
    And I wonder if it is worth enabling mipmaps, does it give performance or take it away? I have disabled them for now.

    upd. ProcessImpostorableObject in case UpdateImpostorTexture the heaviest code in updates when camera move.

    In statics, with a large number of objects, Update Chunks Impostors performs worst of all.
    I'm not sure if deleting all impostors should work that often.
     

    Attached Files:

    Last edited: Mar 20, 2021
  44. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    Yes, system produces overhead if MaxUpdatesPerFrame is too high. Unfortunately, there is nothing to do about it rather than decreasing this value.

    This will kinda help, but yes, not really. 7ms spikes will kill smooth FPS. However, it may decrease power consumption when system runs smoothly.

    Could you please clarify what angle you are talking about?

    I would suggest enabling mipmaps. First of all, distant impostors will look much better with enabled mipmaps.
    Most GPUs have hardware accelerated mipmaps creation, so this does not impact performance that much. Also, sampling mipmapped texture is more performant, so mipmaps do not impact performance(in theory and my tests)

    Yes, you are right! Need to fix that...

    What Unity version are you using? I getting this error with Unity 2019.3.0f6
    'Profiler data stream has invalid signature.Are you using a player built with an older Unity version ?'
    2019.4.22 simply crashes.
     
    Last edited: Mar 20, 2021
  45. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    Perhaps there is a way to combine PIO calls to get a performance boost? With a more rare manual update but in batches.

    Otherwise, I do not understand at all how to use it in on mobile and quest with a moving camera. One update is very small, especially for scenes where there are many objects like a forest.

    Min Angle to Look in Camera. When I choose a low value, 45 or 30, the imposters just disappear.

    2020.3.0f1

    Here's what's going on in Update Chuck's in every update.
     
    Last edited: Mar 20, 2021
  46. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    I'll look at this.

    Maybe your camera moves too fast? I mean too fast for Impostors to handle. In that case, I just can't promise it will work. This specific impostor technic implementation work the best with a slowly moving camera as described in asset description. Don't get me wrong, I will improve this plugin as much as possible, but it has physical limits.
    I'm really glad you are spending your time testing my asset and writing here, this forces me to improve it:)

    Strange... Looks like 'WorldSpaceCameraPos' shader variable is incorrect, for some reason. It may be because of 2020.3 or because of VR rendering technic.

    Got it. Looking at the profiler data right now. How many impostors objects in the scene?

    Could you please tell Jobs and Burst packages versions?
     
  47. wbn1993

    wbn1993

    Joined:
    Sep 15, 2020
    Posts:
    2
    i find this bug! ImpostorLODGroupsManager._minAngleToStopLookAtCamera less than 70 is not to show, maybe that a Floating point precision problem of mail gpu!
     
    Hobodi likes this.
  48. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    What is your Unity version?

    UPD
    I saw it in the picture you sent previously. Looks like 2020.3 causing this problem. Will fix that soon. Hope this issue does not block the development of your product
     
    Last edited: Mar 20, 2021
  49. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    480
    With all the respect, I must say I think that the problem with your device.
    Why? Because on my several devices I never got ProcessImpostorableObject more than 1ms, while you have 8ms. That's very strange.

    I've quickly assembled this performance test app. Please, try it:
    https://drive.google.com/file/d/1eLsrxL0guqkzE6FFo8j1sRDFmqi7N_Dx/view?usp=sharing

    On my device it looks like this:
    upload_2021-3-20_22-28-53.png

    Test code:
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using Unity.Collections;
    5. using Unity.Mathematics;
    6. using UnityEngine;
    7. using UnityEngine.Profiling;
    8.  
    9. public class PerformanceTests : MonoBehaviour
    10. {
    11.     private const int Iterations = 10;
    12.     private const int ArrayLength = 4096;
    13.  
    14.     [System.Serializable]
    15.     private struct BigStruct
    16.     {
    17.         public float4 data0;
    18.         public float4 data1;
    19.         public float4 data2;
    20.         public float4 data3;
    21.         public float4 data4;
    22.         public float4 data5;
    23.         public float4 data6;
    24.         public float4 data7;
    25.         public float4 data8;
    26.         public float4 data9;
    27.     }
    28.  
    29.     private NativeList<BigStruct> _nativeList;
    30.  
    31.     private void OnEnable()
    32.     {
    33.         _nativeList = new NativeList<BigStruct>(ArrayLength, Allocator.Persistent);
    34.  
    35.         for (int test = 0; test < Iterations; test++)
    36.         {
    37.             for (int i = 0; i < ArrayLength; i++)
    38.             {
    39.                 _nativeList.Add(new BigStruct());
    40.             }
    41.         }
    42.     }
    43.  
    44.     private void OnDisable()
    45.     {
    46.         _nativeList.Dispose();
    47.     }
    48.  
    49.     void LateUpdate()
    50.     {
    51.         Profiler.BeginSample("Performance Test");
    52.  
    53.         for (int i = 0, count = _nativeList.Length; i < count; i++)
    54.         {
    55.             Process(i);
    56.         }
    57.  
    58.         Profiler.EndSample();
    59.     }
    60.  
    61.     private void Process(int index)
    62.     {
    63.         var data = _nativeList[index];
    64.  
    65.         data.data0 += data.data1;
    66.         data.data1 += data.data2;
    67.         data.data2 += data.data3;
    68.         data.data3 += data.data4;
    69.         data.data4 += data.data5;
    70.         data.data5 += data.data6;
    71.         data.data6 += data.data7;
    72.         data.data7 += data.data8;
    73.         data.data8 += data.data9;
    74.         data.data9 += data.data0;
    75.  
    76.         _nativeList[index] = data;
    77.     }
    78. }
     
  50. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101
    Not really, standard for FPS shooters.

    This solution has great potential, I want developers to be able to create huge worlds with it. :)

    4107 impostor lod groups show total.
    1.5.0 Burst
    0.8.0-preview.23

    For some reason, the profiler did not want to run for this application. It show 60 fps.

    Here are the profiler stats for your passed application with 10 updates that does not show impsoters on a series of samsungs but does show on blackberry priv.

    On them, the Imposotorable Object Process really gives 0% and the ExecuteCommandBuffer takes all the performance.
    Perhaps my project is affected by the number of objects or something else.

    Also wondering if the choice of Lateupdate and OnPreCull affects performance. In my application, nothing seems to have changed except the call queue.


    upd. I added the profiler sample code for process impostorable object where the work with chunks is going on, and this is what happened. It seems to me that this is the chunks weak point in my case.

    List is convenient, but maybe there is an opportunity to replace it with something faster? As an option.
     

    Attached Files:

    Last edited: Mar 21, 2021