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:
    481
    Actually, I found a workaround for static batching. Now I'm curious if it will work with static batch utility)
    Most likely next update will fix issues with static batching.

    UPD
    StaticBatchingUtility works fine with Impostors. You can call Combine() at any point(Awake, Start, Update)
     
    Last edited: Jun 7, 2021
  2. NullyStudio

    NullyStudio

    Joined:
    May 10, 2019
    Posts:
    5
    Hello Do you know if this will work with Poly Few | Mesh Simplifier and Auto LOD Generator ?
     
  3. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    There is no built-in integration with any asset.
    This asset expands Level Of Details technique with one more level - an impostor. So it should work perfectly with any LODs generators as long as you are using the LODGroup component(it is required for Impostors package to work)
     
  4. NullyStudio

    NullyStudio

    Joined:
    May 10, 2019
    Posts:
    5
    Hello , after i added the rederer feature to the forwardRenderer it does not getr added
    imposter1.PNG imposter 2.PNG
     
  5. NullyStudio

    NullyStudio

    Joined:
    May 10, 2019
    Posts:
    5
    Sorry I was being dumb i did not save the scene after
     
    MUGIK likes this.
  6. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    Hi, I've read other posts regarding this, but I'm wondering what will happen if I have a static house with dynamic interiors, and I want to create an imposter for the house. Would the house appear in front of all the dynamic interior objects since it's just a quad now? I'd need to disable/cull the interior gameobjects before the house turns into an imposter?

    Another scenario: house with no roof, with dynamic interior. The player is standing on a cliff looking towards many houses to see if there are items there before going towards it. Would all the items need to be imposters then? How would the houses render behind those objects while having a few walls overlap some items?
     
  7. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Yes

    That sounds logical. You could cull the interior with LODGroup component because you anyways have to use this component to work with Impostors.

    I think the better solution would be to include interior into impostor. Impostors package doesn't require your objects to be marked with a static gameObject flag, you can move objects but these changes won't apply to impostor texture until you explicitly say ImpostorLODGroup to recalculate rendering instructions. This might be confusing to implement, so if you will have any question feel free to ask me here or in DM.

    If the house and interior objects are all have their own impostors then house's impostor will overlap all the interior impostors. Impostors can't do ZTest because it's just a flat quad.
     
    mikeohc likes this.
  8. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    Thank you so much for answering all the questions. :)
    I'm going to purchase the asset and run a few tests.
     
    MUGIK likes this.
  9. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    So I've ran a few tests, and just came back to say this asset is fantastic! The example regarding an open roof interior is achievable by following what Mugik suggested above for anyone wondering.

    Regarding updating (adding/removing) renderers in the LOD Group, I realized I need to remove the imposters and set it up again. Is there a way to update imposters with updated renderer list in the editor?

    I tried this and am curious how you'd do this when a dynamic object has been moved, and requires update the next time imposter is called. Thanks
     
    hopeful likes this.
  10. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    You need to do this:
    Code (CSharp):
    1. _impostorLODGroup.SetLODsAndCache(lods);
    2. _impostorLODGroup.RequestImpostorTextureUpdate();
    Please, let me know if it helped

    There are context menu commands you could use
    upload_2021-6-19_10-49-13.png
     
    Last edited: Jun 19, 2021
    mikeohc likes this.
  11. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    It seems I'm missing Request Impostor Texture Update?
    Couldn't locate it inside script either...
    Screenshot (219).png
     
  12. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Oh gosh, I'm so sorry! That's the not-released feature yet. I just need to publish it on the asset store... Gonna make this as soon as possible.
    If you'd like you can contact me through email and I will send you the new version bypassing the asset store.
     
    hopeful and mikeohc like this.
  13. ConstantineM

    ConstantineM

    Joined:
    Oct 16, 2012
    Posts:
    3
    Once again, an excellent asset, really helpful that is runtime.

    i would like to note that i faced a minor issue (on version 0.9.5):
    using the built-in render:

    Code (CSharp):
    1. #if IMPOSTORS_UNITY_PIPELINE_URP
    2.                     buff.Add(new SetVectorInstruction(ShaderProperty._MainLightColor, Vector4.zero));
    3. #else
    4.                     buff.Add(new SetVectorInstruction(ShaderProperty._LightColor0, Vector4.zero));
    5. #endif
    it seems that with
    ShaderProperty._LightColor0
    the impostor wouldn't work as expected. solved it by using
    ShaderProperty._MainLightColor
    for the
    #else
    clause.

    Also, i wanted to ask, do you have any rough ETA for completing the shadowcasting on impostors?
     
    Last edited: Jun 22, 2021
  14. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Are you using custom SRP? Is it working as expected?
    I didn't test it with custom SRPs so I'm very curious about how it goes.

    I would like to implement this till August, but I can't promise anything.
     
  15. ConstantineM

    ConstantineM

    Joined:
    Oct 16, 2012
    Posts:
    3
    i'm terribly sorry, i meant built-in render pipeline..

    that is actually great :)
     
  16. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    What version of Unity are you using?
     
  17. ConstantineM

    ConstantineM

    Joined:
    Oct 16, 2012
    Posts:
    3
    im on unity 2020.3.4f1
     
    MUGIK likes this.
  18. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Hey everyone!
    Now I'm looking towards the 1.0 release of Impostors package and... I have doubts about the current name :)
    I see a lot of you are using imposter rather than impostor.
    I'm not a native speaker, so I need your help with this.
    I've set up the one-question poll to gather your answers, please join if you can.
    Thanks!

    Link to poll:
    https://docs.google.com/forms/d/e/1...Fx3_6hlihdZDQDRdEVJuPCcQ/viewform?usp=sf_link

    Literally the poll
    upload_2021-6-30_11-44-53.png

    Have a nice day!
     
    zIyaGtVm likes this.
  19. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    From what I can see, "impostor" is the original spelling, coming from Latin. It is used the most.

    "Imposter" is an alternative spelling that has been used for 200 years, but it is normally used far less than "impostor."

    Possibly non-native English speakers tend to use the "-er" version?
     
    MUGIK likes this.
  20. kotoezh

    kotoezh

    Joined:
    May 21, 2013
    Posts:
    21
    Hello. I purchased the package, played with examples and test scenes and was really impressed with the results. Thanks! Now I am incorporating it in my working project and have a question:

    I need to dynamically create Camera manager, because my main Camera is inside the player prefab which is spawned in the scene with impostors. I have not found a way for this in documentation.
    I am trying to dynamically change Camera in preconfigured Camera Manager to my main Camera following the EditorTools script but maybe there is an easier way I missed? It seems that my setup is not too uncommon

    Please advise
     
  21. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    You could add camera manager component to the same game object inside prefab that has Camera component
     
  22. Alex20004044

    Alex20004044

    Joined:
    Jun 15, 2018
    Posts:
    2
    Hello, can you help me please? I have a problem with the Imposter on android platform. It works great with objects in unity editor, but objects are not visible in android build. I use URP. What I can do to fix this problem?





     
  23. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Hi
    Are there any errors on the device? What android device are you using?
     
  24. Alex20004044

    Alex20004044

    Joined:
    Jun 15, 2018
    Posts:
    2
    I solve this problem, thanks. There were not installed correct render pipeline in medium and low quality graphics settings, which were used on android
     
    MUGIK likes this.
  25. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    45
    Are there any plans to make it work in VR and with the URP? With a few very simple objects added (something of a sigle box type) and turned on Impostors performance went down from 72fps to about 50-60 and the objects where terrible refreshed (it was visible as jittering of the objects). I tried with different settings on the Scene Manager and nothig worked as expected... when the handled objects were replaced by textures from the Impostor than the "jittering" was present all the time. I didn't notice any issues on PC but when application was launched natively on the Quest than all problems were there.... :(
     
  26. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Do you know if this would work with Bakery for Lightmapping on Quest 2?
     
  27. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    I must admit I forgot to test last releases of the package on the Quest device. And unfortunately, I won't be able to test it soon... I'm leaving a town for a week. Sorry for that situation...
     
    arczi79 likes this.
  28. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    I don't know.
    I assume that using Lightmapping is sufficient for indoor environments, but Impostors package better works for outdoor scenes with distant objects.
     
  29. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    45
    I am in no rush with that ... if you can review the Quest related problems and fix them then I could use this package in my project .... otherwise unfortunately it is useless to me (as I am focused only on my VR project).
     
  30. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    184
    Hey, great asset. I just imported the project and ran the example but I'm getting flickering :(
    Is there a way to fix it?

    I am on macOS 11.5.2 (latest)
    Unity 2020.3.18 LTS (latest)
    Metal



     
  31. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Wow... Something is really broken.
    Are there any errors in the console?
     
  32. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    184
    Hey, no errors whatsoever. It just flickers whenever I move around.

    It looks like the impostors do work, but it has some insane triangle flickering.

    I tried tweaking the settings, such as Scheduled and Immediately and it's the same flickering result. Even with fewer impostors it will flicker.
     
  33. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    I will test Impostors on Unity 2020.3.18 but I can't test it on mac.
    Most likely problem is related to Metal, but we'll see
     
    sameng likes this.
  34. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    184
    Thank you so much for taking a look. Hopefully it's something simple.

    I also want to ask, is there any progress on Deferred rendering impostors?

    I've been using Amplify Impostors which works pretty good, but I love your asset that can render it in realtime, saving disk space and rendering many different angles.

    The Forward Rendering of the impostors seems to be slightly different from my deferred.

    Were there problems you ran into when trying to make it work with deferred? I saw that there is some commented out code in your Impostor shader. Was there a specific issue that stopped it from working?
     
  35. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Hi
    I've installed 2020.3.18 and Impostors works fine. I don't have mac device, so, unfortunately, I can't test it properly.

    Does this happen when you just rotating the camera and not moving?

    Just to make sure... Are these settings enabled?
    upload_2021-9-12_11-17-43.png

    Could you please try to disable 'Burst/Enable Compilation', maybe there is a problem with the Birst compiler on mac.
    Also, it might be helpful to know specific versions of Burst and Jobs packages installed in your project.

    Yes, I wasn't able to properly render into render texture using the deferred path. Maybe it's time for yet another attempt:)
    UPD
    Deferred rendering is quite different from forward. It requires a whole bunch of render targets for albedo, normals, emissions, and so on. And then merge these render targets together... I don't think this is possible at all. Or this will require creating, managing, and storing in memory all render targets for each atlas. It's at least 3x more GPU memory consumption.

    Btw, impostors shader is a cutout unlit shader with some vertex "magic", so there is not much sense in rendering them using deferred path.

    For now, Impostors supports only one directional light, maybe that's what causes the difference.
     
    Last edited: Sep 12, 2021
  36. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    184
    Hey thank you for taking a look :)

    1. It happens even when rotating the camera. I also tried toggling VSYNC on/off.

    2. I just tried the Burst/Enable Compilation option and togglng all the different options. Sadly still flickering :(

    3. I am using:
    Burst 1.6.0
    (latest)
    Jobs 0.8.0-preview.23
    (latest)

    3. For Deferred, there is a "final" buffer RT3, maybe it's possible to use that? For modifying the actual deferred rendertargets, Unity added a "finalgbuffer" option. Is this what you mean?
    • finalgbuffer:ColorFunction - Custom deferred path for altering G-buffer content.
    "https://docs.unity3d.com/Manual/SL-SurfaceShaders.html"


    I think there is 2 ways it could be Deferred:

    1. Render the "snapshot" in Deferred method.

    This would help projects that use Deferred because now Impostors will match lighting exactly!
    But that has some problems: for example I have a far object that has a Point Light affect it. In Deferred, this works very well and the object is lit by the Point Light. In Forward, unfortunately the point light does not affect it probably because of maximum light count.

    Is there some method I can try and match the lighting? Perhaps this is mostly up to me to try and match my "forward" mode with my "deferred" mode to make the lighting match. But that seems quite difficult.

    2. Render the Impostor quads in Deferred method.

    Deferred still works well with cutout shaders. But I see what you mean that this makes less sense.
    I wanted to use Deferred so all my Deferred effects still work (modifying gbuffer lighting, ambient occlusion, etc).
    But to do that, I see what you mean by the 3x memory usage as you need to store Normals, Depth, Metallic etc.


    By the way, I love the asset. Great work!

    Despite the flickering, it works very well. It's not the best in the editor, but it seems to not show the flickering problem on my target Console platform :)
     
  37. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    This means this is a hardware problem. While camera doesn't move - Impostors system does no mesh creation or other "dangerous" operations.
    which confirms my theory:(

    If we are talking about impostors then point light does not affect objects because there are no rendering commands in CommandBuffer to do so.
    In the previous version of Impostors asset "snapshot" was taken from Camera.Render() command which triggers culling of the whole scene for each snapshot - quite an expensive operation that prevents from creating more than 10 snapshots in a frame. This approach produces the exact image of the object.
    The current version uses CommandBuffers that are much faster to render and also allows to move the rendering process to render thread and not to block the main thread. But this approach requires recreating all CommandBuffer commands that Unity does internally when rendering scene - which is quite tedious to do(because this is on the engine side). I spent weeks looking into Frame Debbuger window and extracting commands, matrices, and keywords peace by peace:)

    If you really want to you can look at the source code of the ImpostorLODGroup.CreateRenderInstructionsBuffers() method, more specifically the SetupLightmaps() method. This is where lighting setup occurs for each renderer.

    To be honest, I have never used Deferred path in my actual games so I don't really know much about Deffered effects. It would be great if you could provide some example effect where I could test impostors.

    Thanks, I'm really glad to hear that:)
     
  38. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    45
    Any update on that?
     
  39. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Sorry for the late reply, I've been busy with releasing and hotfixing my game:oops:

    I've tried the latest Impostors release on my Quest and it works fine with Built-in RP.

    But with URP there are issues you have described. I don't know exactly what causes this issue and will investigate further, but the main problem is that URP can't handle SetRenderTarget commands from CommandBuffer.

    For now, I have a hacky fix:
    In file 'Impostors/Runtime/URP/UniversalRenderPipelineProxy.cs'
    on line 47 change method `ScheduleImpostorTextureRendering` from this:
    Code (CSharp):
    1.         public override void ScheduleImpostorTextureRendering(CommandBuffer commandBuffer)
    2.         {
    3.             _updateImpostorsTextureFeature.Clear(_cameraWhereToScheduleCommandBufferExecution);
    4.             _updateImpostorsTextureFeature.AddCommandBuffer(_cameraWhereToScheduleCommandBufferExecution, commandBuffer);
    5.         }
    to this:

    Code (CSharp):
    1.         public override void ScheduleImpostorTextureRendering(CommandBuffer commandBuffer)
    2.         {
    3.             Graphics.ExecuteCommandBuffer(commandBuffer);
    4.         }
    Please note, that these changes will negatively impact overall Impostors performance, because now rendering will block the main thread. But in my test on Quest device it shows 72 FPS. You can decrease 'Max Updates Per Frame' if you encounter FPS drop when camera moves.
    P.S.
    One more thing is to disable 'ExampleSpawner' component on the game object called 'Spawner' in the example scene.
    This script uses the old InputManager, and if your project is configured for a new Input System (which is required by XR plugins) then this component will log error every frame, which takes 2ms from the budget.
     
  40. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    184
    I figured out a reason why the impostor looks different from the deferred target: the Fog is not rendering at all.

    I do see the UNITY_FOG_COORDS all set up in Impostors.cginc, but unfortunately the Impostor is set to still full brightness in the distance. Is the Fog supposed to be working fully for impostor? Or does it "render and save" the fog to the rendertexture instead?
     
  41. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Fog should affect impostors in realtime and not the "render and save".
    Are you using built-in fog? Or post-process effect fog?

    UPD
    I've installed Post Processing package 3.0.3 and used the Deferred Fog option.
    Impostors are completely broken in the deferred path, unfortunately.
     
    Last edited: Sep 17, 2021
  42. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    45
    That seems to be working... in most cases. Unfortunately I am using UModeler in my project and Impostors doesn't work properly with objects created in UModeler.


    1. Adding "LOD Group" component to my Game Object created in UModeler:

    01.jpg

    2. LOD 0 - dragged Game Object from the Hierarchy tree (two entries added):

    02.jpg

    3. After selecting Tools->Impostors->Setup Impostor(s) there is added empty "Impostors LOD Group" script and automatically one "Renderer" is removed from the "LOD Group":

    03.jpg

    4. ...so I removed manually remaining "Renderer" from the "LOD Group":

    04.jpg


    ...to be continued....
     
  43. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    45
    5. ...and manually removed "Impostors LOD Group" script:

    05.jpg

    6. After selecting again Tools->Impostors->Setup Impostor(s) I have this effect with WARNING:

    06.jpg

    7. So again I dragged my Game Object to the Renderers on LOD 0 and everything seems to be good now:

    07.jpg

    8. ...but after saving changes and switching between objects I have again the same WARNING and automatically removed one Rendered (probably this one from UModeler):

    08.jpg


    As a result Impostors doesn't work with objects created in UModeler (but culling works in Oculus Quest, only LOD 0 seems to be not working). I can't setup it to not have that worning on "Impostors LOD Group". Is it possible to fix it in code somehow or maybe Impostors are not compatible with UModeler?

    Regards!
     
  44. ShortRoundKim

    ShortRoundKim

    Joined:
    Jul 19, 2012
    Posts:
    2
    Has anyone successfully used this plugin in an iOS game? It seems to work fine on Android, but on iOS my game crashes with the following error.

    "Execution of the command buffer was aborted due to an error during execution. Caused GPU Hang Error (IOAF code 3)"

    The game works fine on iOS with Impostors disabled. Tested on an iPhone XR.
     
  45. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Impostors package is trying to be as straightforward as possible. It mimics the behavior of built-in LODGroup component. If an object works fine with LODGroup then it should also work with ImpostorLODGroup. You just need to reference renderers that should occur on the specified view range.

    Maybe, the problem with UModeler is that it generates a new game object '__renderable_object__' whenever there are changes in the model, which breaks references to renderers in both LODGroup and ImpostorLODGroup.
    I've never used UModeler so can't be sure why it doesn't work.
     
    Last edited: Sep 28, 2021
  46. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Hi
    This is strange. I used to have clients who could run impostors on their iOS devices.
    Could you please try to decrease the 'Max Updates Per Frame' setting to 1 and try again?
    upload_2021-9-28_14-48-37.png

    Also, on the same object you could try to change Scheduled mode to Immediate, maybe this causes the problem...
    upload_2021-9-28_14-51-10.png

    From brief research on google, I can't find anything related to Unity and this error.
     
  47. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    45
    Looks like I was doing something wrong... or something has changed in my project (but I can't find what exactly). Still I have that worning on the "Impostors LOD Group" but the impostors works now properly on the Oculus Quest (with your changes in code of course). I will observe what is the impact on a performance and if the Impostors asset is suitable for my project. Thanks for your help!
     
    MUGIK likes this.
  48. ZhavShaw

    ZhavShaw

    Joined:
    Aug 12, 2013
    Posts:
    173
    Anyone tried this with Vegetation System (Pro)?
     
  49. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    109
    You got success with VSPro & Impostors?
     
  50. andthenwhat

    andthenwhat

    Joined:
    May 11, 2015
    Posts:
    19
    Import into fresh URP project in 2020 LTS, I get this shader error:

    Assets\Impostors\Runtime\MemoryUsage\MemoryUsageUtility.cs(41,59): error CS8377: The type 'T' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'

    Anyone know how to fix?