I am using URP post processing along with cinemachine. I need to make a specific game object in the scene be affected by my post processing but any time I switch to the virtual camera that has the volume settings on it everything on the screen gets affected. If I was doing this with URP only and no cinemachine I could just have the objects on different layers and set up my volume to affect one specific layer but I have no idea how to do this with cinemachine? Any and all help would be appreciated.
Iām afraid there isnāt really a way to do this with the CinemachinVolumeSettings Extension out of the box. Under the hood itās going to create a global volume whose layer mask is pulled from the UniversalAdditionalCameraDataās layer mask. Youāre going to have to make your own volume and make a custom extension to enable it when the vcam is enabled.
@ClumptyJones If you figure this out, can you describe how/what to do such that I can similarly have post processing on some layers, and not on others, when using Cinemachine, as per some discussions in this thread, Iām using BiRP:
I get the feeling that itās not possible to differentiate the passes sufficiently to have some kind post processing on some layers versus some other kind of post processing on other layers. But it might be possible to have post processing on some layers, and none on others.
Iāll post to this thread if/when I figure it out. Iām sure its possible probably just going to take a little bit of trial and error. In the meantime, if anyone else has any bright ideas please post them here!
Ok, so this isnāt actually too difficult to implement.
I made two cameras as overlay cameras and children of the main camera (one for each effect Iām looking for, could be done with just one camera if you only need one layer, dependent on your needs). Set the layer of these cameras to whatever layer they are going to be post-processing, along with setting the volume mask to the layer too. Now add these child overlay cameras to the base cameraās stack.
I set up my volumes as global volumes on the layer that I need them on.
From here, in your scripts, you can disable/enable the post-processing effects by changing the setActive of these overlay cameras.
If you have your particular gameObject that you want to be effected by a volume just change itās layer to the same layer and that effect should only appear on your specified gameObject, regardless of what your Virtual Cameras are up to. The virtual cameras just move the main camera so having these overlay cameras as children of the main camera means they will move with the Main Camera, ready to be disabled/enabled at any time.
Hope this helps! Included some screenshots to show my hierarchy and camera + volume settings.
How did you get Layers to be respected by Post Processing? No matter how I configure, ALL layers are always subjected to Post Processing, all at once.
2a. Is it only in URP that Post Processing Volume Layers become representative of Layers for Post Processing as well as their usage as āvolumesā of region for activation?
Ok, so if youāre on BiRP thereās a chance that none of what Iāve said is relevant, Iām only learning as I go here and not sure on the differences between the two pipelines, but I can answer some of your questions:
As I understand it, an overlay camera is a camera whose view sits in front of the main camera. So it could be used for things like showing a HUD or something like Samusā helmet in Metroid Prime, or in this case to have multiple post processing effects on the same view. If that doesnāt make sense do some googling about the camera stack in Unity, thereās a lot of useful info online. If you look at a cameraās properties in the inspector youāll see a āRender Typeā property and you can change your camera from base to overlay. Then the camera that you have as base has a Stack property which you can add overlay cameras to and change what order they render.
From messing around with this for a while now, I think the camera stack is your friend with this. Basically, all layers are usually effected by post processing but I think if you want a layer to not be effected then just place that overlay camera into the lowest spot in the camera stack so it renders after the other cameras and it should ignore post processing on every other layer. It does leave you with the unfortunate side effect of that layer being rendered āin frontā so taking my example in the pictures I put in earlier, if I have anything in the select layer that is behind an object in the fogged layer, the object in the select layer will still be visible, not ideal but in my case it didnāt really matter too much.
If youāre still struggling with this, try messing around with the culling mask, layer and volume mask of your cameras, as well as the layers of your volumes.
as for 2a. Iām not really sure what you mean, Iāve only used URP for this kind of stuff so itās all I know about Iām afraid.
My gut feeling is that the camera stack you talk of works inverse within BiRP⦠but thatās from a distant idea of what it might.
Sorry, Iām lost on ācamera stackā as I donāt know what/where this feature/functionality is.
I know of camera stacking, which is really a super shoddy way of rendering textures into one another within Unity, for UI overlays, as you say, but this was always a hack, with horrendous implications for performance.
So, when I googled camera stack unity, the first result is from the URP docs, so itās possible this is a part of URP the you might not have using BiRP. I havenāt noticed a performance dip using camera stacking so far but Iāve yet to run any profiler tests on it, Iāll keep an eye out for that, thanks!
I think this is about it. That camera stacking is just a nickname given to the process of rendering into textures and then plopping them as overlays of some sort, in some order (the stack). Theoretically, SRPs should make this controllable by the user, in better ways than was done within the brute force approaches of BiRP. So should be faster in URP as theyād (hopefully) make their own culling and batching systems work for each conglomerate of Layers in any given ācameraā of the āstackā of textures that are ultimately blended/overlayed.
But my faith in Unityās design and product management are pretty low.