API reference
API reference
Select your platform
No SDKs available
No versions available

OVRPassthroughLayer Class

Extends MonoBehaviour
Represents a layer used for passthrough.
The Passthrough API enables you to show the user's real environment in your mixed reality experiences. It offers several options to customize the appearance of passthrough, such as adjusting opacity, highlight salient edges in the image, or control the color reproduction. For passthrough to be visible, it must be enabled in OVRManager via the OVRManager.isInsightPassthroughEnabled field.
Find out more about passthrough and its features or follow along with these tutorials.

Fields

colorMapEditorBrightness : float
This field is not intended for public scripting.
Signature
float colorMapEditorBrightness
colorMapEditorContrast : float
This field is not intended for public scripting.
Signature
float colorMapEditorContrast
colorMapEditorGradient : Gradient
This field is not intended for public scripting.
Use SetColorMapControls() instead.
Signature
Gradient colorMapEditorGradient
colorMapEditorPosterize : float
This field is not intended for public scripting.
Use SetColorMapControls() instead.
Signature
float colorMapEditorPosterize
colorMapEditorSaturation : float
This field is not intended for public scripting.
Signature
float colorMapEditorSaturation
colorOffset : Vector4
Color offset is a value which gets added to the pixel color values during compositing.
The four components of the vector correspond to the R, G, B, and A values, default set to {0,0,0,0}. This field is only applicable if overridePerLayerColorScaleAndOffset is set to 'true'.
Signature
Vector4 colorOffset
colorScale : Vector4
Color scale is a factor applied to the pixel color values during compositing.
The four components of the vector correspond to the R, G, B, and A values, default set to {1,1,1,1}. This field is only applicable if overridePerLayerColorScaleAndOffset is set to 'true'.
Signature
Vector4 colorScale
compositionDepth : int
DeprecatedDefines the order of the layers among all passthrough layers and OVROverlay instances. The layer with smaller compositionDepth is composited in the front of the layer with larger compositionDepth. The default value is zero.
Signature
int compositionDepth
hidden : bool
Hides the passthrough layer from view when true and pauses the system's passthrough system if there are no other visible passthrough layers.
Signature
bool hidden
DeprecatedSpecify whether passthrough should appear on top of (OverlayType.Overlay) or beneath (OverlayType.Underlay) the virtual content. The default is Underlay.
Signature
OVROverlay.OverlayType overlayType
overridePerLayerColorScaleAndOffset : bool
Specify whether colorScale and colorOffset field values should be applied to this layer.
By default, the color scale and offset are not applied to the layer.
Signature
bool overridePerLayerColorScaleAndOffset
passthroughLayerResumed : UnityEvent< OVRPassthroughLayer >
Occurs when a passthrough layer has been rendered and presented on the HMD screen for the first time after being restarted.
This event passes the reference to the current OVRPassthroughLayer passthrough layer to subscribers.
Signature
UnityEvent<OVRPassthroughLayer> passthroughLayerResumed
projectionSurfaceType : ProjectionSurfaceType
DeprecatedThe type of the surface which passthrough textures are projected on: Automatic reconstruction or user-defined geometry. This field can only be modified immediately after the component is instantiated (e.g. using AddComponent). Once the backing layer has been created, changes won't be reflected unless the layer is disabled and enabled again. Default is automatic reconstruction.
Signature
ProjectionSurfaceType projectionSurfaceType

Properties

