Set Specific Color Space in Unity

Color is one of the core components that brings your app to life on an Oculus device. When dealing with colors, one of the challenges is that despite having the same color values, colors can vary with the change in displays and technologies, such as an LCD monitor and an OLED Oculus device. Differences yield in the form of low-level banding, hue shift, and under or over saturation of colors. Colors you see on the monitor during an app development may not essentially match with the ones you see on the target Oculus device. This is because different displays may use different color spaces and do not interpret the color values in the same way.

The following image illustrates the difference in color rendering between Rec 2020 and Rec 709.

What Is A Color Space?

Color space is a defined range of colors that facilitates color management. It defines the capabilities of a display device to reproduce colors based on the specific color information. For understanding purposes, they are typically graphed in reference to the industry-standard chromaticity diagram, which maps out all the color values that a human eye can perceive to x and y coordinates. In the diagram, the triangle represents the specific color space and its corners are called primaries, which represent the primary colors: Red, Green, and Blue. It charts the white point as D65. For detailed information about color management, go to Color and Brightness Mastering Guide.

Color Space Options

To overcome the color variation that may occur due to different color spaces in use, you can remaster your app by setting the specific color space at runtime for your Oculus device. The default color spaces of Oculus devices are:

  • Oculus Rift: Between Adobe RGB and DCI-P3
  • Oculus Rift S: Rec 709
  • Oculus Quest: Rec 2020

In addition to the standard color spaces, you have a choice to select custom Oculus-specific color spaces to master your apps for assets with different display technologies such as LCD vs. OLED. The following tables list the available color spaces and its primaries:

Standard color spaces:

Color SpaceRedGreenBlueWhite
Rec_2020(0.708, 0.292)(0.17, 0.797)(0.131, 0.046)D65 (0.313, 0.329)
Rec_709(0.640, 0.330)(0.292, 0.586)(0.156, 0.058)D65 (0.313, 0.329)
P3(0.680, 0.320)(0.265, 0.690)(0.150, 0.060)D65 (0.313, 0.329)
Adobe_RGB(0.640, 0.330)(0.210, 0.710)(0.150, 0.060)D65 (0.313, 0.329)

Custom color spaces:

Color SpaceRedGreenBlueWhite
Rift_CV1(0.666, 0.334)(0.238, 0.714)(0.139, 0.053)D75 (0.298, 0.318)
Rift_S(0.640, 0.330)(0.300, 0.600)(0.150, 0.060)D75 (0.298, 0.318)
Quest(0.6610, 0.3382)(0.2281, 0.7178)(0.1416, 0.0419)D75 (0.2956, 0.3168)

Set Color Space

The Oculus Integration unity package lets you override the color space of the Oculus device at runtime. When you enable the color gamut feature, it lets you fine tune and re-master colors on the target Oculus device for the entire app. If you prefer to use a color space for a specific scene only, set the color space programmatically.

Note: This is an optional setting. If you do not see any issues with the output from the default color space, do not use this setting. Leave it disabled to use the default color space of the Oculus device.

  1. In the Hierarchy view, select OVRCameraRig.
  2. In the Inspector view, under OVRManager > Display, select Enable Specific Color Gamut.

  3. From the Color Gamut list, select the color space you want your Oculus device to use at runtime. Options include:
    • Unknown: Returns the default value from GetHmdolorSpace() until SetClientColorDesc() is called.
    • Unmanaged: No color correction takes into effect as this option forces the runtime to skip color correction. It is mostly useful for research and experimentation, and should be avoided for software distribution.
    • Rec_2020: Default color space for Oculus Quest. It is the most preferred color space to standardize colors across all Oculus devices as it’s a wider color gamut when compared to the Rec. 709 color space.
    • Rec_709: Default color space for Oculus Rift S. It’s a narrow color gamut and commonly used by LCD panels. It shares the same primaries as the sRGB color space.
    • Rift_CV1: Custom color space. Primaries lie between P3 and Adobe RGB color spaces.
    • Rift_S: Custom color space. Same primaries as the Rec. 709 color space except it uses D75 white point.
    • Quest: Custom color space. Primaries lie between P3 and Adobe RGB color spaces.
    • P3: Same as the DCI-P3 standard color space.
    • Adobe_RGB: Wider color gamut and uses D65 white point.

Note: This feature only handles color-space remapping. Unless specified, all color spaces use D65 white point. It does not affect brightness, contrast, or gamma curves. Some of these aspects such as gamma is handled by the texture format being used. From the GPU samplers’ perspective, each texture continues to be treated as linear luminance including sRGB, which is converted to linear by the texture sampler.

Override Color Space Programmatically

To set the color space for a specific scene, call the color space APIs in your script instead of using the setting from the OVRManager. This is because when you set the color space from OVRManager, Oculus sets it for the entire app.

Get the default or current color space:

The OVRManager contains the nativeColorGamut and the colorGamut variables that store the headset’s default and current color space, respectively. Use either of these variables to retrieve the headset’s color space.

// Retrieves the current color space
OVRManager.ColorSpace CurrentColorSpace = OVRManager.colorGamut;
// Retrieves the default color space
OVRManager.ColorSpace HmdColorSpace = OVRManager.nativeColorGamut;

Set the color space:

To set the color space of your choice, assign a new value to the OVRPlugin.colorGamut variable.

OVRPlugin.colorGamut = OVRManager.ColorSpace.Rec_2020;

Available color space values are:

  • OVRManager.ColorSpace.Unknown
  • OVRManager.ColorSpace.Unmanaged
  • OVRManager.ColorSpace.Rec_2020
  • OVRManager.ColorSpace.Rec_709
  • OVRManager.ColorSpace.Rift_CV1
  • OVRManager.ColorSpace.Rift_S
  • OVRManager.ColorSpace.Quest
  • OVRManager.ColorSpace.P3
  • OVRManager.ColorSpace.Adobe_RGB