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

OVROverlay Class

Extends MonoBehaviour
Add OVROverlay script to an object with an optional mesh primitive rendered as a TimeWarp overlay instead by drawing it into the eye buffer.
This will take full advantage of the display resolution and avoid double resampling of the texture.
We support 3 types of Overlay shapes right now
  1. Quad : This is most common overlay type , you render a quad in Timewarp space.
  2. Cylinder: [Mobile Only][Experimental], Display overlay as partial surface of a cylinder
    • The cylinder's center will be your game object's center
    • We encoded the cylinder's parameters in transform.scale, **[scale.z] is the radius of the cylinder **[scale.y] is the height of the cylinder **[scale.x] is the length of the arc of cylinder
    • Limitations **Only the half of the cylinder can be displayed, which means the arc angle has to be smaller than 180 degree, [scale.x] / [scale.z] <= PI **Your camera has to be inside of the inscribed sphere of the cylinder, the overlay will be faded out automatically when the camera is close to the inscribed sphere's surface. **Translation only works correctly with vrDriver 1.04 or above
  3. Cubemap: Display overlay as a cube map
  4. OffcenterCubemap: [Mobile Only] Display overlay as a cube map with a texture coordinate offset
    • The actually sampling will looks like [color = texture(cubeLayerSampler, normalize(direction) + offset)] instead of [color = texture( cubeLayerSampler, direction )]
    • The extra center offset can be feed from transform.position
    • Note: if transform.position's magnitude is greater than 1, which will cause some cube map pixel always invisible Which is usually not what people wanted, we don't kill the ability for developer to do so here, but will warn out.
  5. Equirect: Display overlay as a 360-degree equirectangular skybox.

Protected Fields

frameIndex : int
Signature
int OVROverlay.frameIndex
isOverridePending : bool
Signature
bool OVROverlay.isOverridePending
layerDesc : OVRPlugin.LayerDesc
Signature
OVRPlugin.LayerDesc OVROverlay.layerDesc
layerIdHandle : GCHandle
Signature
GCHandle OVROverlay.layerIdHandle
layerIdPtr : IntPtr
Signature
IntPtr OVROverlay.layerIdPtr
layerIndex : int
Signature
int OVROverlay.layerIndex
layerTextures : LayerTexture[]
Signature
LayerTexture [] OVROverlay.layerTextures
prevFrameIndex : int
Signature
int OVROverlay.prevFrameIndex
rend : Renderer
Signature
Renderer OVROverlay.rend
stageCount : int
Signature
int OVROverlay.stageCount
texturePtrs : IntPtr[]
Signature
IntPtr [] OVROverlay.texturePtrs

Fields

colorOffset : Vector4
Signature
Vector4 OVROverlay.colorOffset
colorScale : Vector4
Signature
Vector4 OVROverlay.colorScale
compositionDepth : int
The compositionDepth defines the order of the OVROverlays in composition.
The overlay/underlay with smaller compositionDepth would be composited in the front of the overlay/underlay with larger compositionDepth.
Signature
int OVROverlay.compositionDepth
currentOverlayShape : OverlayShape
Specify overlay's shape.
Signature
OverlayShape OVROverlay.currentOverlayShape
currentOverlayType : OverlayType
Specify overlay's type.
Signature
OverlayType OVROverlay.currentOverlayType
destRectLeft : Rect
Signature
Rect OVROverlay.destRectLeft
destRectRight : Rect
Signature
Rect OVROverlay.destRectRight
externalSurfaceHeight : int
The height which will be used to create the external surface.
It's effective only on Android.
Signature
int OVROverlay.externalSurfaceHeight
externalSurfaceObject : System.IntPtr
The Surface object (Android only).
Signature
System.IntPtr OVROverlay.externalSurfaceObject
externalSurfaceObjectCreated : ExternalSurfaceObjectCreated
Will be triggered after externalSurfaceTextueObject get created.
Signature
ExternalSurfaceObjectCreated OVROverlay.externalSurfaceObjectCreated
externalSurfaceWidth : int
The width which will be used to create the external surface.
It's effective only on Android.
Signature
int OVROverlay.externalSurfaceWidth
hidden : bool
Signature
bool OVROverlay.hidden
invertTextureRects : bool
Signature
bool OVROverlay.invertTextureRects
isAlphaPremultiplied : bool
Signature
bool OVROverlay.isAlphaPremultiplied
isDynamic : bool
If true, the texture's content is copied to the compositor each frame.
Signature
bool OVROverlay.isDynamic
isExternalSurface : bool
If true, the layer will be created as an external surface.
externalSurfaceObject contains the Surface object. It's effective only on Android.
Signature
bool OVROverlay.isExternalSurface
isProtectedContent : bool
If true, the layer would be used to present protected content (e.g.
HDCP), the content won't be shown in screenshots or recordings.
Signature
bool OVROverlay.isProtectedContent
layerTextureFormat : OVRPlugin.EyeTextureFormat
Signature
OVRPlugin.EyeTextureFormat OVROverlay.layerTextureFormat
noDepthBufferTesting : bool
The noDepthBufferTesting will stop layer's depth buffer compositing even if the engine has "Depth buffer sharing" enabled on Rift.
Signature
bool OVROverlay.noDepthBufferTesting
overridePerLayerColorScaleAndOffset : bool
Signature
bool OVROverlay.overridePerLayerColorScaleAndOffset
overrideTextureRectMatrix : bool
Signature
bool OVROverlay.overrideTextureRectMatrix
srcRectLeft : Rect
Signature
Rect OVROverlay.srcRectLeft
srcRectRight : Rect
Signature
Rect OVROverlay.srcRectRight
textures : Texture[]
The left- and right-eye Textures to show in the layer.
Signature
Texture [] OVROverlay.textures
useAutomaticFiltering : bool
Signature
bool OVROverlay.useAutomaticFiltering
useBicubicFiltering : bool
Signature
bool OVROverlay.useBicubicFiltering
useEfficientSharpen : bool
Signature
bool OVROverlay.useEfficientSharpen
useEfficientSupersample : bool
Signature
bool OVROverlay.useEfficientSupersample
useExpensiveSharpen : bool
Signature
bool OVROverlay.useExpensiveSharpen
useExpensiveSuperSample : bool
Signature
bool OVROverlay.useExpensiveSuperSample
useLegacyCubemapRotation : bool
Signature
bool OVROverlay.useLegacyCubemapRotation

