Struct MeshInstanceDesc
Parameters used to configure the creation of instances that are part of a IRayTracingAccelStruct.
Inherited Members
Namespace: UnityEngine.Rendering.UnifiedRayTracing
Assembly: Unity.UnifiedRayTracing.Runtime.dll
Syntax
public struct MeshInstanceDesc
  Constructors
MeshInstanceDesc(Mesh, int)
Creates a MeshInstanceDesc.
Declaration
public MeshInstanceDesc(Mesh mesh, int subMeshIndex = 0)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | mesh | The Mesh used to build this instance's geometry.  | 
      
| int | subMeshIndex | The index of the sub-mesh (MeshInstanceDesc references a single sub-mesh).  | 
      
Fields
enableTriangleCulling
Whether front/back face culling for this ray tracing instance is enabled. Default value: true.
Declaration
public bool enableTriangleCulling
  Field Value
| Type | Description | 
|---|---|
| bool | 
frontTriangleCounterClockwise
Whether to flip the way triangles face in this ray tracing instance. Default value: false.
Declaration
public bool frontTriangleCounterClockwise
  Field Value
| Type | Description | 
|---|---|
| bool | 
instanceID
Instance identifier. Can be accessed in the HLSL via the instanceID member of Hit (Hit is returned by the TraceRayClosestHit/TraceRayAnyHit HLSL functions).
Declaration
public uint instanceID
  Field Value
| Type | Description | 
|---|---|
| uint | 
localToWorldMatrix
The transformation matrix of the instance.
Declaration
public Matrix4x4 localToWorldMatrix
  Field Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
mask
The instance mask.
Declaration
public uint mask
  Field Value
| Type | Description | 
|---|---|
| uint | 
Remarks
Instances in the acceleration structure contain an 8-bit user defined instance mask. The TraceRayClosestHit/TraceRayAnyHit HLSL functions have an 8-bit input parameter, InstanceInclusionMask which gets ANDed with the instance mask from any instance that is a candidate for intersection during acceleration structure traversal on the GPU. If the result of the AND operation is zero, the GPU ignores the intersection.
mesh
The Mesh used to build this instance's geometry.
Declaration
public Mesh mesh
  Field Value
| Type | Description | 
|---|---|
| Mesh | 
opaqueGeometry
Whether the geometry is considered opaque. Default value: true.
Declaration
public bool opaqueGeometry
  Field Value
| Type | Description | 
|---|---|
| bool | 
Remarks
When an instance's opaqueGeometry field is set to false, the AnyHitExecute shader function will be invoked during the ray traversal when a hit is found. This alows the user to programmatically decide whether to reject or accept the candidate hit. This feature can, for example, be used to implement alpha cutout transparency. For best performance, prefer to set this parameter to false for as many geometries as possibe.
subMeshIndex
The index of the sub-mesh (MeshInstanceDesc references a single sub-mesh).
Declaration
public int subMeshIndex
  Field Value
| Type | Description | 
|---|---|
| int |