I was working on post processing in my game, and I wanted some objects to be affected by bloom. I tried to set one gameobject’s (the red one) layer to custom layer Bloom and set a camera, which renders only Bloom layer (using Culling Mask). Despite the fact that the camera preview shows this 2D object, it does not appear in Game window.
As you can see, I also tried adding 3D object to the scene, and putting it on Bloom layer too. And for some reason it’s being rendered by the camera.
How do I fix this problem?
Short answer: You need to set the output of the bloom camera to a render texture and render that render texture with the main camera.
Long answer:
Each camera has an output target. This can be a render texture or a Display1-8.
When you set the "target display" of a camera to DisplayX, you can view it from the game view. By default the game view shows the Display1. You can change to another Display from the game tab:
If you need to render the output of a camera(CamX) within a different camera(CamY), you’ll need to set the output of CamX to a render texture(renderTextureX) . Then you create a quad as a child of CamX, give it a 2D sprite unlit material(right click project window, create>Material) and set the sprite texture of the quad’s material to the renderTextureX
Notes:
1-make sure CamX has a lower “Priority” than CamY(under rendering settings of the camera component)
2-dont render the quad with CamX and only render bloom objects with CamX(you can do it with layers & culling mask, you already know this)
3- I’d be surprised if bloom postfx doesnt have an option for selecting layers – edit: nope there isnt an option for it, but apparently you can do it with camera stacking on URP
Thanks a lot!
Though, I found out, that camera stacking on URP isn’t supported for 2D projects yet, unfortunately: Important note: In this version of URP, Camera Stacking is not supported when using the 2D Renderer or when using the VR Multi Pass mode. Support for these will be added in upcoming versions of URP.
Also, one more question: if I were to use render textures, then I would have to choose a single screen resolution for the game? Or is it not the case?