Search Unity

Bug HDRP Compositor producing low screen resolution in builds

Discussion in 'High Definition Render Pipeline' started by nekropantz, Apr 20, 2021.

  1. nekropantz

    nekropantz

    Joined:
    Dec 11, 2012
    Posts:
    17
    We're using the compositor to stack 2 cameras. It works fine in the editor but when we make a windows build the output resolution tanks (Screenshot attached).

    The resolution is fine in the main menu screen where there is no compositor set up and works fine if we disable the compositor.

    Looks like the target render texture being composited is generated at the wrong resolution in builds.
     

    Attached Files:

  2. IVANMARTINEZ94

    IVANMARTINEZ94

    Joined:
    Aug 2, 2017
    Posts:
    10
    First sorry for my english.

    Yes, I have the same issue in my project.
    after trying several things, one of the problems was having a local volume in the scene after remove it the problem of pixelated was not appear, in other scenes the problem was that i have more than one volume however this volumes was disabled but affected.
    In other scene the problem was resolved after remove compositor camera, restart de editor and create one again.
    I have many problems after modify lighting or sky and fog component, seem that something stays in memory and affect.

    Now my problem if use compositor is that in builds resolutions in 1080p or below works fine but 1440p or greater provoke that the ui position not correspond with original position, this problem not appear in editor only in builds. (I compile with il2cpp)
     
  3. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    765
    hey @nekropantz, I briefly tried to repro but couldn't with a simple layer and two camera stacked on top of each other.
    I tried mulitple resolution up to 4k in build.
    Could you give the HDRP version and/or the engine version you're using ?
    If you have a small repro project that you could share, it would be great for us to investigate the issue faster !
     
  4. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    Actually the the low resolution look is looking like it could be used in some stylized game, would love to reproduce it on my side :)
     
  5. mariusz_str

    mariusz_str

    Joined:
    Feb 10, 2021
    Posts:
    2
    I had a similar problem but when enabling ray tracing while using composer.
     
  6. nekropantz

    nekropantz

    Joined:
    Dec 11, 2012
    Posts:
    17
    I don't have a repro project right now, but we are using Unity 2021.3.1

    From the other posts, It sounds like the compositor isn't ready for production. I heard that it is actually intended for film?

    Our use case is to render the player weapon/hands separately so that it does not clip through walls.
    What is the intended workflow for solving this problem?

    If I recall we initially moved from just using the camera depth to using the compositor because we were having issues with the depth of field not working correctly when stacking cameras.
     
  7. PavlosM

    PavlosM

    Unity Technologies

    Joined:
    Oct 8, 2019
    Posts:
    31
    The compositor is using multiple cameras under the hood to render each composition sub-layer, and this makes it rather slow for applications where performance is critical, like games.

    Using multiple cameras (with or without the compositor) is rather slow, because for every camera you have to pay the cost of culling and also the cost to setup various passes that are needed during rendering, so the overhead is rather high for drawing simple things like one weapon or some UI.

    For rendering weapon/hands separately, I would recommend looking at the custom pass API in HDRP:
    https://github.com/alelievr/HDRP-Custom-Passes
    This should give you the best performance.

    On a side note, regarding the compositor bug that you saw, while we could not repro locally, I think this PR will solve the issue (it will land in a future release):
    https://github.com/Unity-Technologies/Graphics/pull/4593
     
    chap-unity likes this.
  8. nekropantz

    nekropantz

    Joined:
    Dec 11, 2012
    Posts:
    17
    Just to follow up, haven't been able to confirm the fix.
    We've transitioned to using one camera and a custom pass as advised.
     
  9. PavlosM

    PavlosM

    Unity Technologies

    Joined:
    Oct 8, 2019
    Posts:
    31
    Good to know, the custom pass was clearly the best/faster option for your use case.

    The compositor fix unfortunately did not land yet in any release.
     
  10. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    720
    I've also run into this on 2020.3.13f1. It didn't seem to matter whether the resolution was changed after starting the game or not. This is on a 3440x1440 monitor; perhaps the issue depends on your screen resolution?
     
  11. hugokostic

    hugokostic

    Joined:
    Sep 23, 2017
    Posts:
    84
    I was able to Setup all the RT I need using copy pass functions from alelievr repo ( https://github.com/alelievr/HDRP-Custom-Passes ). With this feature (custom pass) you can create an order for your pass, and create effect or save the result into an RTs.
    I have just modified some things and created a pass that initialize multiple "screen sized RT" but without really writing into it, look at the SyncRenderTextureAspect() use in the execute of the CopyPass.cs render pass.

    Code (CSharp):
    1.    void SyncRenderTextureAspect(RenderTexture rt, Camera camera)
    2.     {
    3.         float aspect = rt.width / (float)rt.height;
    4.  
    5.         if (!Mathf.Approximately(aspect, camera.aspect))
    6.         {
    7.             rt.Release();
    8.             rt.width = camera.pixelWidth;
    9.             rt.height = camera.pixelHeight;
    10.             rt.Create();
    11.         }
    12.     }
    Just to always get the proper size. Anyway, compositor will write the sized (but empty) RT with his own condition if they are that are sloted into _BaseLayerX property of the compositor graph


    It initialize the RT at the good size, it even change accordingly each time you switch from format directly in game view.
    I ended up inject that RT with no additional settings into the compositor using only some layer in texture mode, then the result of each RT is lerp it into the compositor's shader in the way I needed.
    So, only one camera used to generate the RT with the good effect set for each RT and inject the compositor shader with this.
    Dunno why, but additional culling parameter work by texture layer in compositor settings too, it allow even more complex layer base interaction. So it need the Main compositor cam as a recipe and the source camera use to output to some RT.
    I see the result in the the game view if the compositor preview option is enable. This is working with a nice previous of your RT in the compositor Tab :


    I did not show to change Game view resolution in the gif but it is working anyway.

    Actually it's better to this kind of operation with custom pass only and replace the compositor part by adding simple blit custom pass, it is better because it allow you to have the effect even in Editor view and is project-wide effective, as the compositor is only scene-relative.