Develop
Develop
Select your platform

Passthrough Color LUT Tutorial

Updated: Jan 4, 2025
In this tutorial, you will modify the Passthrough Basic Tutorial to set up a simple color LUT (color look up table)-enhanced passthrough environment. Here are the steps:
Note: In this tutorial, we have both the OVRPassthroughLayer and the new script components attached to the OVRCameraRig. (The OVRPassthroughLayer is added and configured in the Passthrough Basic Tutorial).

Before You Begin

Create a New Scene

  1. In the Project tab, under the Assets folder, create a new folder named Passthrough Color LUT Tutorial, and then select it to make it the current folder for new objects.
  2. In the Project Hierarchy, right click SampleScene, and choose Save Scene As. Give the new scene a unique name, such as PassthroughColorLUTTutorial. This becomes the active scene in the Hierarchy.
  3. Remove any game objects from the scene, except for the Directional Light and OVRCameraRig.

Create the PassthroughColorLUTController Script

  1. On the top menu, go to Assets > Create > C# Script, and name it PassthroughColorLUTController.
  2. Double-click the new script to open it.
  3. Create a serialized Texture2D field by adding the following code snippet to the PassthroughColorLUTController class. Later, we will assign our Texture2D asset to it in the Inspector.
    [SerializeField]
    private Texture2D _2dColorLUT;
    public Texture2D ColorLUT2D => _2dColorLUT;
    
  4. In the Start script, we want to instantiate the OVRCameraRig, the OVRPassthroughLayer, and the Texture2D object.
    private OVRPassthroughColorLut ovrpcl;
    private OVRPassthroughLayer passthroughLayer;
    
    void Start()
    {
        OVRCameraRig ovrCameraRig = FindObjectOfType<OVRCameraRig>();
        if (ovrCameraRig == null)
        {
            Debug.LogError("Scene does not contain an OVRCameraRig");
            return;
        }
    
        passthroughLayer = ovrCameraRig.GetComponent<OVRPassthroughLayer>();
        if (passthroughLayer == null)
        {
            Debug.LogError("OVRCameraRig does not contain an OVRPassthroughLayer component");
            return;
        }
    
        ovrpcl = new OVRPassthroughColorLut(_2dColorLUT, flipY: false);
        passthroughLayer.SetColorLut(ovrpcl, weight: 1);
    }
    
    For this tutorial, the relevant action is setting the passed-in LUT image into the passthrough layer. When we create the color LUT object, we specify the passed-in LUT image, and a value of false for flipY (the image we will use is already flipped -- that is, the solid black portion of the image is to the lower right).
    When we call SetColorLut, we provide the passed-in LUT image, and a weight value of 1, since we want the colors to be taken fully from the LUT.
  5. Save the script.

Assign the Script to OVRCameraRig

  1. In the Hierarchy window, click OVRCameraRig.
  2. In the Inspector, scroll to the bottom and choose Add Component.
  3. Search for the PassthroughColorLUTController and add it.

Add the Color LUT Texture2D to PassthroughColorLUTController

  1. In the Inspector, expand the Passthrough Color LUT Controller component.
  2. Save the following inverted-lut image to your Assets folder. This image comes from the Starter Samples project. Make sure the Compression value of the asset is set to None. inverted-lut file
  3. Drag the inverted-lut asset to the Passthrough Color LUT Controller component 2d Color LUT field.
Your project should resemble the following figure:
Assign the Script to OVRCameraRig

Alternatively, Assign Color LUT Texture directly to OVRPassthroughLayer

You can achieve the same outcome without utilizing a separate script, PassthroughColorLUTController, by directly assigning the Color LUT texture to the OVRPassthroughLayer component.
  1. In the Hierarchy window, click OVRCameraRig.
  2. In the Inspector, expand the OVR Passthrough Layer component.
  3. In the Color Control dropdown, choose Color LUT.
  4. Drag the inverted-lut asset to the OVR Passthrough Layer component LUT field. If prompted, select Fix image compression.

Save, Build, and Run the Project

  1. On the top menu, go to File > Save, and then go to File > Save Project.
  2. On the top menu, go to File > Build Settings to open the settings window.
  3. Remove the previous scenes from the Scenes in Build pane. Then click Add Open Scenes. Only your new PassthroughColorLUTTutorial should be in the build.
  4. Make sure that the Run Device is set to Meta Quest headset that is connected via USB cable.
  5. Click Build and Run.
  6. Save the .APK file.
  7. Put on the headset to test the color effect. Your passthrough environment should resemble the following figure:
    Passthrough Color LUT tutorial output

Reference: The Full Passthrough Color LUT Controller Script

For your reference, here is the full controller script.
using UnityEngine;

public class PassthroughColorLUTController : MonoBehaviour
{
    [SerializeField]
    private Texture2D _2dColorLUT;
    public Texture2D ColorLUT2D => _2dColorLUT;
    private OVRPassthroughColorLut ovrpcl;
    private OVRPassthroughLayer passthroughLayer;

    void Start()
    {
        OVRCameraRig ovrCameraRig = FindObjectOfType<OVRCameraRig>();
        if (ovrCameraRig == null)
        {
            Debug.LogError("Scene does not contain an OVRCameraRig");
            return;
        }

        passthroughLayer = ovrCameraRig.GetComponent<OVRPassthroughLayer>();
        if (passthroughLayer == null)
        {
            Debug.LogError("OVRCameraRig does not contain an OVRPassthroughLayer component");
            return;
        }

        ovrpcl = new OVRPassthroughColorLut(_2dColorLUT, flipY: false);
        passthroughLayer.SetColorLut(ovrpcl, weight: 1);
    }

    void Update()
    {
    }
}
Did you find this page helpful?