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)
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 。。。。
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:
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Experimental.Rendering.Universal;
public class CanvasScaleFixer : MonoBehaviour
{
private int lastScreenWidth = 0;
private int lastScreenHeight = 0;
private CanvasScaler _canvasScaler;
private PixelPerfectCamera _pixelPerfectCamera;
private void OnEnable()
{
_canvasScaler = GetComponent<CanvasScaler>();
_pixelPerfectCamera = Camera.main.GetComponent<PixelPerfectCamera>();
}
void Update()
{
if (lastScreenWidth != Screen.width || lastScreenHeight != Screen.height)
{
lastScreenWidth = Screen.width;
lastScreenHeight = Screen.height;
StartCoroutine(FindCanvasScaleFactor());
}
}
private IEnumerator FindCanvasScaleFactor()
{
yield return new WaitForSeconds(0.001f);
float difference = Screen.height / Camera.main.orthographicSize;
float newScaleFactor = difference / (_pixelPerfectCamera.assetsPPU * 2);
_canvasScaler.scaleFactor = newScaleFactor;
}
}
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.
+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.