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

Bug Post-Processing bug with camera stacking in Unity 2022.3.0 (LTS)

Discussion in 'Universal Render Pipeline' started by GabrielBigardi, Jul 18, 2023.

  1. GabrielBigardi

    GabrielBigardi

    Joined:
    Apr 14, 2017
    Posts:
    18
    Hi, i'm currently using a 2-camera-stack for a game i'm developing (one for the game and one for the UI), however there's an issue, i wan't to add post-processing (bloom, vignette), but it is not working properly.
    What i wan't to do is to set the post-processing active only on the base camera (game), but when i enable it, it does not work, it only works when i enable it on the overlay camera, but that applies post-processing to every camera...

    I've recorded a small video, hope it helps understanding, i'm not good with words:


    Thanks for anyone wanting to help.

    EDIT:
    Forgot to mention, i've even tried setting both cameras render type to "Base" and setting the Skybox of the UI Camera to Uninitialized, but the same issue happens, only when my UI Camera has post processing it "works" (but for everything in the scene)
     
  2. japonica

    japonica

    Joined:
    Jun 23, 2016
    Posts:
    2
    Hello.

    I am having the same problem.
    If you have solved it, could you please tell me how to solve it?
    I am having a huge problem.
     
  3. japonica

    japonica

    Joined:
    Jun 23, 2016
    Posts:
    2
    One thing I have discovered.
    When Depth Of Field is set to Active and an effect such as Color Adjustment is enabled, the effect is applied.
    What on earth is this 。。。。
     
  4. KingkongX

    KingkongX

    Joined:
    Dec 12, 2019
    Posts:
    1
    Having same issue in 2022.3.
    Post process property check on Base type camera do not work, only works on overlay camera in camera stack
     
  5. GabrielBigardi

    GabrielBigardi

    Joined:
    Apr 14, 2017
    Posts:
    18
    Hi, unfortunately i didn't managed to solve it, i've tried lots of different fixes from creating new projects to changing the URP code myself, but what i ended up doing was not using a camera stack, instead of using a UI Camera in worldspace i'm now using the UI in screen space overlay with scaling mode set to constant pixel size + using this script i've made to make it pixel perfect correctly:

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using UnityEngine.UI;
    4. using UnityEngine.Experimental.Rendering.Universal;
    5.  
    6. public class CanvasScaleFixer : MonoBehaviour
    7. {
    8.     private int lastScreenWidth = 0;
    9.     private int lastScreenHeight = 0;
    10.  
    11.     private CanvasScaler _canvasScaler;
    12.     private PixelPerfectCamera _pixelPerfectCamera;
    13.  
    14.     private void OnEnable()
    15.     {
    16.         _canvasScaler = GetComponent<CanvasScaler>();
    17.         _pixelPerfectCamera = Camera.main.GetComponent<PixelPerfectCamera>();
    18.     }
    19.  
    20.     void Update()
    21.     {
    22.         if (lastScreenWidth != Screen.width || lastScreenHeight != Screen.height)
    23.         {
    24.             lastScreenWidth = Screen.width;
    25.             lastScreenHeight = Screen.height;
    26.             StartCoroutine(FindCanvasScaleFactor());
    27.         }
    28.     }
    29.  
    30.     private IEnumerator FindCanvasScaleFactor()
    31.     {
    32.         yield return new WaitForSeconds(0.001f);
    33.  
    34.         float difference = Screen.height / Camera.main.orthographicSize;
    35.         float newScaleFactor = difference / (_pixelPerfectCamera.assetsPPU * 2);
    36.         _canvasScaler.scaleFactor = newScaleFactor;
    37.     }
    38. }
    However not the best solution, while it works for me it most likely won't work for other people's games that needs camera stacking for different purposes.
     
    leohilbert likes this.
  6. leohilbert

    leohilbert

    Joined:
    Nov 28, 2015
    Posts:
    17
    +1
    I'm currently upgrading from 2021.3.18f1 to 2022.3.8f1 and when stacking my UI Camera (no PP) on top of my Main Camera (PP), the PostProcessing from the Main Camera is not working anymore.
    As soon as removing the UI Camera from the Stack, the PP works again. In 2021 this worked without problems, first the MainCam is rendered with PP and then the UI Cam is just layered on top.
     
  7. WeloSentoki

    WeloSentoki

    Joined:
    Jan 27, 2020
    Posts:
    2
  8. leohilbert

    leohilbert

    Joined:
    Nov 28, 2015
    Posts:
    17
    I created a bug ticket for Unity and they released a fix in 2022.3.11f1 (also in 2023.1.14f1, 2023.2.0b10, 2023.3.0a4).
    Haven't tested it yet though.
    Edit: Just updated and everything seems to work :)
     
    Last edited: Oct 27, 2023