Version: 2023.1

Graphics.DrawProcedural

切换到手册
public static void DrawProcedural (Material material, Bounds bounds, MeshTopology topology, int vertexCount, int instanceCount, Camera camera, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows, int layer);

参数

material 要使用的 Material
bounds 围绕要绘制的实例的包围体。
topology 程序化几何体的拓扑。
vertexCount 要渲染的顶点数。
instanceCount 要渲染的实例数。
camera If null (default), the mesh will be drawn in all cameras. Otherwise it will be rendered in the given Camera only.
properties 在绘制此网格之前应用于材质的其他材质属性。请参阅 MaterialPropertyBlock
castShadows 确定网格是否可以投射阴影。
receiveShadows 确定网格是否可以接受阴影。
layer 要使用的 Layer

描述

This function is now obsolete. For non-indexed rendering, use Graphics.RenderPrimitives instead. For indexed rendering, use Graphics.RenderPrimitivesIndexed. Draws procedural geometry on the GPU.

This function is now obsolete. For non-indexed rendering, use RenderPrimitives instead. For indexed rendering, use Graphics.RenderPrimitivesIndexed.

DrawProcedural 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 DrawProcedural. This is mainly useful on Shader Model 4.5 level hardware where shaders can read arbitrary data from ComputeBuffer buffers.

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

For non-indexed rendering: public static void DrawProcedural(Material material, Bounds bounds, MeshTopology topology, int vertexCount, int instanceCount = 1, Camera camera = null, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0)

For indexed rendering (takes GraphicsBuffer indexBuffer): public static void DrawProcedural(Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer indexBuffer, int indexCount, int instanceCount = 1, Camera camera = null, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0)

See Also: Graphics.RenderPrimitives, Graphics.RenderPrimitivesIndexed, Graphics.DrawProceduralIndirect, SystemInfo.supportsInstancing.


public static void DrawProcedural (Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer indexBuffer, int indexCount, int instanceCount, Camera camera, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows, int layer);

参数

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

描述

Draws procedural geometry on the GPU, with an index buffer.

Use the GraphicsBuffer.Target.Index target flag to create an index buffer.