Search Unity

Question Using multiple cameras for layer post processing

Discussion in 'General Graphics' started by robdood, Jan 26, 2021.

  1. robdood

    robdood

    Joined:
    Jan 18, 2021
    Posts:
    14
    Hi - super newb here so please empathise if I'm doing something totally stupid. :D


    So here's the setup. I have a 2.5D game where I'm trying to use post processing to get a bit of depth of field in the background, and also apply a vignette to the whole screen.

    First I set up the depth of field. I did this by:
    1. setting my main camera's culling mask to draw everything except objects on the background layer and the post process layer. I have left this camera on the 'default' object layer. I set it's clear flags to 'don't clear' - i.e. so everything else is blank space. It gives me something like this:
      upload_2021-1-26_23-22-26.png
    2. created a child camera called for depth of field. this one only draws the background objects layer, and the post processing layer I created, that the postprocess volume uses. I set its clear flag to solid colour as that's how I want it to look. on it's own it looks like this:
      upload_2021-1-26_23-26-32.png
    3. So combined I get:
      upload_2021-1-26_23-27-47.png
    4. I tried adding a vignette to the same post process volume as the depth of field, but (understandably) it's 'hidden' behind the foreground layer because that camera doesn't draw the foreground. e.g.:
      upload_2021-1-26_23-31-24.png
    5. So I created another child camera (parent = depth of field camera) and set up the vignette. Clear flags: don't clear (keep what's underneath). Culling mask: nothing (i.e. draw the vignette on top of all objects). And this is where I get confused. It shows in the editor's game window as I'd expect:
      upload_2021-1-26_23-39-48.png
    6. but when I run the game it only seems to appear at top half of the screen (this also happens in the editor's game view when I disable/re enable the main camera..) i.e. just like the screenshot in step 4 above.
    Sooooo... I've spent an hour trying different combination of layers/clear flags and even reordering the cameras but it still doesn't seem to be making a difference.

    Can anyone advise on what I'm doing wrong? Turning the cameras on and off seems ot cause all sort of weird editor game display bugs, the only 'true' way to display it seems to be by running my scene.

    Does camera hierarchy matter for this? Would making another post process layer help? (why did I only just think of that!?! Going to try it now) EDIT - nah making two post process layers didn't work.

    Any help greatly appreciated! :)
     
    Last edited: Jan 26, 2021