Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Apply post processing to objects rendered by a specific camera only

Discussion in 'General Graphics' started by Noxalus, Nov 26, 2018.

  1. Noxalus

    Noxalus

    Joined:
    Jan 9, 2018
    Posts:
    80
    Hello everyone,

    I'm just trying to use the post processing stack of Unity for the first time, with the preview package version 2.0.17 and even with the help of the documentation I'm not able to achieve what I would like to do.

    My example is simple, I have a scene with 2 cubes:

    unity-pp-1.jpg

    And I want to apply a bloom effect to the cube to the right only. So what I've done is:
    - Change the layer of the right cube to PostProcessing
    - Update the Main Camera culling mask to only render Default layer
    - Create a copy of the Main Camera and change its culling mask to only render PostProcessing layer + the clear flags to Don't clear + change the depth from -1 to 1 to render after the Main Camera

    unity-pp-2.jpg


    unity-pp-3.jpg

    Now, for the post processing part, I've added a Post Process Layer component to the PostProcessCamera:

    unity-pp-4.jpg

    Then I've created a new game object with the PostProcessing layer on which I've added a Post Process Volume with its Is Global checkbox ticked. I then created a post process profile file with a bloom effect like that:

    unity-pp-5.jpg

    But in my scene, both cube are bloomed (I will ask you to believe me, I can't post more image :s).

    Do you know why? Did I do something wrong? How can I achieve what I want to do?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    The "Don't clear" option means whatever was rendered by previous cameras is used as the background. Thus, the second camera starts with the first cube and background already visible and the second cube just gets rendered on top. The post process effect still applies to everything, because everything is what the camera sees.

    Try stepping through using the Frame Debugger.

    There are a ton of threads on how to apply post processing to a limited set of objects on screen, but the TLDR version is you need to write custom post process effects to do this.
     
  3. Noxalus

    Noxalus

    Joined:
    Jan 9, 2018
    Posts:
    80
    Thank you for your answer @bgolus.

    Now that you said it, it's pretty logical indeed. If it's a hot topic, I will perform some searches, thank you again.
     
  4. DearUnityPleaseAddSerializableDictionaries

    DearUnityPleaseAddSerializableDictionaries

    Joined:
    Sep 12, 2014
    Posts:
    135
    Did you find a good way to solve this?
     
  5. Noxalus

    Noxalus

    Joined:
    Jan 9, 2018
    Posts:
    80
    Sorry, I don't remember why I needed to do that and how I fixed it.

    But if I had to apply bloom on a specific object today, I will probably use HDR with an Emissive color!
     
    Last edited: Oct 9, 2020
  6. DearUnityPleaseAddSerializableDictionaries

    DearUnityPleaseAddSerializableDictionaries

    Joined:
    Sep 12, 2014
    Posts:
    135
    I will learn this.

    I wanted to blur only one specific camera or sorting layer. It's a really hard problem.