Provides high performance mesh instancing.
    public class MultiMesh : Resource

MultiMesh provides low level mesh instancing. Drawing thousands of MeshInstance nodes can be slow because each object is submitted to the GPU to be drawn individually.

MultiMesh is much faster because it can draw thousands of instances with a single draw call, resulting in less API overhead.

As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object).

Since instances may have any behavior, the AABB used for visibility must be provided by the user.

Inheritance Chain

Constructors

    public MultiMesh()

Properties

    public Color[] ColorArray { get; set; }

    public ColorFormatEnum ColorFormat { get; set; }

Format of colors in color array that gets passed to shader.

    public Color[] CustomDataArray { get; set; }

    public CustomDataFormatEnum CustomDataFormat { get; set; }

Format of custom data in custom data array that gets passed to shader.

    public int InstanceCount { get; set; }

Number of instances that will get drawn.

    public Mesh Mesh { get; set; }

Mesh to be drawn.

    public Vector3[] TransformArray { get; set; }

    public TransformFormatEnum TransformFormat { get; set; }

Format of transform used to transform mesh, either 2D or 3D.

Methods

    public AABB GetAabb()

Return the visibility AABB.

    public ColorFormatEnum GetColorFormat()

Getter for ColorFormat

    public CustomDataFormatEnum GetCustomDataFormat()

Getter for CustomDataFormat

    public Color GetInstanceColor(int instance)

Get the color of a specific instance.

    public int GetInstanceCount()

Getter for InstanceCount

    public Color GetInstanceCustomData(int instance)

Return the custom data that has been set for a specific instance.

    public Transform GetInstanceTransform(int instance)

Return the transform of a specific instance.

    public Transform2D GetInstanceTransform2d(int instance)

    public Mesh GetMesh()

Getter for Mesh

    public TransformFormatEnum GetTransformFormat()

Getter for TransformFormat

    public void SetColorFormat(ColorFormatEnum format)

Setter for ColorFormat

    public void SetCustomDataFormat(CustomDataFormatEnum format)

Setter for CustomDataFormat

    public void SetInstanceColor(int instance, Color color)

Set the color of a specific instance.

    public void SetInstanceCount(int count)

Setter for InstanceCount

    public void SetInstanceCustomData(int instance, Color customData)

Set custom data for a specific instance. Although Color is used, it is just a container for 4 numbers.

    public void SetInstanceTransform(int instance, Transform transform)

Set the transform for a specific instance.

    public void SetInstanceTransform2d(int instance, Transform2D transform)

    public void SetMesh(Mesh mesh)

Setter for Mesh

    public void SetTransformFormat(TransformFormatEnum format)

Setter for TransformFormat

Inner Types

ColorFormatEnum

Name Value Description
None 0 Use when you are not using per-instance [Color]s.
Color8bit    
Float 2 The [Color] passed into [method set_instance_color] will use 4 floats. Use this for highest precision [Color].

CustomDataFormatEnum

Name Value Description
None 0 Use when you are not using per-instance custom data.
Data8bit    
Float 2 The [Color] passed into [method set_instance_custom_data] will use 4 floats. Use this for highest precision.

TransformFormatEnum

Name Value Description
Transform2d    
Transform3d    
Tags: