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

Accessing HDRP's Volume in script

Discussion in 'High Definition Render Pipeline' started by saifshk17, Oct 11, 2020.

  1. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    HDRP uses Volume for post processing. I am trying to access this feature in my C# script. I can however access the Depth Of Field attribute, how do I access the Near Blur and Far Blur values?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Rendering;
    5. using UnityEngine.Rendering.HighDefinition;
    6.  
    7. public class LimitDepthOfField : MonoBehaviour {
    8.    
    9.     public Volume postProcessVolume;
    10.     DepthOfField dof;
    11.     // Start is called before the first frame update
    12.     void Start () {
    13.  
    14.     }
    15.  
    16.     void ChangeValue() {
    17.             if (postProcessVolume.profile.TryGet<DepthOfField> (out DepthOfField tempB)) {
    18.                dof = tempB;
    19.                //Access FarBlur Start Value
    20.             }
    21.     }
    22. }
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Those are all just properties of the dof object you have. For example,
    dof.farFocusEnd.value
    If you wanted to change one of the values, you'd use the Override method:
    dof.farFocusEnd.Override(someNewValue)