colorMapEditorType : ColorMapEditorType
[Get][Set]
Editor attribute to get or set the selection in the inspector.
Using this selection will update the colorMapType and colorMapData if needed.
Signature
ColorMapEditorType colorMapEditorType
edgeColor : Color
[Get][Set]
Color for the edge rendering.
Signature
Color edgeColor
edgeRenderingEnabled : bool
[Get][Set]
Enables or disables edge rendering.
Use this flag to enable or disable the edge rendering but retain the previously selected color (incl. alpha) in the UI when it is disabled.
Signature
bool edgeRenderingEnabled
textureOpacity : float
[Get][Set]
Defines the passthrough opacity.
It can be used to blend between passthrough and VR when overlayType is set to OverlayType.Overlay, or to dim passthrough when overlayType is set toOverlayType.Underlay`. Value ranges from 0f to 1f.
Signature
float textureOpacity

Events

PassthroughLayerResumed : Action
DeprecatedOccurs when a passthrough layer has been rendered and presented on the HMD screen for the first time after being restarted.
Signature
Action PassthroughLayerResumed

Methods

AddSurfaceGeometry ( obj , updateTransform )
DeprecatedAdds a GameObject to the passthrough projection surface.
This is only applicable if projectionSurfaceType is set to UserDefined . Refer to Surface Projected Passthrough for more details.
When updateTransform parameter is set to true, current layer will update the transform of the surface mesh every frame. Otherwise only the initial transform is recorded.
Signature
void AddSurfaceGeometry(GameObject obj, bool updateTransform=false)
Parameters
obj: GameObject  The Gameobject you want to add to the Insight Passthrough projection surface.
updateTransform: bool  Indicate if the transform should be updated every frame
Returns
void
DisableColorMap ()
Disables any previously set color maps or color LUTs.
Signature
void DisableColorMap()
Returns
void
IsSurfaceGeometry ( obj )
DeprecatedChecks if the given gameobject is a surface geometry (If called with AddSurfaceGeometry).
Signature
bool IsSurfaceGeometry(GameObject obj)
Parameters
obj: GameObject
Returns
bool true if the GameObject has been added to the passthrough projection surface.
RemoveSurfaceGeometry ( obj )
DeprecatedRemoves a GameObject that was previously added using AddSurfaceGeometry from the projection surface.
Signature
void RemoveSurfaceGeometry(GameObject obj)
Parameters
obj: GameObject  The GameObject to remove.
Returns
void
SetBrightnessContrastSaturation ( brightness , contrast , saturation )
This method allows to configure brightness and contrast adjustment for Passthrough images.
Signature
void SetBrightnessContrastSaturation(float brightness=0.0f, float contrast=0.0f, float saturation=0.0f)
Parameters
brightness: float  Modify the brightness of Passthrough. Valid range: [-1, 1]. A value of 0 means that brightness is left unchanged.
contrast: float  Modify the contrast of Passthrough. Valid range: [-1, 1]. A value of 0 means that contrast is left unchanged.
saturation: float  Modify the saturation of Passthrough. Valid range: [-1, 1]. A value of 0 means that saturation is left unchanged.
Returns
void
SetColorLut ( lut , weight )
Applies a color look-up table (LUT) to the passthrough layer.
Color LUTs enable a wide range of effects, ranging from subtle color grading to stylizations such as posterization, selective coloring, and chroma keying. See Color Mapping Techniques for more details.
Signature
void SetColorLut(OVRPassthroughColorLut lut, float weight=1)
Parameters
lut: OVRPassthroughColorLut  An instance of OVRPassthroughColorLut containing the color LUT.
weight: float  Value between 0 and 1 which defines the blend between the original Passthrough colors and the LUT. If weight is 0, the appearance of Passthrough is unchanged. If weight is 1, the colors are fully taken from the LUT. Values between 0 and 1 lead to a linear interpolation between the original color and the LUT color. This value can be animated to create smooth transitions.
Returns
void
SetColorLut ( lutSource , lutTarget , weight )
Applies the interpolation between two color LUTs to the passthrough layer.
Use it to transition between two different color LUTs.
Signature
void SetColorLut(OVRPassthroughColorLut lutSource, OVRPassthroughColorLut lutTarget, float weight)
Parameters
lutSource: OVRPassthroughColorLut  An instance of OVRPassthroughColorLut containing the source color LUT
lutTarget: OVRPassthroughColorLut  An instance of OVRPassthroughColorLut containing the target color LUT
weight: float  Value between 0 and 1 which defines the blend between lutSource and lutTarget. The output color is computed as C_result = (1 - weight) * lutSource[C_in] + weight * lutTarget[C_in], where C_in represents the original Passthrough color. This value can be animated to create smooth transitions.
Returns
void
SetColorMap ( values )
This color map method allows to recolor the grayscale camera images by specifying a color lookup table.
Scripts should call the designated methods to set a color map. The fields and properties are only intended for the inspector UI.
Signature
void SetColorMap(Color[] values)
Parameters
values: Color[]  The color map as an array of 256 color values to map each grayscale input to a color.
Returns
void
SetColorMapControls ( contrast , brightness , posterize , gradient , colorMapType )
This method allows to generate (and apply) a color map from the set of controls which is also available in inspector.
Signature
void SetColorMapControls(float contrast, float brightness=0.0f, float posterize=0.0f, Gradient gradient=null, ColorMapEditorType colorMapType=ColorMapEditorType.GrayscaleToColor)
Parameters
contrast: float  The contrast value. Ranges from -1 (minimum) to 1 (maximum).
brightness: float  The brightness value. Ranges from -1 (minimum) to 1 (maximum).
posterize: float  The posterize value. Ranges from 0 to 1, where 0 = no posterization (no effect), 1 = reduce to two colors.
gradient: Gradient  The gradient will be evaluated from 0 (no intensity) to 1 (maximum intensity). This parameter only has an effect if colorMapType is GrayscaleToColor.
colorMapType: ColorMapEditorType  Type of color map which should be generated. Supported values: Grayscale and GrayscaleToColor.
Returns
void
SetColorMapMonochromatic ( values )
This method allows to specify the color map as an array of 256 8-bit intensity values.
Use this to map each grayscale input value to a grayscale output value.
Signature
void SetColorMapMonochromatic(byte[] values)
Parameters
values: byte[]  Array of 256 8-bit values.
Returns
void
SetStyleDirty ()
This method is required for internal use only.
Signature
void SetStyleDirty()
Returns
void

Inner Enums

ProjectionSurfaceType Enum

DeprecatedThe passthrough projection surface type: reconstructed | user defined.

Enumeration Constants

MemberDescription
Reconstructed
Reconstructed surface type will render passthrough using automatic environment depth reconstruction.
UserDefined
UserDefined allows you to define the projection surface manually, see Surface Projected Passthrough.

ColorMapEditorType Enum

Unity editor enumerator to provide a dropdown in the inspector.

Enumeration Constants

MemberValue
None
0
GrayscaleToColor
1
Controls
GrayscaleToColor
Custom
2
Grayscale
3
ColorAdjustment
4
ColorLut
5
InterpolatedColorLut
6