Search Unity

Bug Various problems with URP and upscaling in 2021.3

Discussion in 'High Definition Render Pipeline' started by sebas77, Oct 4, 2022.

  1. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    The UI is affected by the Upscaling. I couldn't find a reason in the settings for this problem and didn't debug the code to look for a hack because I thought to open this thread for clues first. The documentation clearly states that the UI shouldn't be affected by the upscaling, but this doesn't work for UIs that use Screen Space - Camera. It works as intended only if Screen Space - Overlay is used.

    the previous problem is even more annoying knowing that the UI dedicated camera is using a separate URP renderer:
    upload_2022-10-4_12-2-21.png
    upload_2022-10-4_12-20-40.png


    I also want to report an impression, which unfortunately I cannot prove but:
    with my previous product Techblox (now Robocrat 2) the AMD fidelity x upscaling was not noticeable at all with HDRP, but in my new product, the jiggering is quite noticeable in URP even with high values (0.75). Maybe I have never noticed/forgot that Nvidia DLSS was running instead.
     

    Attached Files:

    Last edited: Oct 4, 2022
  2. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    769
    Hi, this is HDRP forum, maybe someone should move this thread to URP forum.

    It would be better if sending a bug report (in the editor) and providing a small project. (to reproduce this bug)

    Or just waiting for any Unity dev to reply to this thread.

    Some anti-aliasing (MSAA or TAA) can reduce these jiggering effects.

    Are you using TAA (or MSAA) in that HDRP project? You can try enabling MSAA 8x in URP to compare the results.
     
    nehvaleem and sebas77 like this.
  3. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    Today I discuss if we want to keep the upscaling feature. If so,I will open a bug report.
     
    wwWwwwW1 likes this.
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    If you place AI in world space (using world space or screen space) the UI gets rendered as if it's inside of the game.
    This allows shaders and post processing to work properly, including render scale.

    Overlay has a completely different pass for the UI making it easy to get out of the render scale.

    You can submit a bug report, if possible they fix it that would be great, but I expect a 'by design' mark
     
    sebas77 and wwWwwwW1 like this.
  5. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    In HDRP the upscaling can be set per camera, in URP there isn't such a thing, the only exception is the UI, so I am not sure how it can be by design, unless we want world space text to be unreadable.
     
  6. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    also in URP
    GetComponent<Camera>().allowDynamicResolution = false;

    doesn't work. it worked with HDRP, but it doesn't work in URP.
     
    Last edited: Oct 4, 2022
  7. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    So it also doesn't work in the hdrp anymore?

    I'd say make a bug report and see what happens
     
  8. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    no sorry I rephrased. It's a while I don't test HDRP
     
  9. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    Hi,

    What you are experiencing is by design, rendering UI as ScreenSpace or WorldSpace will throw the UI into the same rendering pass as the rest of the scene, making it adhere to the RenderScale in URP.

    In saying that you are right about being able to have RenderScale available at the camera level and is something that will come to URP with the better unification of HDRP/URP workflows. In the meantime you can set this value on the pipeline asset via API before the camera you want to render the UI in, and then set it back afterwards(using something like the RenderPipelineManager callbacks as an entry point), a bit more work is involved but it is possible.

    The allowDynamicResolution is another thing altogether and is used more for performance scaling during taxing parts of your game, this currently in URP is being worked on with better scaling options in the UI so I can try see if we can make some/all of those options configurable at the camera level rather than on the URP pipeline asset only.
     
    ManueleB, wwWwwwW1 and DevDunk like this.
  10. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    first of all, your reply is very appreciated.

    I am relatively sure that allowDynamicResolution was part of the HDRP Dynamic Resolution setup.

    upload_2022-10-13_14-34-54.png

    this is anyway what I am talking about in case it wasn't clear.

    Upscaling/Dynamic resolution are the same thing, aren't they?
     
  11. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    Not really, at least not how they are implemented in Unity.

    Upscaling, generally is just taking a lower resolution output, and doing something to make it the original size on screen. Recently this has been added to URP with a few options, the best being FSR, which does some pretty decent sharpening and works everywhere. In HDRP you have access to DLSS, which requires Nvidia hardware.

    Dynamic Resolution is the scaling that happens on the fly, generally this is done based on performance, so if the game is not quite hitting a set frame time then the resolution can be lowered, and if its easily hitting that target it can render full resolution. Now this really shines when you use it with upscaling since it can be pretty unnoticeable, especially if it's just quick action heavy parts in a game where this happens, so it is handy.

    Unfortunately this is not in URP, the backend is there(the API to tell buffers to be able to be dynamically scaled) but there is no UI or connection to performance data, so this has to be written manually. It is possible to do(I did it in the Boat Attack sample project) but it is completely up to you to implement which is not great, what's worse is newer API in SRP broke it :(

    So in URP at least RenderScale is not a replacement for dynamic scaling, the difference between this and proper dynamic scaling(what is shown in HDRP above) is that dynamic scaling creates a buffer that can be rendered into via a viewport very efficiently, so you create one buffer that is say 1080p, then you can render only 480p worth of pixels in it quickly, where RenderScale creates a buffer at that size, so if you did change it often, it is creating new buffers of that size every frame, they are temporary buffers, but still it is not good practise.

    This is why in URP we have Upscaling, but currently do not support Dynamic Resolution.

    A light at the end of the tunnel is that we are working hard on a decent Dynamic Resolution option in URP as we speak, so it is coming soon, I will look into how far back we plan to back port it, but depending on the complexity it might not go back too many Unity versions.
     
    sebas77 likes this.
  12. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    All right, but Dynamic Resolution and Upscaling are tied together. There is no Dynamic Resolution without upscaling.
    To Me DynamicResolution is not that different than setting the current URP

    (GraphicsSettings.renderPipelineAsset as UniversalRenderPipelineAsset).renderScale =

    dynamically.

    But after your explanation, I get the point. The use case still fits because we have just two different options for renderScale: 1 or 0.75 and it's a graphic setting.
     
  13. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    Hi,

    I'd like to resume this because in all this discussion I still didn't understand how to use RenderScale without affecting the UI.

    I will sum up the findings:

    1. the UI won't scale only if the canvas is set as screen space - overlay. Screen space - camera and worldpsace will make it scale with the RT.
    2. I am not sure why I cannot use two different base cameras yet , however I suspect that this won't work because it's not possible to have two different pipeline assets, one for each camera. This could be a new feature, or at least move the upscale option to the renderer asset. (atm I'd get this
    Code (CSharp):
    1. Dimensions of color surface does not match dimensions of depth surface
    2. UnityEngine.GUIUtility:processEvent (int,intptr,bool&))
    I assume because it's not DynamicResolution it's actually using a RT with a different res that won't match the UI one.
    3. change the upscale value through the callback as suggested. I am going to test this now and report back. (this didn't work eventually)
     
    Last edited: Dec 19, 2022
  14. Sabrino

    Sabrino

    Joined:
    Aug 8, 2015
    Posts:
    36
    How to change URP upscaling filter for dynamic resolution via script? It works using this, but I don't know how to choose FSR vs something else like in HDRP or renderscale: https://github.com/Unity-Technologies/DynamicResolutionSample
     
  15. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    437
    how come this thread related to URP is still in this subforum with even Unity staff replying here?
     
    DevDunk likes this.
  16. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    I didn't even notice it :O

    @Andre_Mcgrail could you please move this thread to the right forum?


    I thought this would have worked, but it didn't :

    Code (CSharp):
    1.   public void EnableGameCamera()
    2.         {
    3.                 _original = (GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset).renderScale;
    4.             RenderPipelineManager.beginCameraRendering += StartRendering;
    5.             RenderPipelineManager.endCameraRendering += EndRendering;
    6.         }
    7.  
    8.         public void DisableGameCamera()
    9.         {
    10.             RenderPipelineManager.beginCameraRendering -= StartRendering;
    11.             RenderPipelineManager.endCameraRendering -= EndRendering;
    12.         }
    13.    
    14.         void StartRendering(ScriptableRenderContext context, Camera camera)
    15.         {
    16.             if (camera.name == "UICamera")
    17.             {
    18.                 (GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset).renderScale = 1.0f;
    19.             }
    20.         }
    21.    
    22.         void EndRendering(ScriptableRenderContext context, Camera camera)
    23.         {
    24.             if (camera.name == "UICamera")
    25.             {
    26.                 (GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset).renderScale = _original;
    27.             }
    28.         }
    I do think this makes sense with hindsight, since the upscaling changes the resolution of the final RT I am not sure how this workaround would have ever worked.

    I guess for the moment I give up
     
    Last edited: Dec 19, 2022
  17. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    Eric5h5 could you please move this thread to the URP forum?
     
    nehvaleem likes this.