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.
  6. ScaledEquirect: Display overlay as a 360-degree equirectangular sphere with a radius, centered at the location of the overlay.

Protected Fields

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

Fields

colorOffset : Vector4
Signature
Vector4 colorOffset
colorScale : Vector4
Signature
Vector4 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 compositionDepth
currentOverlayShape : OverlayShape
Specify overlay's shape.
Signature
OverlayShape currentOverlayShape
currentOverlayType : OverlayType
Specify overlay's type.
Signature
OverlayType currentOverlayType
destRectLeft : Rect
Signature
Rect destRectLeft
destRectRight : Rect
Signature
Rect destRectRight
externalSurfaceHeight : int
The height which will be used to create the external surface.
It's effective only on Android.
Signature
int externalSurfaceHeight
externalSurfaceObject : System.IntPtr
The Surface object (Android only).
Signature
System.IntPtr externalSurfaceObject
externalSurfaceObjectCreated : ExternalSurfaceObjectCreated
Will be triggered after externalSurfaceTextueObject get created.
Signature
ExternalSurfaceObjectCreated externalSurfaceObjectCreated
externalSurfaceWidth : int
The width which will be used to create the external surface.
It's effective only on Android.
Signature
int externalSurfaceWidth
hidden : bool
Signature
bool hidden
invertTextureRects : bool
Signature
bool invertTextureRects
isAlphaPremultiplied : bool
Signature
bool isAlphaPremultiplied
isDynamic : bool
If true, the texture's content is copied to the compositor each frame.
Signature
bool 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 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 isProtectedContent
layerTextureFormat : OVRPlugin.EyeTextureFormat
Signature
OVRPlugin.EyeTextureFormat 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 noDepthBufferTesting
overridePerLayerColorScaleAndOffset : bool
Signature
bool overridePerLayerColorScaleAndOffset
overrideTextureRectMatrix : bool
Signature
bool overrideTextureRectMatrix
srcRectLeft : Rect
Signature
Rect srcRectLeft
srcRectRight : Rect
Signature
Rect srcRectRight
textures : Texture[]
The left- and right-eye Textures to show in the layer.
Signature
Texture [] textures
useAutomaticFiltering : bool
Signature
bool useAutomaticFiltering
useBicubicFiltering : bool
Signature
bool useBicubicFiltering
useEfficientSharpen : bool
Signature
bool useEfficientSharpen
useEfficientSupersample : bool
Signature
bool useEfficientSupersample
useExpensiveSharpen : bool
Signature
bool useExpensiveSharpen
useExpensiveSuperSample : bool
Signature
bool useExpensiveSuperSample
useLegacyCubemapRotation : bool
Signature
bool useLegacyCubemapRotation

Protected Static Fields

cubeMaterial : readonly Material[]
Signature
readonly Material [] cubeMaterial
tex2DMaterial : Material
Signature
Material tex2DMaterial

Static Fields

instances : List< OVROverlay >
Signature
List<OVROverlay> instances

Protected Properties

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

Properties

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

Protected Methods

BlitSubImage ( src , width , height , mat , rect )
Signature
void BlitSubImage(Texture src, int width, int height, Material mat, Rect rect)
Parameters
src: Texture
width: int
height: int
mat: Material
rect: Rect
Returns
void
CreateLayer ( mipLevels , sampleCount , etFormat , flags , size , shape )
Signature
bool 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 CreateLayerTextures(bool useMipmaps, OVRPlugin.Sizei size, bool isHdr)
Parameters
useMipmaps: bool
size: OVRPlugin.Sizei
isHdr: bool
Returns
bool
DestroyLayer ()
Signature
void DestroyLayer()
Returns
void
DestroyLayerTextures ()
Signature
void DestroyLayerTextures()
Returns
void
GetBlitRect ( eyeId , width , height , invertRect )
Signature
Rect GetBlitRect(int eyeId, int width, int height, bool invertRect)
Parameters
eyeId: int
width: int
height: int
invertRect: bool
Returns
Rect
GetCurrentLayerDesc ()
Signature
OVRPlugin.LayerDesc GetCurrentLayerDesc()
Returns
OVRPlugin.LayerDesc
LatchLayerTextures ()
Signature
bool LatchLayerTextures()
Returns
bool
PopulateLayer ( mipLevels , isHdr , size , sampleCount , stage )
Signature
bool 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 SetupEditorPreview()
Returns
void
SubmitLayer ( overlay , headLocked , noDepthBufferTesting , pose , scale , frameIndex )
Signature
bool 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 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 OverrideOverlayTextureInfo(Texture srcTexture, IntPtr nativePtr, UnityEngine.XR.XRNode node)
Parameters
srcTexture: Texture
nativePtr: IntPtr
node: UnityEngine.XR.XRNode
Returns
void
ResetEditorPreview ()
Signature
void ResetEditorPreview()
Returns
void
SetPerLayerColorScaleAndOffset ( scale , offset )
Signature
void 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 SetSrcDestRects(Rect srcLeft, Rect srcRight, Rect destLeft, Rect destRight)
Parameters
srcLeft: Rect
srcRight: Rect
destLeft: Rect
destRight: Rect
Returns
void
UpdateTextureRectMatrix ()
Signature
void UpdateTextureRectMatrix()
Returns
void

Protected Static Methods

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

Static Methods

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

Inner Struct

LayerTexture Struct

Fields

appTexture : Texture
Signature
Texture appTexture
appTexturePtr : IntPtr
Signature
IntPtr appTexturePtr
swapChain : Texture[]
Signature
Texture [] swapChain
swapChainPtr : IntPtr[]
Signature
IntPtr [] 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
ScaledEquirect
OVRPlugin.OverlayShape.ScaledEquirect
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