Protected Static Fields

cubeMaterial : Material
Signature
Material OVROverlay.cubeMaterial
tex2DMaterial : Material
Signature
Material OVROverlay.tex2DMaterial

Static Fields

instances : OVROverlay[]
Signature
OVROverlay [] OVROverlay.instances

Protected Properties

layout : OVRPlugin.LayerLayout
[Get]
Signature
OVRPlugin.LayerLayout OVROverlay.layout
texturesPerStage : int
[Get]
Signature
int OVROverlay.texturesPerStage

Properties

isOverlayVisible : bool
[Get]
Signature
bool OVROverlay.isOverlayVisible
layerId : int
[Get]
Signature
int OVROverlay.layerId
OpenVROverlayKey : string
[Get]
Signature
string OVROverlay.OpenVROverlayKey
previewInEditor : bool
[Get][Set]
Preview the overlay in the editor using a mesh renderer.
Signature
bool OVROverlay.previewInEditor

Protected Methods

BlitSubImage ( src , dst , mat , rect , invertRect )
Signature
void OVROverlay.BlitSubImage(Texture src, RenderTexture dst, Material mat, Rect rect, bool invertRect=false)
Parameters
src: Texture
dst: RenderTexture
mat: Material
rect: Rect
invertRect: bool
Returns
void
CreateLayer ( mipLevels , sampleCount , etFormat , flags , size , shape )
Signature
bool OVROverlay.CreateLayer(int mipLevels, int sampleCount, OVRPlugin.EyeTextureFormat etFormat, int flags, OVRPlugin.Sizei size, OVRPlugin.OverlayShape shape)
Parameters
mipLevels: int
sampleCount: int
etFormat: OVRPlugin.EyeTextureFormat
flags: int
size: OVRPlugin.Sizei
shape: OVRPlugin.OverlayShape
Returns
bool
CreateLayerTextures ( useMipmaps , size , isHdr )
Signature
bool OVROverlay.CreateLayerTextures(bool useMipmaps, OVRPlugin.Sizei size, bool isHdr)
Parameters
useMipmaps: bool
size: OVRPlugin.Sizei
isHdr: bool
Returns
bool
DestroyLayer ()
Signature
void OVROverlay.DestroyLayer()
Returns
void
DestroyLayerTextures ()
Signature
void OVROverlay.DestroyLayerTextures()
Returns
void
GetBlitRect ( eyeId )
Signature
Rect OVROverlay.GetBlitRect(int eyeId)
Parameters
eyeId: int
Returns
Rect
GetCurrentLayerDesc ()
Signature
OVRPlugin.LayerDesc OVROverlay.GetCurrentLayerDesc()
Returns
OVRPlugin.LayerDesc
LatchLayerTextures ()
Signature
bool OVROverlay.LatchLayerTextures()
Returns
bool
PopulateLayer ( mipLevels , isHdr , size , sampleCount , stage )
Signature
bool OVROverlay.PopulateLayer(int mipLevels, bool isHdr, OVRPlugin.Sizei size, int sampleCount, int stage)
Parameters
mipLevels: int
isHdr: bool
size: OVRPlugin.Sizei
sampleCount: int
stage: int
Returns
bool
SetupEditorPreview ()
Signature
void OVROverlay.SetupEditorPreview()
Returns
void
SubmitLayer ( overlay , headLocked , noDepthBufferTesting , pose , scale , frameIndex )
Signature
bool OVROverlay.SubmitLayer(bool overlay, bool headLocked, bool noDepthBufferTesting, OVRPose pose, Vector3 scale, int frameIndex)
Parameters
overlay: bool
headLocked: bool
noDepthBufferTesting: bool
pose: OVRPose
scale: Vector3
frameIndex: int
Returns
bool

