Version: 2019.3
LanguageEnglish
  • C#

Graphics.DrawMeshInstancedProcedural

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static void DrawMeshInstancedProcedural(Mesh mesh, int submeshIndex, Material material, Bounds bounds, int count, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows, int layer, Camera camera, Rendering.LightProbeUsage lightProbeUsage, LightProbeProxyVolume lightProbeProxyVolume);

Parameters

meshThe Mesh to draw.
submeshIndexWhich subset of the mesh to draw. This applies only to meshes that are composed of several materials.
material Material to use.
boundsThe bounding volume surrounding the instances you intend to draw.
countThe number of instances to be drawn.
propertiesAdditional material properties to apply. See MaterialPropertyBlock.
castShadowsShould the meshes cast shadows?
receiveShadowsShould the meshes receive shadows?
layer Layer to use.
cameraIf null (default), the mesh will be drawn in all cameras. Otherwise it will be drawn in the given camera only.
lightProbeUsage LightProbeUsage for the instances.

Description

Draw the same mesh multiple times using GPU instancing. This is similar to Graphics.DrawMeshInstancedIndirect, except when the instance count is known from script, it can be supplied directly using this method, rather than via a ComputeBuffer.

To render the instances with light probes, provide the light probe data via the MaterialPropertyBlock and specify lightProbeUsage with LightProbeUsage.CustomProvided. Check LightProbes.CalculateInterpolatedLightAndOcclusionProbes for the details.