Search Unity

Question [Global volume] - How to change individual RGB values in a channel mixer by script?

Discussion in 'Universal Render Pipeline' started by B-Pingel, Nov 12, 2022.

  1. B-Pingel

    B-Pingel

    Joined:
    Apr 17, 2020
    Posts:
    13
    For example, I'd like to change the "red" value in a channel mixer. I managed to change the chromatic abberation intensity by script:
    Code (CSharp):
    1. CA.intensity.SetValue(new UnityEngine.Rendering.ClampedFloatParameter(caValue, 0, 1, true));
    How do I set values for channel mixers?
     
  2. B-Pingel

    B-Pingel

    Joined:
    Apr 17, 2020
    Posts:
    13
    By the way, for anyone wondering, here's a simple script that specifically changes chromatic abberation intensity.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Rendering;
    5. using UnityEngine.Rendering.Universal;
    6.  
    7. public class VolumeScript : MonoBehaviour
    8. {
    9.     [SerializeField]
    10.     private Volume volume;
    11.     private ChromaticAberration CA;
    12.  
    13.     private float caValue = 1f;
    14.  
    15.     void Start()
    16.     {
    17.         if (volume.profile.TryGet(out CA))
    18.         {
    19.             CA.intensity.SetValue(new UnityEngine.Rendering.ClampedFloatParameter(caValue, 0, 1, true));
    20.         }
    21.     }
    22. }