Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is it possible to apply bloom only to a UI and not the game beneath?

Discussion in 'Image Effects' started by sarahnorthway, Aug 8, 2019.

  1. sarahnorthway

    sarahnorthway

    Joined:
    Jul 16, 2015
    Posts:
    78
    I'm using a 2-camera setup. Top camera sees UI on UI layer, bottom camera sees the rest of the game. I'd like my semi-transparent UI to glow using something like a bloom effect.

    I know it's possible to only apply bloom to the bottom camera by attaching a PostProcessingVolume and Layer to it with Global = true and Layer = nothing.

    But my attempts to move it to the top camera have failed. Either everything glows or nothing glows. Am I doing something wrong or misunderstanding how bloom works?
     
  2. Namey5

    Namey5

    Joined:
    Jul 5, 2013
    Posts:
    188
    Post processing is applied directly to the render target of the selected camera. In a multi-cam setup like yours, the bottom camera is drawn like normal. Ordinarily, once we're finished with that, the render buffer would be cleared so that we can draw new stuff without the old stuff bleeding in. However, you can change the clear mode such that we can store whatever is drawn first, then draw over the top of it with a new camera and effectively combine the two. This means that while yes, the two are separate entities, the final render target which is used for post processing and display on screen contains all the information from both cameras combined.

    In order to separate this process to apply post processing to a single camera, you would need to draw the top camera to a render texture with said post processing applied - making sure to set the camera's clear flags to "background colour" and the colour itself to something transparent (i.e. RGBA [0,0,0,0]). Then you would need to write (what is essentially) a custom post processing script that applies the UI back over the top of the bottom camera. That is how I would go about doing it (whether it would be as simple as that, I have no idea - I tend not to mess with clear flags and combining cameras). You might even be better off applying the bloom straight onto the UI itself, rather than using post processing.
     
    sarahnorthway likes this.