Version: 2021.1
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 The Renderer to add to the RayTracingAccelerationStructure.
subMeshMask 指示是否向 RayTracingAccelerationStructure 添加子网格的任何大小的位掩码。对于具有多个子网格的渲染器,如果 subMeshMask[i] = true,该子网格已添加到 RayTracingAccelerationStructure。对于只有一个子网格的渲染器,可将未初始化的数组作为默认值传递。
subMeshTransparencyFlags 指示给定子网格是否透明的任何大小的位数组。对于具有多个子网格的渲染器,如果 subMeshTransparencyFlag[i] = true,则该子网格已标记为透明。对于只有一个子网格的渲染器,传递具有单个初始化条目的数组,并且指示一个子网格是否透明。
enableTriangleCulling 一个 bool 值,指示 GPU 驱动程序级剔除通道(例如正面剔除或背面剔除)是否应将此渲染器剔除。默认情况下启用 (true) 剔除。
frontTriangleCounterClockwise A bool that indicates whether to flip the way triangles face in this Renderer. If this is set to true, front-facing triangles will become back-facing and vice versa. Set to false by default.
mask An 8-bit mask you can use to selectively intersect the ray tracing instance associated with the target Renderer with rays that only pass the mask. All rays are enabled (0xff) by default.
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.

描述

Adds a ray tracing instance associated with a Renderer to this RayTracingAccelerationStructure.

Instance geometry can be either a Renderer or a GraphicsBuffer that includes a number of axis-aligned bounding boxes.

This function is the primary way to add a ray tracing instance to a manually managed RayTracingAccelerationStructure. Note that to build the acceleration structure on the GPU, you must call RayTracingAccelerationStructure.Build or CommandBuffer.BuildRayTracingAccelerationStructure.

Ray tracing instances in the acceleration structure contain an 8-bit user defined instance mask. The TraceRay() HLSL function has an 8-bit input parameter, InstanceInclusionMask which gets ANDed with the instance mask from any ray tracing instance that is a candidate for intersection during acceleration structure traversal on the GPU. If the result of the AND operation is zero, the intersection is ignored.

See Also: RayTracingAccelerationStructure.RemoveInstance.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961