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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

[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+

    48 vote(s)
    81.4%
  2. Jobs (+ Collection and Mathematics)

    50 vote(s)
    84.7%
  3. Burst (+ Mathematics)

    51 vote(s)
    86.4%
Multiple votes are allowed.
  1. InfiBatnisGame

    InfiBatnisGame

    Joined:
    Jun 26, 2019
    Posts:
    15
    Same
    pls add HDRP, best asset.
     
  2. AuKtagon

    AuKtagon

    Joined:
    Aug 3, 2017
    Posts:
    5
    What was the fix? I am having the same exact issue. Thanks!
     
  3. AuKtagon

    AuKtagon

    Joined:
    Aug 3, 2017
    Posts:
    5
    Hi, I hope everything is going alright and much support for the people of Ukraine.

    I am having a similar issue to Kamil1064 where I have lots of objects in my scene and am getting an "Index {0} is out of range of '{1}' Length." Please help. Thank you!
     
  4. Kamil_Reich

    Kamil_Reich

    Joined:
    Aug 14, 2014
    Posts:
    190
    The author send me on private message newest version of asset. It should be in asset store already, that was just small update.
     
  5. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Hi
    As Kamil1064 mentioned the update is live on the Asset Store. Let me know if it fixes the issue for you.
     
  6. AuKtagon

    AuKtagon

    Joined:
    Aug 3, 2017
    Posts:
    5
    This seems to have fixed my issues. Thank you so much!
     
  7. tyebeach_unity

    tyebeach_unity

    Joined:
    May 9, 2020
    Posts:
    7
    I imported Imposters into my project and I have the following errors can someone help me out?

    upload_2022-3-31_19-56-49.png
     
  8. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Hi
    Most likely Unity didn't automatically import essential packages that are required by Impostors.
    Please, import Jobs and Burst packages using the Unity Package Manager window.

    Just in case I should mention that the Impostors package doesn't depend on Entities.
     
  9. inyourpc

    inyourpc

    Joined:
    Jul 14, 2013
    Posts:
    6
    Hi,
    I see burst and jobs in dependencies list, so its probably not for webgl solutions, and what about android, ios apps ? Also can you recommend alternative for webgl incase imposters is not supported on webgl
     
  10. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Hi
    Yes, you are right, Impostors package doesn't work for webgl because the Jobs package is not supported there.
    On Android it works fine, even on Oculus Quest. That's what I'm able to personally test.
    From customers' words on iOS it also works
     
  11. Xavier78

    Xavier78

    Joined:
    Oct 13, 2013
    Posts:
    36
    Hi I am getting the error.

    Assets\Impostors\Runtime\URP\UpdateImpostorsTexturesFeature.cs(38,17): error CS0012: The type 'RTHandle' is defined in an assembly that is not referenced. You must add a reference to assembly 'Unity.RenderPipelines.Core.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.


    And in the IDE if I hover over it I get the message.


    Method 'UnityEngine.Rendering.Universal.ScriptableRenderPass.ConfigureTarget' is obsolete: Use RTHandle for colorAttribute


    Not sure how to switch them out, and seems like they changed something on the newer URPs.
     
  12. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    What Unity and URP versions are you using?
     
  13. JDrem1

    JDrem1

    Joined:
    Jun 24, 2017
    Posts:
    199
    Hi.
    Quick beginner to imostors question.
    And forgive if this is insanely obvious.
    Just making sure.

    Can the imposters be used for static objects, (buildings, etc,) -from a distance, then as the player draws closer. (this would be in VR) Swap to a lod'ed version of the mesh, and so get more detailed until close up.

    As billboard trees do. Just instead of the billboard, it is an impostor?

    Also if the above question is a yes, is it "couple of clicks doable, for each object.

    Thanks for any help.
     
  14. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Hi
    If your objects already have the LODGroup component then yes it's a couple of clicks to set up impostors on these objects.

    The core component of Impostors package is ImpostorLODGroup, which works in conjuction with Unity's LODGroup component. Think of this as extending LODGroup functionality to draw impostors as the last LOD - instead of culling object just drawing its impostor.
     
  15. JDrem1

    JDrem1

    Joined:
    Jun 24, 2017
    Posts:
    199
    Thank you MUGIK.

    Yes the objects would already be lodded,
    Or I would add the LODs, before attaching the impostor as the last LOD.
    So I believe this is what you meant, which is great news.

    I appreciate the rapid and very helpful feedback.
     
    MUGIK likes this.
  16. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    8
    Hello. When I run in play mode inside Unity, impostors are working great. When I build and deploy to Quest 2, they simply don't render. I am logging to ensure the scene/camera manager are active/enabled, and even tried adding via
    SetupImpostorLODGroupToObject
    at runtime, but no change, and no other errors logged. Am I missing something simple? Thank you!
     
  17. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Hi
    Please, try this temporary fix:
    https://forum.unity.com/threads/released-impostors-runtime-optimization.759110/page-3#post-7500839
     
  18. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    8
  19. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Great. A new version is currently on review and soon will be available on the Asset Store. The update fixes a bunch of issues and also adds a setting to control impostor rendering for URP projects
     
    hopeful likes this.
  20. MaxKMadiath

    MaxKMadiath

    Joined:
    Dec 10, 2016
    Posts:
    58
    Do you have any plan for HDRP support Unity 2021 PLS
     
  21. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    30
    Will it fix also the problem with Quest 2 so we don't have to use workaround any more?
     
  22. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    For now, there are no plans for HDRP support.
    Maybe only as a separate package because of the differences in the render pipelines.
     
  23. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Yes, now there is a setting to choose how to render impostors instead of the workaround
     
  24. EpiEmanuel

    EpiEmanuel

    Joined:
    Jan 26, 2022
    Posts:
    5
    Hi! I just bought your asset and it looks very promising! Although I encountered and issue with my custom shader that has a Dither LOD Fade function for Cross Fade between levels. When it reaches the Impostor level it looks like this:
    Unity_x6Ux8ADUAx.png

    I suspect Impostor captures the object just when it does the dither fade? Is there a workaround for this?
     
  25. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Hi
    Looks like that's a new issue so there is no quick workaround. Could I get your custom shader?
     
  26. EpiEmanuel

    EpiEmanuel

    Joined:
    Jan 26, 2022
    Posts:
    5
    Here you go. :) Would be awesome if you found a solution for it.
     

    Attached Files:

  27. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Whan Unity and URP version are you using?
     
  28. EpiEmanuel

    EpiEmanuel

    Joined:
    Jan 26, 2022
    Posts:
    5
    Using Unity 2021.2 and URP 12.1.3
     
  29. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    You will need to change code a bit.
    In the ImpostorLODGroup.cs at line ~385 make this change:

    Code (CSharp):
    1. SetupLightmaps(builder, renderer, lightmaps);
    2.  
    3. builder.PropertyBlock.SetVector("unity_LODFade", new Vector4(1,1)); // added line
    4.  
    5. DrawRenderer(renderer, builder, sharedMaterials);
    Let me know if this helps
     
  30. EpiEmanuel

    EpiEmanuel

    Joined:
    Jan 26, 2022
    Posts:
    5
    I added the line but it's still the same behavior, unfortunately.

    Did it work for you?
     
    Last edited: Apr 27, 2022
  31. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Looks like something is wrong with Unity's Dither node. When '1' is provided as input Dither node still produces some noise.
    upload_2022-4-28_12-28-4.png

    And this noise is fully gone only when input is bigger than 2
    upload_2022-4-28_12-30-6.png


    However, LODGroup provides unity_LODFade in range 0..1 and it somehow works correctly.
    I don't know what exactly is happening.

    But to fix your issue instead of setting
    new Vector4(1,1)
    use something like
    new Vector4(10,10)
     
    Last edited: Apr 28, 2022
  32. EpiEmanuel

    EpiEmanuel

    Joined:
    Jan 26, 2022
    Posts:
    5
    Ah yes, that did it! Strange indeed.

    Thanks for the fast response!
     
  33. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    30
    But it doesn't change how it works underneath... It adds only checkbox which turns on/off that "workaround" in code. And in this post: https://forum.unity.com/threads/released-impostors-runtime-optimization.759110/page-3#post-7500839 you mentioned something like that: "Please note, that these changes will negatively impact overall Impostors performance, because now rendering will block the main thread". Is there any better fix planned? ;)
     
  34. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    I would love to fix this issue in a proper way, but...
    1. I don't have access to my Quest device and don't think I will get it soon. And without device I cannot debug
    2. Quite possible that there is no fix just because of how unity handles VR rendering
    Btw, I can't say that this is a "workaround". It's just another way to render impostors that has some pros and cons.
    Pros - it is stable, works in most cases, and doesn't affect the rendering pipeline in any way.
    Cons - it is slightly worse in performance. Maybe 25-50% slower.

    So, for example, the whole impostor system update loop (with rendering impostor textures on GPU) will take:
    Scheduled - 1ms
    Immediate - 1.25-1.5ms
    You may say that's a lot, but it's only a 2-5% increase within the frame budget of 10ms. I believe, compared to no impostors at all this increase is negligible. Please, correct me if I'm wrong.
     
    arczi79 likes this.
  35. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    30
    Definitely without impostors my small project would be completely different ;) Hope one day you have a time/opportunity to dig a little deeper in the VR subject to push a little further performance on thes small, funny devices.
     
    MUGIK likes this.
  36. FiveXGames

    FiveXGames

    Joined:
    Apr 27, 2016
    Posts:
    41
    Does this asset support impostors with an orthographic camera?
     
  37. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Not really. It needs some adjustments to work properly with the orthographic camera.
    I didn't implement them yet because there were no requests for that. Let's discuss this in PM because I need some additional information about your project
     
  38. jtomola

    jtomola

    Joined:
    Nov 3, 2016
    Posts:
    2
    So does this system not support deferred rendering through URP? With that setup, none of the impostors are visible at all. If I switch it to forward rendering in URP, it looks like everything works properly.
     
  39. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Hello

    I missed the news about deferred rendering finally being added to URP.

    I need more time to investigate everything related, but there is a simple workaround to make impostors work with deferred URP.
    Go to Impostors/Runtime/Resources/Shaders/impostorsShader.shader and change line ~24 from
    "LightMode" = "UniversalForward"
    to
    "LightMode" = "UniversalForwardOnly"

    This will force impostors to draw using forward rendering even if deferred rendering is set in the project settings. Let me know if this works for you
     
  40. madkevop7

    madkevop7

    Joined:
    Nov 11, 2021
    Posts:
    23
    Hi my game is multiplayer and player is spanwed runtime, how do I assign MainCamera at runtime?
     
  41. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    You can assign CameraImpostorsManager directly to camera game object. Make sure that this component is active only for the player.

    Alternatively, you need to follow these steps:
    1. disable CameraImpostorsManager script
    2. set reference to CameraImpostorsManager.mainCamera field
    3. enable CameraImpostorsManager script

    Let me know if this works for you.
     
  42. mickkay

    mickkay

    Joined:
    Jan 24, 2016
    Posts:
    3
    I just purchased your asset because of the slogan "Next generation of Imposter System asset with DOTS in mind." but it seems that it's not working with ECS... or does it?
     
  43. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    DOTS and ECS are not the same things :)

    ECS stands for Entity Component System - a specific way of structuring your code by separating data and logic.
    As a side feature, it makes possible efficient use of RAM and encourages CPU cache usage(the DOTS thing). But that's not the main idea. There are tons of ECS implementations that are not using such optimizations. For example LeoECS.

    DOTS stands for Data-Oriented Technology Stack. In Unity ecosystem it refers to three main packages: Jobs, Burst, and Entities. While Entities is still in preview(pre-release), the Jobs and Burst packages are quite stable and ready for production development.

    Impostors package is based on ideas of DOTS (efficient RAM and CPU cache usage) using Burst and Jobs packages.
     
  44. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    30
    Hi! Again a funny question from me. Do you see any possibility to make the Impostors work with World Streamer 2 ?? Any advice on what I should start? Do you think adding Impostors Handler on every dynamically loaded scene makes any sense?
     
  45. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Hi
    I don't know how exactly World Streamer 2 is working, but in general, Impostors system supports dynamically adding and removing objects (whether it's enabling/disabling or spawning/destroying).

    No, ImpostorLODGroupsManager (previously called ImpostorsHandler) has to be a single instance, it's basically a singleton. Its lifetime is in your full control. You can make it DontDestroyOnLoad or whatever best fits you project
     
    arczi79 likes this.
  46. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    30
    But will it handle object on multiple scenes? What if I'am adding another scene in a runtime? Will it recognieze objects from that added scene?
     
  47. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    406
    Yes, a single instance of ImpostorLODGroupsManager will handle all loaded scenes. Loading scene is basically an instantiating process so it should be fine
     
    arczi79 likes this.
  48. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    30
    Thank you so much for fast response.
     
  49. mickkay

    mickkay

    Joined:
    Jan 24, 2016
    Posts:
    3
    Thank you for your answer. I am aware of the differences between DOTS and ECS.

    So, rephrasing my question: do you have any plans to support ECS so that we can use impostors with entities directly?

    And, if not, are you aware of any other work around for using impostors within an ECS project besides using game objects instead of entities?
     
  50. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    30
    You were right - loading scenes at runtime is not a problem - Impostors can handle it without issues.

    Unfortunately I have another issue with Impostors... and honestly I don't know how to resolve it.
    Large scale worlds (which I am trying to use in my project) are affected in Unity by issue called "Floating Point Error for Large Scale Worlds" caused by losing precision of calculation on float point numbers when these numbers starting to be a bigger and bigger (decimal part starting to be shorter and shorter and the calculations are less precise causing variety of artefacts and physics issues). Solution is to periodically move coordinates of the player to (0, 0, 0) point and all objects in the loaded scene hve to be also moved accordingly.

    To resolve the issue with Floating Point Error I use a solution delivered with World Streamer 2 (already prepared script). Unfortunately when the script is turned on then Impostors seem to be not working. I assume the issue is caused by the updated/changed position of objects with the attached ImpostorLODGroup script. Any idea how to resolve something like that? I assume positions of objects in some Impostors collections have to be updated... but how and where?