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.

[RESOLVED]Custom PostProcess always working, even if there is not Volume in scene.

Discussion in 'High Definition Render Pipeline' started by fubbi1000, Jan 16, 2020.

  1. fubbi1000

    fubbi1000

    Joined:
    Jul 14, 2018
    Posts:
    90
    I make a custom PostProcess. This is the csharp code.
    Screen Shot 2020-01-16 at 6.05.36 PM.png
    As you can see, I print some text at the first of Render method.
    Then I add my custom PostProcess to the injection point.
    Screen Shot 2020-01-16 at 6.09.21 PM.png
    At this time, My custom PostProcess already affect screen, even if there is not any Volume in scene.
    Screen Shot 2020-01-16 at 6.13.13 PM.png
    It's a empty scene.
    Some text I printed display in the Console.
    It means Render method always working, even if there is not any Volume in scene.

    Is it a bug or design?
    Thanks.
     
    minuskube and konsic like this.
  2. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    808
    I am interesting in that too.
     
  3. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    209
    Hello, by default the volume system instantiate one volume of each type with default values so there is never null or missing settings when we check for them via the volume stack in script.
    That explain why your custom post process effect is created even in an empty scene. Now the IsActive function in you custom post process is supposed to tell if the effect will be executed or not. If it returns false and the Render function is called then it's a bug
     
    minuskube likes this.
  4. fubbi1000

    fubbi1000

    Joined:
    Jul 14, 2018
    Posts:
    90
    Screen Shot 2020-01-16 at 11.41.26 PM.png
    @antoinel_unity Thanks. Maybe I know the reason now. My custom postprocess is running all the time because of m_Material variable never be null.

    Another confusion is how should I write code for IsActive function?

    My purpose is:
    If custom postprocess is not added to volume, it will not be executed.
    If toggle is off, it will not be execute.
    Screen Shot 2020-01-16 at 11.56.03 PM.png
     
  5. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    209
    You should put in the IsActive a code that returns false when the current settings of your post process wouldn't change anything (for example an intensity at 0).
    There are some examples here on how it's done with HDRP post processes:
    DOF: https://github.com/Unity-Technologi...ostProcessing/Components/DepthOfField.cs#L266
    Bloom: https://github.com/Unity-Technologi...ntime/PostProcessing/Components/Bloom.cs#L127
    etc.

    The toggle on the volume is a global toggle to disable all the overrides in the component, so there is no difference between a disabled component and an active component with all overrides disabled.
     
    minuskube and fubbi1000 like this.