Version: 2020.3

CommandBuffer.DrawMeshInstanced

切换到手册
public void DrawMeshInstanced (Mesh mesh, int submeshIndex, Material material, int shaderPass, Matrix4x4[] matrices, int count, MaterialPropertyBlock properties);
public void DrawMeshInstanced (Mesh mesh, int submeshIndex, Material material, int shaderPass, Matrix4x4[] matrices, int count);
public void DrawMeshInstanced (Mesh mesh, int submeshIndex, Material material, int shaderPass, Matrix4x4[] matrices);

参数

mesh 要绘制的 Mesh
submeshIndex Which subset of the mesh to draw. This only applies to meshes that are composed of several materials.
material 要使用的 Material
shaderPass 要使用着色器的哪个通道,或选择 -1,表示渲染所有通道。
matrices 对象变换矩阵的数组。
count 要绘制的实例数。
properties Additional Material properties to apply onto the Material just before this Mesh is drawn. See MaterialPropertyBlock.

描述

Adds a "draw mesh with instancing" command.

如果 Material.enableInstancing 为 false,该命令不会立即失败并抛出异常,但如果检测到此类情况,则会记录错误并在每次执行命令时跳过渲染。

如果当前平台不支持此 API(即,如果 GPU 实例化不可用),则会抛出 InvalidOperationException。请参阅 SystemInfo.supportsInstancing