Class XRPass
XRPass holds the render target information and a list of XRView. XRView contains the parameters required to render (projection and view matrices, viewport, etc) When a pass has 2 views or more, single-pass will be active if the platform supports it. To avoid allocating every frame, XRView is a struct and XRPass is pooled.
Inherited Members
Namespace: UnityEngine.Experimental.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public class XRPass
Constructors
XRPass()
Parameterless constructor. Note: in order to avoid GC, the render pipeline should use XRPass.Create instead of this method.
Declaration
public XRPass()
Properties
copyDepth
If true, the render pipeline is expected to output a valid depth buffer to the renderTarget.
Declaration
public bool copyDepth { get; }
Property Value
| Type | Description |
|---|---|
| bool |
cullingParams
Parameters used for culling.
Declaration
public ScriptableCullingParameters cullingParams { get; }
Property Value
| Type | Description |
|---|---|
| ScriptableCullingParameters |
cullingPassId
Index used for culling. It can be shared between multiple passes.
Declaration
public int cullingPassId { get; }
Property Value
| Type | Description |
|---|---|
| int |
enabled
Returns true if the pass contains at least one view.
Declaration
public bool enabled { get; }
Property Value
| Type | Description |
|---|---|
| bool |
foveatedRenderingInfo
Native pointer from the XR plugin to be consumed by ConfigureFoveatedRendering.
Declaration
public IntPtr foveatedRenderingInfo { get; }
Property Value
| Type | Description |
|---|---|
| IntPtr |
hasMotionVectorPass
If true, the render pipeline is expected to generate motion data and output to the motionVectorRenderTarget.
Declaration
public bool hasMotionVectorPass { get; }
Property Value
| Type | Description |
|---|---|
| bool |
hasValidOcclusionMesh
Returns true if the pass was setup with expected mesh and material.
Declaration
public bool hasValidOcclusionMesh { get; }
Property Value
| Type | Description |
|---|---|
| bool |
hasValidVisibleMesh
Returns true if the pass was setup with expected mesh and enabled by settings.
Declaration
public bool hasValidVisibleMesh { get; }
Property Value
| Type | Description |
|---|---|
| bool |
hdrDisplayOutputColorGamut
Returns color gamut of the active HDR display.
Declaration
public ColorGamut hdrDisplayOutputColorGamut { get; }
Property Value
| Type | Description |
|---|---|
| ColorGamut |
hdrDisplayOutputInformation
Returns HDR display information of the active HDR display.
Declaration
public HDROutputUtils.HDRDisplayInformation hdrDisplayOutputInformation { get; }
Property Value
| Type | Description |
|---|---|
| HDROutputUtils.HDRDisplayInformation |
isFirstCameraPass
If true, is the first pass of a xr camera
Declaration
public bool isFirstCameraPass { get; }
Property Value
| Type | Description |
|---|---|
| bool |
isHDRDisplayOutputActive
Returns true when the active display has HDR enabled.
Declaration
public bool isHDRDisplayOutputActive { get; }
Property Value
| Type | Description |
|---|---|
| bool |
isLastCameraPass
If true, is the last pass of a xr camera
Declaration
public bool isLastCameraPass { get; }
Property Value
| Type | Description |
|---|---|
| bool |
motionVectorRenderTarget
Destination render target for motion vectors
Declaration
public RenderTargetIdentifier motionVectorRenderTarget { get; }
Property Value
| Type | Description |
|---|---|
| RenderTargetIdentifier |
motionVectorRenderTargetDesc
Destination render target descriptor for motion vectors.
Declaration
public RenderTextureDescriptor motionVectorRenderTargetDesc { get; }
Property Value
| Type | Description |
|---|---|
| RenderTextureDescriptor |
multipassId
Index of the pass inside the frame.
Declaration
public int multipassId { get; }
Property Value
| Type | Description |
|---|---|
| int |
occlusionMeshScale
Scaling factor used when drawing the occlusion mesh.
Declaration
public float occlusionMeshScale { get; }
Property Value
| Type | Description |
|---|---|
| float |
renderTarget
Destination render target.
Declaration
public RenderTargetIdentifier renderTarget { get; }
Property Value
| Type | Description |
|---|---|
| RenderTargetIdentifier |
renderTargetDesc
Destination render target descriptor.
Declaration
public RenderTextureDescriptor renderTargetDesc { get; }
Property Value
| Type | Description |
|---|---|
| RenderTextureDescriptor |
renderTargetScaledHeight
Destination render target scaled height if XR dynamic resolution is enabled
Declaration
public int renderTargetScaledHeight { get; }
Property Value
| Type | Description |
|---|---|
| int |
renderTargetScaledWidth
Destination render target scaled width if XR dynamic resolution is enabled
Declaration
public int renderTargetScaledWidth { get; }
Property Value
| Type | Description |
|---|---|
| int |
singlePassEnabled
If true, the render pipeline is expected to use single-pass techniques to save CPU time.
Declaration
public bool singlePassEnabled { get; }
Property Value
| Type | Description |
|---|---|
| bool |
spaceWarpRightHandedNDC
Reports which NDC convention the render pipeline should use when calculating motion vectors.
if true, motion vector data must use the right-handed NDC space. If false motion vector data
must use the left-handed NDC space.
Declaration
public bool spaceWarpRightHandedNDC { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
The render pipeline must write motion vector data to the UnityEngine.XR.XRDisplaySubsystem.XRRenderPass.motionVectorRenderTarget.
Note
The OpenXR specification doesn't specify which coordinate space convention to use for the motion vector data. Unity only supports SpaceWarp when using the Vulkan graphics API, which uses the right-handed convention for normalized device coordinates, but devices still can choose either convention for motion data when the application is using the Vulkan graphics API.
supportsFoveatedRendering
Returns true if the pass can use foveated rendering commands.
Declaration
public bool supportsFoveatedRendering { get; }
Property Value
| Type | Description |
|---|---|
| bool |
viewCount
Returns the number of views inside this pass.
Declaration
public int viewCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
ApplyXRViewCenterOffset(Vector2)
Take a point that is center-relative (0.5, 0.5) and modify it to be placed relative to the view's center instead, respecting the asymmetric FOV (if it is used)
Declaration
public Vector4 ApplyXRViewCenterOffset(Vector2 center)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | center | Center relative point for symmetric FOV. |
Returns
| Type | Description |
|---|---|
| Vector4 | View center relative points. First view center is stored in x,y components and second view center is stored in z,w components. |
CreateDefault(XRPassCreateInfo)
Default allocator method for XRPass.
Declaration
public static XRPass CreateDefault(XRPassCreateInfo createInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| XRPassCreateInfo | createInfo | A descriptor used to create and initialize the XRPass. |
Returns
| Type | Description |
|---|---|
| XRPass | Default XRPass created from createInfo descriptor. |
GetOcclusionMesh(int)
Returns the occlusion mesh for a given view.
Declaration
public Mesh GetOcclusionMesh(int viewIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewIndex | Index of XRView to retrieve the data from. |
Returns
| Type | Description |
|---|---|
| Mesh | XR occlusion mesh for the specified XRView. |
GetPrevViewMatrix(int)
Returns the previous frame view matrix for a given view.
Declaration
public Matrix4x4 GetPrevViewMatrix(int viewIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewIndex | Index of XRView to retrieve the data from. |
Returns
| Type | Description |
|---|---|
| Matrix4x4 | Previous frame XR view matrix for the specified XRView. |
GetPrevViewValid(int)
Returns true if the previous frame view matrix for a given view is valid.
Declaration
public bool GetPrevViewValid(int viewIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewIndex | Index of XRView to retrieve the data from. |
Returns
| Type | Description |
|---|---|
| bool | Boolean describing if previous frame view matrix for a given view is valid. |
GetProjMatrix(int)
Returns the projection matrix for a given view.
Declaration
public Matrix4x4 GetProjMatrix(int viewIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewIndex | Index of XRView to retrieve the data from. |
Returns
| Type | Description |
|---|---|
| Matrix4x4 | XR projection matrix for the specified XRView. |
GetTextureArraySlice(int)
Returns the destination slice index (for texture array) for a given view.
Declaration
public int GetTextureArraySlice(int viewIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewIndex | Index of XRView to retrieve the data from. |
Returns
| Type | Description |
|---|---|
| int | XR target slice index for the specified XRView. |
GetViewMatrix(int)
Returns the view matrix for a given view.
Declaration
public Matrix4x4 GetViewMatrix(int viewIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewIndex | Index of XRView to retrieve the data from. |
Returns
| Type | Description |
|---|---|
| Matrix4x4 | XR view matrix for the specified XRView. |
GetViewport(int)
Returns the viewport for a given view.
Declaration
public Rect GetViewport(int viewIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewIndex | Index of XRView to retrieve the data from. |
Returns
| Type | Description |
|---|---|
| Rect | XR viewport rect for the specified XRView. |
GetVisibleMesh(int)
Returns the visible mesh for a given view.
Declaration
public Mesh GetVisibleMesh(int viewIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewIndex | Index of XRView to retrieve the data from. |
Returns
| Type | Description |
|---|---|
| Mesh | XR visible mesh for the specified XRView. |
InitBase(XRPassCreateInfo)
Initialize the base class fields.
Declaration
public void InitBase(XRPassCreateInfo createInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| XRPassCreateInfo | createInfo | A descriptor used to create and initialize the XRPass. |
Release()
Default release method. Can be overridden by render pipelines.
Declaration
public virtual void Release()
RenderDebugXRViewsFrustum()
Draw debug line for all XR views.
Declaration
public void RenderDebugXRViewsFrustum()
RenderOcclusionMesh(CommandBuffer, bool)
Generate commands to render the occlusion mesh for this pass. In single-pass mode : the meshes for all views are combined into one mesh, where the corresponding view index is encoded into each vertex. The keyword "XR_OCCLUSION_MESH_COMBINED" is also enabled when rendering the combined mesh.
Declaration
public void RenderOcclusionMesh(CommandBuffer cmd, bool renderIntoTexture = false)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | CommandBuffer to modify |
| bool | renderIntoTexture | Set to true when rendering into a render texture. Used for handling Unity yflip. |
RenderOcclusionMesh(RasterCommandBuffer, bool)
Generate commands to render the occlusion mesh for this pass. In single-pass mode : the meshes for all views are combined into one mesh, where the corresponding view index is encoded into each vertex. The keyword "XR_OCCLUSION_MESH_COMBINED" is also enabled when rendering the combined mesh.
Declaration
public void RenderOcclusionMesh(RasterCommandBuffer cmd, bool renderIntoTexture = false)
Parameters
| Type | Name | Description |
|---|---|---|
| RasterCommandBuffer | cmd | RasterCommandBuffer to modify |
| bool | renderIntoTexture | Set to true when rendering into a render texture. Used for handling Unity yflip. |
RenderVisibleMeshCustomMaterial(CommandBuffer, float, Material, MaterialPropertyBlock, int, bool)
Generate commands to render the visible mesh for this pass using a custom material and set of material property block. In single-pass mode : the meshes for all views are combined into one mesh, where the corresponding view index is encoded into each vertex.
Declaration
public void RenderVisibleMeshCustomMaterial(CommandBuffer cmd, float occlusionMeshScale, Material material, MaterialPropertyBlock materialBlock, int shaderPass = 0, bool renderIntoTexture = false)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | RasterCommandBuffer to modify |
| float | occlusionMeshScale | Occlusion Mesh scale |
| Material | material | Material that the visibility mesh will render. |
| MaterialPropertyBlock | materialBlock | Material block with all the shader parameters that need to be set. |
| int | shaderPass | Material shader pass to render, set 0 by default. |
| bool | renderIntoTexture | Set to true when rendering into a render texture. Used for handling Unity yflip. |
RenderVisibleMeshCustomMaterial(RasterCommandBuffer, float, Material, MaterialPropertyBlock, int, bool)
Generate commands to render the visible mesh for this pass using a custom material and set of material property block. In single-pass mode : the meshes for all views are combined into one mesh, where the corresponding view index is encoded into each vertex.
Declaration
public void RenderVisibleMeshCustomMaterial(RasterCommandBuffer cmd, float occlusionMeshScale, Material material, MaterialPropertyBlock materialBlock, int shaderPass, bool renderIntoTexture = false)
Parameters
| Type | Name | Description |
|---|---|---|
| RasterCommandBuffer | cmd | RasterCommandBuffer to modify |
| float | occlusionMeshScale | Occlusion Mesh scale |
| Material | material | Material that the visibility mesh will render. |
| MaterialPropertyBlock | materialBlock | Material block with all the shader parameters that need to be set. |
| int | shaderPass | Material shader pass to render, set 0 by default. |
| bool | renderIntoTexture | Set to true when rendering into a render texture. Used for handling Unity yflip. |
StartSinglePass(CommandBuffer)
Queue up render commands to enable single-pass techniques. Note: depending on the platform and settings, either single-pass instancing or the multiview extension will be used.
Declaration
public void StartSinglePass(CommandBuffer cmd)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | CommandBuffer to modify |
StartSinglePass(IRasterCommandBuffer)
Queue up render commands to disable single-pass techniques.
Declaration
public void StartSinglePass(IRasterCommandBuffer cmd)
Parameters
| Type | Name | Description |
|---|---|---|
| IRasterCommandBuffer | cmd | IRasterCommandBuffer compatible command buffer to modify (This can be a RasterCommandBuffer or an UnsafeCommandBuffer) |
StopSinglePass(BaseCommandBuffer)
Queue up render commands to disable single-pass techniques.
Declaration
public void StopSinglePass(BaseCommandBuffer cmd)
Parameters
| Type | Name | Description |
|---|---|---|
| BaseCommandBuffer | cmd | BaseCommandBuffer to modify |
StopSinglePass(CommandBuffer)
Queue up render commands to disable single-pass techniques.
Declaration
public void StopSinglePass(CommandBuffer cmd)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | CommandBuffer to modify. |