Version: 2023.1

Graphics.DrawProceduralIndirect

切换到手册
public static void DrawProceduralIndirect (Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer bufferWithArgs, int argsOffset, Camera camera, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows, int layer);
public static void DrawProceduralIndirect (Material material, Bounds bounds, MeshTopology topology, ComputeBuffer bufferWithArgs, int argsOffset, Camera camera, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows, int layer);

参数

material 要使用的 Material
bounds 围绕要绘制的实例的包围体。
topology 程序化几何体的拓扑。
camera If null (default), the mesh will be drawn in all cameras. Otherwise it will be rendered in the given Camera only.
bufferWithArgs 具有绘制参数的缓冲区。
argsOffset 缓冲区中的字节偏移,绘制参数所在位置。
properties 在绘制此网格之前应用于材质的其他材质属性。请参阅 MaterialPropertyBlock
castShadows 确定网格是否可以投射阴影。
receiveShadows 确定网格是否可以接受阴影。
layer 要使用的 Layer

描述

在 GPU 上绘制程序化的几何形状。

This function is now obsolete. For non-indexed rendering, use RenderPrimitivesIndirect instead. For indexed rendering, use RenderPrimitivesIndexedIndirect.

This function only works on platforms that support compute shaders.

DrawProceduralIndirect does a draw call on the GPU, without any vertex or index buffers. If the shader requires vertex buffers one of the following occurs depending on platform: If the vertex buffer is declared but compiler can optimize it away then the normal DrawProcedural call will occur. If the compiler is not able to optimize the vertex buffer declaration away then this will be converted into a normal mesh drawing call with emulated vertexbuffers injected. The latter option has performance overhead so it is recommended not to declare vertex inputs in shaders when using DrawProceduralIndirect. The amount of geometry to draw is read from a ComputeBuffer. Typical use case is generating an arbitrary amount of data from a ComputeShader and then rendering that, without requiring a readback to the CPU.

这主要在 Shader Model 4.5 级别的硬件中有用,其中着色器可以从 ComputeBuffer 缓冲区读取任意数据。

带参数的缓冲区 bufferWithArgs 必须在给定的 argsOffset 偏移处具有四个整数: 每个实例的顶点数、实例数、起始顶点位置和起始实例位置。 这会映射到 Direct3D11 DrawInstancedIndirect 和其他图形 API 中的等效函数。在 OpenGL 4.2 之前的版本和支持间接绘制的所有 OpenGL ES 版本中,最后一个参数保留,因此必须是零。

CommandBuffers 中也有类似的功能,请参阅 CommandBuffer.DrawProceduralIndirect

See Also: Graphics.RenderPrimitivesIndirect, Graphics.RenderPrimitivesIndexedIndirect, Graphics.DrawProcedural, ComputeBuffer.CopyCount, SystemInfo.supportsComputeShaders.


public static void DrawProceduralIndirect (Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer indexBuffer, GraphicsBuffer bufferWithArgs, int argsOffset, Camera camera, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows, int layer);
public static void DrawProceduralIndirect (Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer indexBuffer, ComputeBuffer bufferWithArgs, int argsOffset, Camera camera, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows, int layer);

参数

material 要使用的 Material
bounds 围绕要绘制的实例的包围体。
topology 程序化几何体的拓扑。
indexBuffer 用于将顶点提交到 GPU 的索引缓冲区。
camera If null (default), the mesh will be drawn in all cameras. Otherwise it will be rendered in the given Camera only.
bufferWithArgs 具有绘制参数的缓冲区。
argsOffset 缓冲区中的字节偏移,绘制参数所在位置。
properties 在绘制此网格之前应用于材质的其他材质属性。请参阅 MaterialPropertyBlock
castShadows 确定网格是否可以投射阴影。
receiveShadows 确定网格是否可以接受阴影。
layer 要使用的 Layer

描述

在 GPU 上绘制程序化的几何形状。

DrawProceduralIndirect 在 GPU 上执行绘制调用,没有顶点缓冲区。 要绘制的几何体数量可从 ComputeBuffer 中读取。典型的用例是从 ComputeShader 中生成任意数量的数据,然后渲染该数据,无需回读 CPU。

这主要在 Shader Model 4.5 级别的硬件中有用,其中着色器可以从 ComputeBuffer 缓冲区读取任意数据。

带参数的缓冲区 bufferWithArgs 必须在给定的 argsOffset 偏移处具有五个整数: 每个实例的索引数、实例数、起始索引位置、基顶点位置和起始实例位置。 这会映射到 Direct3D11 DrawIndexedInstancedIndirect 和其他图形 API 中的等效函数。在 OpenGL 4.2 之前的版本和支持间接绘制的所有 OpenGL ES 版本中,最后一个参数保留,因此必须是零。

CommandBuffers 中也有类似的功能,请参阅 CommandBuffer.DrawProceduralIndirect

另请参阅:Graphics.DrawProceduralComputeBuffer.CopyCountSystemInfo.supportsComputeShaders