Color Mapping Techniques
Color Map Type lets you choose from number of different techniques to map each input color to a different output color. The following options are available:
- None: Display passthrough images unchanged.
- Color Adjustment: Adjust the image’s brightness, contrast, and saturation. Saturation adjustment only has an effect on devices that support color passthrough.
- Grayscale: Adjust brightness and contrast and apply a posterization effect to grayscale passthrough images. Color passthrough images are converted to grayscale first if this option is chosen.
- Grayscale To Color: Colorize grayscale passthrough images, adjust brightness and contrast, and apply a posterization effect. Color passthrough images are converted to grayscale first if this option is chosen.
- Color LUT: Apply a color look-up table (LUT), which maps each RGB input color into an arbitrary RGB(A) in the passthrough image stream.
- Interpolated Color LUTs: Apply the blend between two color LUTs to the passthrough image stream. This option can be used to smoothly transition between two color LUTs.
Grayscale and Grayscale To Color options are provided for compatibility. Prefer using Color Adjustments or color LUTs to build apps that can leverage color passthrough. You can check if the current device supports color passthrough using IsColorPassthroughSupported
from Oculus Library and adjust the styling accordingly:
Color Look-Up Tables (LUTs)
A color LUT is a 3D array which maps each RGB color to an arbitrary new RGB(A) color. Color LUTs enable a wide range of effects, ranging from subtle color grading to stylizations such as posterization, selective coloring, and chroma keying.
To apply a color LUT via Inspector, do the following:
- In the
OculusXRPassthroughLayer
Inspector, locate Stereo Layer Shape. - Under Color Map Type, select Color LUT.
- Under Color LUT Source, select an UOculusXRPassthroughColorLut asset or create a new one.
- The LUT Weight slider controls the blend between the original colors and the LUT. You can use Blueprints to create smooth transitions.
- To customize UOculusXRPassthroughColorLut, open the inspector.
- In the inspector, under Color LUT Type, select Texture.
- Under LUT Texture, select a texture for which
Texture Group
is set to Color Lookup Table
(referred to as “LUT texture” in this document). See Creating Color LUTs for more information on supported formats and how to generate them. Color LUTs built for Unreal Engine’s native color grading capabilities are compatible.
To apply a color LUT via Blueprints, you can use the following functions:
- Set Color LUT Source: Sets the color LUT on a passthrough layer (source color LUT when Color Map Type is Interpolated Color LUTs).
- Set Color LUT Target: Sets the target color LUT on a passthrough layer. Only applicable when Color Map Type is Interpolated Color LUTs.
- Set Color LUT Weight: Sets the LUT weight on a passthrough layer.
- Remove Color LUT: Remove the application of any color LUT on a passthrough layer.
Color LUTs and other other color mapping features are mutually exclusive. Calling any of these functions will replace the color map defined in a previous call.
There is a constraint on the maximum resolution allowed for color LUTs, which can be queried using UOculusXRPassthroughColorLut::GetMaxResolution
method. On current Meta Quest devices, the maximum resolution is 64. The color LUT resolution impacts memory usage and GPU performance. For that reason, it is advisable to keep the resolution as small as possible given use case and quality constraints. For example, start with a color LUT of resolution 16, then check if increasing the resolution to 32 significantly improves the visual quality.
Animating Color LUT Transitions To fade a Color LUT in or out, or transition between two different color LUTs, call Set Color LUT Weight with different value for LUT Weight during transition. Note, before chaning LUT Weight Color LUT Source and Target (if lColor Map Type is Interpolated Color LUTs) should be set to desired values. Set Color LUT Weight is a lightweight operation that doesn’t add a lot of overhead and can be called in every frame.
Animating Color LUT Contents Some use cases require color LUTs to change continuously beyond linear interpolation. For example, an app could dynamically adjust the saturation of different color hues based on the state of the app or external input (such as audio).
To change the color LUT object in the Blueprints, use the function Set LUT From Array. The LUT data must be defined as a 3D color array. The color values are laid out “blue-major”, that is, the resulting color value for an input color triplet (R, G, B) in range [0, Resolution]
must be stored at the index LUT[R + G * Resolution + B * Resolution * Resolution]
.
The updated data will automatically be used on all passthrough layers that are currently using that OVRPassthroughColorLut
instance. There is no need to call Set Color LUT Source
or Set Color LUT Target
to propagate the changes.
If the target color LUT was previously using a texture source, the texture source will be overwritten.
For high resolution color LUTs (especially 64^3), calling Set LUT From Array in every frame can have a notable impact on app performance. Try to keep the LUTs as small as possible in such cases - a resolution of 32^3 or lower is recommended.