Version: 2020.2
Experimental: this API is experimental and might be changed or removed in the future.

RayTracingAccelerationStructure.AddInstance

切换到手册
public void AddInstance (Renderer targetRenderer, bool[] subMeshMask, bool[] subMeshTransparencyFlags, bool enableTriangleCulling, bool frontTriangleCounterClockwise, uint mask);
public void AddInstance (GraphicsBuffer aabbBuffer, uint numElements, Material material, Matrix4x4 instanceTransform, bool isCutOff, bool enableTriangleCulling, bool frontTriangleCounterClockwise, uint mask, bool reuseBounds);
public void AddInstance (GraphicsBuffer aabbBuffer, uint numElements, Material material, bool isCutOff, bool enableTriangleCulling, bool frontTriangleCounterClockwise, uint mask, bool reuseBounds);

参数

targetRenderer 将添加到 RayTracingAccelerationStructure 的渲染器。
subMeshMask 指示是否向 RayTracingAccelerationStructure 添加子网格的任何大小的位掩码。对于具有多个子网格的渲染器,如果 subMeshMask[i] = true,该子网格已添加到 RayTracingAccelerationStructure。对于只有一个子网格的渲染器,可将未初始化的数组作为默认值传递。
subMeshTransparencyFlags 指示给定子网格是否透明的任何大小的位数组。对于具有多个子网格的渲染器,如果 subMeshTransparencyFlag[i] = true,则该子网格已标记为透明。对于只有一个子网格的渲染器,传递具有单个初始化条目的数组,并且指示一个子网格是否透明。
enableTriangleCulling 一个 bool 值,指示 GPU 驱动程序级剔除通道(例如正面剔除或背面剔除)是否应将此渲染器剔除。默认情况下启用 (true) 剔除。
frontTriangleCounterClockwise 一个 bool 值,指示在渲染器中是否翻转三角形的朝向。如果将其设置为 true,则正面三角形将变为背面,反之亦然。默认情况下,设置为 false。
mask 可使用 8 位掩码有选择地将渲染器与仅通过此掩码的射线相交。默认情况下启用 (0xff) 所有射线。
aabbBuffer A GraphicsBuffer that defines a number of axis-aligned bounding boxes (AABBs). An AABB is defined by a list of bounds, written as floats in the following order: minX, minY, minZ, maxX, maxY, maxZ.
numElements The number of axis-aligned bounding boxes defined in the given GraphicsBuffer.
material The Material to apply to an instance defined by axis-aligned bounding boxes in a GraphicsBuffer.
instanceTransform The object to world matrix to apply to an instance defined by axis-aligned bounding boxes in a GraphicsBuffer. This is optional, and takes the value of a Matrix4x4.identity by default.
isCutOff A bool that indicates whether the Material applied to a GraphicsBuffer instance has cutoff transparency.
reuseBounds A bool that indicates whether Unity reuses the AABBs defined in the GraphicsBuffer without change. If the exact same bounds can be used across multiple acceleration structures or multiple frames, set this to true. This is false by default.

描述

Add an instance to this RayTracingAccelerationStructure. Instance geometry can be either a Renderer or a GraphicsBuffer that includes a number of axis-aligned bounding boxes.

必须调用它才能将实例添加到手动托管的 RayTracingAccelerationStructure。