Change LUT Texture in runtime

Hello everyone. I have a project using URP and a Global Volume with FX - like LUT (Color Correction). I am trying to create a script allowing me to change in-game the texture which is applied for the color correction, but the solution which I found doesn’t work properly. Do you know how I can reach my goal? Thanks for your help. I wish you the best ++

Done. I found the right semantic after many attempts. This way I can test in-game more than 300 LUT - and out of the inspector. Really useful. I share with you the code which works well as expected. I hope that it will help someone. use Keypad + and - to navigate between all textures which you have put in a single array ++

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering;

public class Gallery : MonoBehaviour
{
    public Texture[] myLUTs;
    private int index = 0;
    // my profile
    public VolumeProfile volumeProfile;
    private ColorLookup clu;

    void Start()
    {   // check every component
        for (int i = 0; i < volumeProfile.components.Count; i++)
        {   // handle on the Color Lookup component
            if (volumeProfile.components[i].name == "ColorLookup")
            {
                clu = (ColorLookup)volumeProfile.components[i];
                clu.texture.value = myLUTs[index];
            }
        }
        // no Color Lookup component?
        if (clu == null)
            this.enabled = false;
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.KeypadPlus))
        {   // increment index
            ++index;
            // check bound and select a new texture for the Color Lookup
            if (index > myLUTs.Length - 1)
                index = 0;
            // apply the new one
            clu.texture.value = myLUTs[index];
        }

        if (Input.GetKeyDown(KeyCode.KeypadMinus))
        {   // decrement index
            --index;
            // check bound and select a new texture for the Color Lookup
            if (index < 0)
                index = myLUTs.Length - 1;
            // apply the new one
            clu.texture.value = myLUTs[index];
        }
    }
    // simple info about texture name
    void OnGUI()
    {
        GUI.Label(new Rect(Screen.width - 200, Screen.height - (Screen.height / 14), Screen.width / 5, 5 * (Screen.height / 200)), clu.texture.value.name);
    }
}
1 Like