Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. 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+

    28 vote(s)
    84.8%
  2. Jobs (+ Collection and Mathematics)

    28 vote(s)
    84.8%
  3. Burst (+ Mathematics)

    27 vote(s)
    81.8%
Multiple votes are allowed.
  1. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    81
    Having tested the example scene, I realized that the load appears more with a large number of chunks. 4096 in example. Even if the camera is not pointed at objects.

    Also, my scene does not have a Light Probe, but Calculate Light Probe works, not critical, but it would be nice to turn it off.
     
    Last edited: Mar 21, 2021
  2. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Got it.

    Yes, these numbers are more truthful. ExecuteCommandBuffer is on the engine side, we have no control over it. It's the rendering process that draws objects into the impostor's texture. I doubt there is something I can do about it. Nevertheless, I have no excuse for why it takes so long in comparison to default rendering.

    Ok, maybe it's hardware problem that causes impostors to not show... I got device with Mali GPU and can reproduce this problem.

    This setting has no effect on performance. But I suggest using OnPreCull.

    Yes, this definitely could be improved. Previously, I thought that 100 chunks wouldn't affect performance that much
     
  3. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    4096 chunk?o_O

    It must be super cheap and shouldn't affect performance at all.
     
  4. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    81
    Objects. Highest setting in example scene.

    A single boolean check would be even faster, but not critical.

    It is strange that in the same project, example scene and my scene produce different imposter rendering results.
    In my scene, the rendering is normal, but in the example scene, only a few nearby imposters are rendered.

    In any case, faster chunk operations are needed now.
    There are also wishes for rendering, but for now the FPS is more important.
     
  5. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Maybe the problem with MinAngleToStopLookAtCamera again?

    Working on improving it right now
     
  6. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    81
    No, because of the angle disappear completely. So far I am using 180 and it works.
    Perhaps the LOD Bias settings do not match in scenes or are calculated incorrectly on the phone itself. In the editor, everything works fine in all scenes.


    My heavily loaded scene has 46-52 chunks.
    Hope this helps.
     
    MUGIK likes this.
  7. retoal

    retoal

    Joined:
    Mar 12, 2020
    Posts:
    2
    hello,when i play example on windows platform it looks perfect! but when i switch to android platform, it looks some issues. my project is mobile vr, can you tell me how to fix it? is it alpha channel?
    upload_2021-4-5_1-12-20.png upload_2021-4-5_1-12-20.png
     
    Last edited: Apr 4, 2021
  8. retoal

    retoal

    Joined:
    Mar 12, 2020
    Posts:
    2
    i run on my mobile vr device, and it became a big error, i can not see impostors. What's your setting on mobile vr?
    upload_2021-4-5_1-6-30.png
     

    Attached Files:

  9. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    It's strange...
    I'm able to reproduce this issue.
    As a quick fix please deselect the HDR option on ImpostorLODGroupsManager
    upload_2021-4-5_0-16-48.png

    If you are using a Built-In render pipeline for VR project, then you need to change Impostor Rendering Type to 'Immediately'.
    Unfortunately, Built-in RP has some limitations
     

    Attached Files:

    Last edited: Apr 5, 2021
  10. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,092
    1. What's the difference with amplify impostors? (Which is shader based)
    2. Does the URP shader graph allow custom lighting?
     
  11. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Amplify impostors are baked at edit time and each impostor uses big atlas to represent a single object from various sides.
    Impostors - Runtime Optimization are created at runtime, and each impostor represents object from a specific side, which faces camera. Therefore whenever camera moves it requires to regenerate impostor texture.
    Pros over amplify impostors:
    • no need to create big and heavy texture atlases and inject them into build,
    • creates impostors at runtime and could be used with procedurally generated objects,
    • mobile and VR friendly
    Cons:
    • not suitable for fast-paced camera movement games(because of the need to regenerate impostors when camera moves)
    • not suitable for close objects because of shader simplicity, which means no shadows, depth-write, and dynamic lighting.(but for distant objects it works great)
    I'm not sure what it is. Can you link some examples?
     
    Last edited: May 11, 2021
    laurentlavigne likes this.
  12. cepoimario280135

    cepoimario280135

    Joined:
    Jan 24, 2020
    Posts:
    11
    Just purchased the asset and the performance is insane good job ! however on URP 11 there seems to be an issue with render textures rendering transparent , i even tried to manually change the format and it it is still rendering the entire quad .

    Has anyone experienced this ?

    # tried changing the background color to black an made sure the it is indeed transparent but indeed the texture is not rendering alpha

    #disabeling the hdr bool solved the issue
     
    Last edited: May 10, 2021
    MUGIK likes this.
  13. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    I've just installed Unity 2021.2.0a16.2250.
    It comes with URP 12 and everything works fine with and without HDR.
    What specific version of Unity are you using?
     
  14. Elervax

    Elervax

    Joined:
    Sep 4, 2017
    Posts:
    5
    Does it work on terrain trees? And has someone tried using it with hdrp?
     
  15. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    No, terrain trees are entirely driven by unity's terrain system which cannot be expanded, unfortunately.

    I've tried HDRP:) For now, I didn't find a way to run it on HDRP, unfortunately.
     
  16. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    121
    Hi.I have some questions.
    Does every impostor's original gameobject need to add an LOD Group component even if they have only one mesh?
    How to scale an impostor?(I tried scale "ObjectToBecomeImpostor" and subObject "Cube" the runtime result still not scaled)
    How to make an impostor for a nested prefab?(The house in my scene is combined by small prototype prefabs like blocks and pillars, the house itself is not a single mesh).:)
     
  17. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Yes it's required, built-in LODGroup component is responsible for culling original renderers.

    Changing impostor at runtime is not a cheap operation.
    After changing scale(or other transformation) it's required to recalculate rendering instruction.
    Here is what you need to do:
    Code (CSharp):
    1.         private void OnChanged(ImpostorLODGroup impostorLODGroup)
    2.         {
    3.             impostorLODGroup.GetComponent<LODGroup>().RecalculateBounds();
    4.             impostorLODGroup.RecalculateBounds();
    5.             impostorLODGroup.Cache();
    6.             impostorLODGroup.UpdateSettings();
    7.         }
    Maybe I don't understand you correctly, but in theory house's impostor should not contain interior.
    To include/exclude renderers from impostor you can select ImpostorLOD and change renderers just like in LODGroup component:
    upload_2021-5-23_16-14-59.png
     
  18. tomobiki

    tomobiki

    Joined:
    Sep 27, 2020
    Posts:
    2
    HI, here's some gameplay footage of a game I'm developing ( https://youtu.be/To5X7Ncw-x0 ) do you think that Impostors could work in this environment? I read the description in the asset store, but I am not sure about it. I posted this becuase I read on the description to ask to you if one isn't sure if Impostors would work well in a game; if it's a problem I can delete this post.
    Thanks, bye.
     
  19. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    It should be ok assuming character flying speed will be the same as in the video. With higher speed comes higher performance drop.
     
    tomobiki likes this.
  20. tomobiki

    tomobiki

    Joined:
    Sep 27, 2020
    Posts:
    2
    Thanks!
     
  21. ysundawa

    ysundawa

    Joined:
    Mar 2, 2020
    Posts:
    15
    Hello, I am new to this asset and just starting my experiment.
    How can I combine between LOC group and Impostors?
    For example I will use LOD0, LOD1 from original, and wants to replace LOD3 and LOD4 with impostor?

    When I added the Impostor LOD Group, seems like it remove all LOD and only keep original?
    Or did I misunderstand ?

    Thanks..
     
  22. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Ahhh yes, now I see that it looks kinda counterintuitive.
    Original object
    means that at this range LODGroup is in control over the object.
    Just run an example scene and inspect the object, you will see, that LODGroup and ImpostorLODGroup work in conjunction.
    Before scene run:
    upload_2021-5-24_12-21-46.png
    In Playmode
    upload_2021-5-24_12-22-57.png

    This is how it may look:
    upload_2021-5-24_12-27-54.png
    Where 'Impostor 0' and 'Impostor 1' are previous 'LOD 3' and 'LOD 4'
     
  23. ysundawa

    ysundawa

    Joined:
    Mar 2, 2020
    Posts:
    15
    Aaah.... .... now I got it ! ... thanks for the explanation... will explore more on it !
     
  24. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    121
    • Sorry about my explanation, the house doesn't contain interior, it's just build with nested prefabs (for example walls are made by bricks) the house's outside surface maybe contains hundreds base prefabs. I wonder the performance under this structure because it's not easy to add all the meshes in inspector when they are nested prefabs.
    nested.png

    • Sometimes after I call "Setup Imposter(s)", I think the length of "Impostor 0" is extruded from 100%.
    length.png
     
  25. SofielafeeStudio

    SofielafeeStudio

    Joined:
    Mar 26, 2018
    Posts:
    41
    hey i've just followed the manual and first run my URP project errors out with

    NullReferenceException: Object reference not set to an instance of an object
    Impostors.URP.UniversalRenderPipelineProxy.ScheduleImpostorTextureRendering (UnityEngine.Rendering.CommandBuffer commandBuffer) (at Assets/Impostors/Runtime/URP/UniversalRenderPipelineProxy.cs:42)
    Impostors.Managers.ImpostorableObjectsManager.UpdateImpostorTextures () (at Assets/Impostors/Runtime/Managers/ImpostorableObjectsManager.cs:499)
    Impostors.Managers.ImpostorableObjectsManager.UpdateImpostorSystem () (at Assets/Impostors/Runtime/Managers/ImpostorableObjectsManager.cs:354)
    Impostors.Managers.ImpostorableObjectsManager.OnPreCullCallback (UnityEngine.Camera cam) (at Assets/Impostors/Runtime/Managers/ImpostorableObjectsManager.cs:404)
    Impostors.RenderPipelineProxy.RenderPipelineProxyBase.OnPreCullCalled (UnityEngine.Camera camera) (at Assets/Impostors/Runtime/RenderPipelineProxy/RenderPipelineProxyBase.cs:21)

    any idea?
     
  26. SofielafeeStudio

    SofielafeeStudio

    Joined:
    Mar 26, 2018
    Posts:
    41
    ok got it I've added the imposterer renderer. now my new issue is the background of the impostors are not clear, but light gray; although the alpha is set to 0
     
  27. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    81
    Try to open RenderTextureObjectPool and replace
    Code (CSharp):
    1. RenderTextureFormat = renderTextureFormat
    with
    Code (CSharp):
    1. RenderTextureFormat = RenderTextureFormat.ARGB4444
     
    MUGIK likes this.
  28. SofielafeeStudio

    SofielafeeStudio

    Joined:
    Mar 26, 2018
    Posts:
    41
    actually disabling HDR worked and was mentioned in a post above
    thanks
     
  29. lem2802

    lem2802

    Joined:
    Sep 25, 2020
    Posts:
    1
    does it work with terrain trees?
     
  30. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    There is no built-in functionality to fill LODs with renderers. You can write your own script that automatically sets renderers to the impostor's LOD. There is a property called
    ImpostorLODGroup.LODs
    that you can use to specify renderers at edit-time.
    For runtime LOD changes you need to use
    ImpostorLODGroup.SetLODsAndCache()
    .
    Please note that the first LOD represents the original object and must be empty.

    Also, I have to warn you that these wall blocks won't use GPU instancing

    Thanks for the report, I will look into this.
     
  31. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Yes, that's a known issue. Sorry for the inconvenience.
    The next update will fix this
     
  32. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
  33. Lynxbird

    Lynxbird

    Joined:
    Aug 19, 2018
    Posts:
    6
    I got this asset in the bundle, since it does not work with the terrain trees I am thinking what would be nice way to use this tool in my top down RPG, anyone have any ideas?

    Can you use this on projectiles? Maybe on people in top down RPG?
     
  34. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    It could be adopted and completely replace terrain trees with impostors.

    Impostors work only on static objects, for now.
     
  35. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    23
    Works perfectly in the editor, however in the android build impostors won’t appear if the objects are static batched. It works if they are not batched. I guess there’s an issue when generating the impostors on objects already batched, but this happens only on the actual build and not in the editor.
     
  36. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Thank you for the report. I'm sorry you faced this issue. Never thought static batching works differently on android...

    Let me know if this is critical for your project right now
     
  37. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    5
    Hello @MUGIK

    I have problem with example scene from your package - when the camera goes to the distance where "Impostor 0" LOD should kick-in than the example house just disappears (the same situation for the Game View and for the Scene View). I also don't see any spawned houses in any higher distance (Game View and Scene View). I am not sure what I should check and what options I should change to have it worked.

    Unity 2020.3.9f1.459
    Universal Render Pipeline

    Here how it looks like in editor:

    00_0.png

    00_1.png

    My Build Settings:

    05.png

    Quality Settings:

    01.png

    XR plugin settings:

    04.png
     
  38. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    5
    ...and the Player settings for Desktop:

    02.png

    02b.png

    ...and for the Android:

    03.png

    03b.png

    HDR is unmarked on IMPOSTORS setting and the proper component is added to the Forward Renderer:

    06.png

    Any suggestions what more should I check?
     
    Last edited: Jun 2, 2021
  39. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    I see you created the required render feature for impostors.
    But just to make sure... Did you replace BuiltInRenderPipelineProxy with UniversalRenderPipelineProxy on ImpostorableObjectsManager?
     
  40. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Hi
    I've just checked this issue and looks like Impostors won't work with static batched renderers.
    The thing is that in editor static batching occurs after scene is fully loaded (after Awake but before Start) so there is a time when system can access original mesh.

    But with builds it's different... Meshes are combined on the Build Player step. Docs.
    So there is no way to access original meshes and to feed them to the Impostors system.

    That's sad and there is nothing I can do, for now:(
     
    Last edited: Jun 2, 2021
  41. shadowfork

    shadowfork

    Joined:
    Jan 8, 2010
    Posts:
    165
    Will this work alongside Curved World shader?
     
  42. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    5
    It resolved my problem :) Sorry for stupid question... apparently I missed that part of setup. Thank you for your help!
     
    MUGIK likes this.
  43. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    No.
    First of all, each impostor is created for a specific camera angle, which would be incorrect with Curved World shader.

    Secondly, Impostors package uses a custom shader for impostors rendering. To work with Curved World you would have to modify impostors shader as stated in Curved World documentation.
     
  44. Evgenius

    Evgenius

    Joined:
    Sep 4, 2013
    Posts:
    16
    Hello there!

    I use Unity 2021.1.6f1, URP 11.0.0, with all required packages.
    I managed to setup example scene for the URP, but I have problems with adding new gameobjects with impostors, no matter in that scene or in a blank new. Steps:

    - Create an empty GO (parent).
    - Add a cube as a child (child).
    - Add default LOD Group.
    - Add child cube renderers to LODs (no matter how many LODs there are).
    - Add Impostors LOD Group.

    After the last step I get a NullReferenceException on validate.



    However, if I remove Impostors LOD Group and add it through the Tools -> Impostors -> Setup Impostors, then everything works fine!
    Also if I disable and then enable script, it works too.

    What could be the problem? Also is it possible to see impostors in edit-view during the play mode?
     
    Last edited: Jun 3, 2021
    arczi79 likes this.
  45. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Sorry, that's a bug. Thanks for pointing it out.
    That's a preferred way to set up an impostor in edit-time.

    Yes, in ImpostorableObjectsManager there is a setting called 'Debug Mode Enabled'. Enable it and you will see impostors in the scene view. This works only in play mode. Also, you can clear 'Debug Color' to see impostors without tinting.
    upload_2021-6-3_13-4-27.png
     
  46. Evgenius

    Evgenius

    Joined:
    Sep 4, 2013
    Posts:
    16
    No problem ;)

    Thanks, now I see that it's actually working with my prefabs :) Thanks for the great asset!
     
    MUGIK likes this.
  47. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    Hey there!

    Impostors 0.9.5 just released on the Asset Store!

    In this version:
    • Fixed HDR causing gray impostor's background
    • Improved editor workflow
    • Added ability to set rendering layer for impostors
    • Added in-editor dialogs to simplify impostors setup process
    Upgrading to the new version shouldn't break existing objects, but please back up your projects just in case!
     
    zIyaGtVm, arczi79 and hopeful like this.
  48. ChezDoodles

    ChezDoodles

    Joined:
    Sep 13, 2007
    Posts:
    101
    Will you actively pursue HDRP support in the future?

    Love your work.
    I also bought your previous product, and it also worked great - so I would love to be able to use this updated system with my HDRP projects.
     
  49. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    292
    I'd also love to! But I spent about a week last time trying to run Impostors with HDRP. I need some time to refresh and start all over again.
    For now, I'm focusing on the 1.0.0 release and frequently requested features like impostors` shadows and dynamic object impostors.
     
  50. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    23
    I see. Actually in my main project I don’t use unity static batching at build time, I use static batch utility to batch meshes on awake, so I might be able to make it work.
    The issue I’ve seen was in a small test project I made, were I was using standard batching during the build.

    I will try using impostors and manual batching, and check if it works, thanks!
     
unityunity