Methods

ExternalSurfaceObjectCreated ()
Signature
delegate void OVROverlay.ExternalSurfaceObjectCreated()
Returns
delegate void
OverrideOverlayTextureInfo ( srcTexture , nativePtr , node )
Use this function to set texture and texNativePtr when app is running GetNativeTexturePtr is a slow behavior, the value should be pre-cached.
Signature
void OVROverlay.OverrideOverlayTextureInfo(Texture srcTexture, IntPtr nativePtr, UnityEngine.XR.XRNode node)
Parameters
srcTexture: Texture
nativePtr: IntPtr
node: UnityEngine.XR.XRNode
Returns
void
ResetEditorPreview ()
Signature
void OVROverlay.ResetEditorPreview()
Returns
void
SetPerLayerColorScaleAndOffset ( scale , offset )
Signature
void OVROverlay.SetPerLayerColorScaleAndOffset(Vector4 scale, Vector4 offset)
Parameters
scale: Vector4
offset: Vector4
Returns
void
SetSrcDestRects ( srcLeft , srcRight , destLeft , destRight )
Sets the source and dest rects for both eyes.
Source explains what portion of the source texture is used, and dest is what portion of the destination texture is rendered into.
Signature
void OVROverlay.SetSrcDestRects(Rect srcLeft, Rect srcRight, Rect destLeft, Rect destRight)
Parameters
srcLeft: Rect
srcRight: Rect
destLeft: Rect
destRight: Rect
Returns
void
UpdateTextureRectMatrix ()
Signature
void OVROverlay.UpdateTextureRectMatrix()
Returns
void

Protected Static Methods

NeedsTexturesForShape ( shape )
Signature
static bool OVROverlay.NeedsTexturesForShape(OverlayShape shape)
Parameters
Returns
bool

Static Methods

IsPassthroughShape ( shape )
Signature
static bool OVROverlay.IsPassthroughShape(OverlayShape shape)
Parameters
Returns
bool

Inner Struct

LayerTexture Struct

Fields

appTexture : Texture
Signature
Texture OVROverlay.LayerTexture.appTexture
appTexturePtr : IntPtr
Signature
IntPtr OVROverlay.LayerTexture.appTexturePtr
swapChain : Texture[]
Signature
Texture [] OVROverlay.LayerTexture.swapChain
swapChainPtr : IntPtr[]
Signature
IntPtr [] OVROverlay.LayerTexture.swapChainPtr

Inner Enums

OverlayShape Enum

Determines the on-screen appearance of a layer.

Enumeration Constants

MemberValue
Quad
OVRPlugin.OverlayShape.Quad
Cylinder
OVRPlugin.OverlayShape.Cylinder
Cubemap
OVRPlugin.OverlayShape.Cubemap
OffcenterCubemap
OVRPlugin.OverlayShape.OffcenterCubemap
Equirect
OVRPlugin.OverlayShape.Equirect
ReconstructionPassthrough
OVRPlugin.OverlayShape.ReconstructionPassthrough
SurfaceProjectedPassthrough
OVRPlugin.OverlayShape.SurfaceProjectedPassthrough
Fisheye
OVRPlugin.OverlayShape.Fisheye
KeyboardHandsPassthrough
OVRPlugin.OverlayShape.KeyboardHandsPassthrough
KeyboardMaskedHandsPassthrough
OVRPlugin.OverlayShape.KeyboardMaskedHandsPassthrough

OverlayType Enum

Whether the layer appears behind or infront of other content in the scene.

Enumeration Constants

Member
None
Underlay
Overlay