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

    71 vote(s)
    85.5%
  2. Jobs (+ Collection and Mathematics)

    71 vote(s)
    85.5%
  3. Burst (+ Mathematics)

    72 vote(s)
    86.7%
Multiple votes are allowed.
  1. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    449
    Please, update to version 2.0.0. It should fix this problem. Here is a guide.
     
  2. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    449
    In the Assets\Impostors\Runtime\URP\UpdateImpostorsTexturesFeature.cs replace UpdateImpostorsTexturesRenderPass with this piece of code:

    Code (CSharp):
    1. class UpdateImpostorsTexturesRenderPass : ScriptableRenderPass
    2. {
    3.     private readonly Func<bool> _clearBufferAfterPass;
    4.     public readonly List<CommandBuffer> CommandBuffers;
    5.     private RTHandle _dummyRTHandle;
    6.     public UpdateImpostorsTexturesRenderPass(Func<bool> clearBufferAfterPass)
    7.     {
    8.         _clearBufferAfterPass = clearBufferAfterPass;
    9.         CommandBuffers = new List<CommandBuffer>();
    10.     }
    11.     public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
    12.     {
    13.         var rtFormat = RenderTextureFormat.R8;
    14.         if (SystemInfo.SupportsRenderTextureFormat(rtFormat) == false)
    15.             rtFormat = RenderTextureFormat.Default;
    16.        
    17.         var desc = new RenderTextureDescriptor(2, 2, rtFormat, 0, 0);
    18.         RenderingUtils.ReAllocateIfNeeded(ref _dummyRTHandle, desc, FilterMode.Point, TextureWrapMode.Clamp, name: "_ImpostorsDummyHandle");
    19.     }
    20.     public override void OnCameraCleanup(CommandBuffer cmd)
    21.     {
    22.         _dummyRTHandle?.Release();
    23.         _dummyRTHandle = null;
    24.     }
    25.     public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
    26.     {
    27.         ConfigureTarget(_dummyRTHandle);
    28.     }
    29.     public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
    30.     {
    31.         foreach (var commandBuffer in CommandBuffers)
    32.         {
    33.             context.ExecuteCommandBuffer(commandBuffer);
    34.         }
    35.     }
    36.     public override void FrameCleanup(CommandBuffer cmd)
    37.     {
    38.         if (_clearBufferAfterPass.Invoke())
    39.             CommandBuffers.Clear();
    40.     }
    41. }
     
  3. RichardJaquish

    RichardJaquish

    Joined:
    Sep 30, 2011
    Posts:
    5
    HDRP support please!
     
  4. szmalqp

    szmalqp

    Joined:
    Nov 15, 2018
    Posts:
    1
    On some Android devices (e.g. SoC:Snapdragon 450), it crashes after "Unity Warning: unsupported format 21, will likely crash!" as above. It seems to be related to "impostors-dither-pattern".
     
  5. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    449
    Ahh, the classic thing when you try to optimize but shoot in your leg instead...
    Please, change Format to Automatic in the texture import settings. Also, the R8 option might work as well.
    upload_2023-7-17_15-36-14.png
    Thanks for investigating and reporting the issue!
    Sorry for any caused trouble
     
  6. hehedang

    hehedang

    Joined:
    Jun 16, 2017
    Posts:
    8
    Dear author
    I'm using Unity2021.3.15 URP and I got two error from the script:

    Assets\Plugins\Impostors\Runtime\URP\UpdateImpostorsTexturesFeature.cs(96,60): error CS1503: Argument 3: cannot convert from 'UnityEngine.TextureWrapMode' to 'int'
    Assets\Plugins\Impostors\Runtime\URP\UpdateImpostorsTexturesFeature.cs(96,83): error CS1503: Argument 4: cannot convert from 'UnityEngine.TextureWrapMode' to 'UnityEngine.Rendering.DepthBits'

    Any suggestions from you to fix it?
    Thanks
     
  7. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    449
    Hi
    I'm testing with Unity 2021.3.17, URP 12.1.9, and the latest version of Impostors 2.0.0. Don't have any issues.

    Most likely you need to upgrade the URP package to a suggested version in the Package Manager window.
    Let me know whether this works for you.

    UPD
    by suggested URP version I mean the version that has a green check mark
    upload_2023-7-26_22-50-12.png
     
  8. hehedang

    hehedang

    Joined:
    Jun 16, 2017
    Posts:
    8
    That is really weird,I followed your recommand and this problem is prefectly solved,which i really appreciated that.But the new problems pops up:

    Assets\Impostors\Samples\Scripts\SimpleCameraController.cs(87,9): error CS0246: The type or namespace name 'InputAction' could not be found (are you missing a using directive or an assembly reference?)

    I guessed this is probably the reference issue but i don't know how to do.So sadly I have to deleted the sample forlder and the problem is gone.Althrough i'm not satisfied that i can't study from the sample,But at least it can fuctioning now.Really appreciate for your help!
    By the way,Unity2021.3.15 can't use this package because the latested URP version for 2021.3.15 is 12.1.8,I upgrade to 3.27 to solved this problem
     
  9. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    449
    Yes, that was a missing assembly reference. Sorry for the trouble. Update that fixes these issues is currently under review. Should be live in a few days. I'll let you know.

    That's really strange, I thought Unity does not introduce major API changes in minor version updates of their packages...
     
  10. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    449
    Hi!
    Version 2.0.1 is live. You should be able to seamlessly upgrade to this version and import samples without any additional steps. Let me know whether it works for you.
    Cheers!
     
    hehedang likes this.
  11. hehedang

    hehedang

    Joined:
    Jun 16, 2017
    Posts:
    8
    Thank you!That's really a fantastic news to heard.
    I'll figured it out during my job time.Really appreciated for your afford!