Documentation
¶
Overview ¶
MultiMesh provides low-level mesh instancing. Drawing thousands of graphics.gd/classdb/MeshInstance3D nodes can be slow, since each object is submitted to the GPU then drawn individually.
MultiMesh is much faster as 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 from each other, performance may be reduced as every single instance will always render (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.
Note: A MultiMesh is a single object, therefore the same maximum lights per object restriction applies. This means, that once the maximum lights are consumed by one or more instances, the rest of the MultiMesh instances will not receive any lighting.
Note: Blend Shapes will be ignored if used in a MultiMesh.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsMultiMesh() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) Buffer() []float32
- func (self Instance) CustomAabb() AABB.PositionSize
- func (self Instance) GetAabb() AABB.PositionSize
- func (self Instance) GetInstanceColor(instance int) Color.RGBA
- func (self Instance) GetInstanceCustomData(instance int) Color.RGBA
- func (self Instance) GetInstanceTransform(instance int) Transform3D.BasisOrigin
- func (self Instance) GetInstanceTransform2d(instance int) Transform2D.OriginXY
- func (self Instance) ID() ID
- func (self Instance) InstanceCount() int
- func (self Instance) Mesh() Mesh.Instance
- func (self Instance) PhysicsInterpolationQuality() PhysicsInterpolationQuality
- func (self Instance) ResetInstancePhysicsInterpolation(instance int)
- func (self Instance) SetBuffer(value []float32)
- func (self Instance) SetBufferInterpolated(buffer_curr []float32, buffer_prev []float32)
- func (self Instance) SetCustomAabb(value AABB.PositionSize)
- func (self Instance) SetInstanceColor(instance int, color Color.RGBA)
- func (self Instance) SetInstanceCount(value int)
- func (self Instance) SetInstanceCustomData(instance int, custom_data Color.RGBA)
- func (self Instance) SetInstanceTransform(instance int, transform Transform3D.BasisOrigin)
- func (self Instance) SetInstanceTransform2d(instance int, transform Transform2D.OriginXY)
- func (self Instance) SetMesh(value Mesh.Instance)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPhysicsInterpolationQuality(value PhysicsInterpolationQuality)
- func (self Instance) SetTransformFormat(value TransformFormat)
- func (self Instance) SetUseColors(value bool)
- func (self Instance) SetUseCustomData(value bool)
- func (self Instance) SetVisibleInstanceCount(value int)
- func (self Instance) TransformFormat() TransformFormat
- func (self Instance) UseColors() bool
- func (self Instance) UseCustomData() bool
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) VisibleInstanceCount() int
- type PhysicsInterpolationQuality
- type TransformFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsMultiMesh ¶
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsMultiMesh ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) CustomAabb ¶
func (self Instance) CustomAabb() AABB.PositionSize
func (Instance) GetAabb ¶
func (self Instance) GetAabb() AABB.PositionSize
Returns the visibility axis-aligned bounding box in local space.
func (Instance) GetInstanceColor ¶
Gets a specific instance's color multiplier.
func (Instance) GetInstanceCustomData ¶
Returns the custom data that has been set for a specific instance.
func (Instance) GetInstanceTransform ¶
func (self Instance) GetInstanceTransform(instance int) Transform3D.BasisOrigin
Returns the [Transform3D.BasisOrigin] of a specific instance.
func (Instance) GetInstanceTransform2d ¶
func (self Instance) GetInstanceTransform2d(instance int) Transform2D.OriginXY
Returns the [Transform2D.OriginXY] of a specific instance.
func (Instance) InstanceCount ¶
func (Instance) PhysicsInterpolationQuality ¶
func (self Instance) PhysicsInterpolationQuality() PhysicsInterpolationQuality
func (Instance) ResetInstancePhysicsInterpolation ¶
When using physics interpolation, this function allows you to prevent interpolation on an instance in the current physics tick.
This allows you to move instances instantaneously, and should usually be used when initially placing an instance such as a bullet to prevent graphical glitches.
func (Instance) SetBufferInterpolated ¶
An alternative to setting the Instance.Buffer property, which can be used with physics interpolation. This method takes two arrays, and can set the data for the current and previous tick in one go. The renderer will automatically interpolate the data at each frame.
This is useful for situations where the order of instances may change from physics tick to tick, such as particle systems.
When the order of instances is coherent, the simpler alternative of setting Instance.Buffer can still be used with interpolation.
func (Instance) SetCustomAabb ¶
func (self Instance) SetCustomAabb(value AABB.PositionSize)
func (Instance) SetInstanceColor ¶
Sets the color of a specific instance by multiplying the mesh's existing vertex colors. This allows for different color tinting per instance.
Note: Each component is stored in 32 bits in the Forward+ and Mobile rendering methods, but is packed into 16 bits in the Compatibility rendering method.
For the color to take effect, ensure that Instance.UseColors is true on the graphics.gd/classdb/MultiMesh and graphics.gd/classdb/BaseMaterial3D.Instance.VertexColorUseAsAlbedo is true on the material. If you intend to set an absolute color instead of tinting, make sure the material's albedo color is set to pure white (Color(1, 1, 1)).
func (Instance) SetInstanceCount ¶
func (Instance) SetInstanceCustomData ¶
Sets custom data for a specific instance. 'custom_data' is a [Color.RGBA] type only to contain 4 floating-point numbers.
Note: Each number is stored in 32 bits in the Forward+ and Mobile rendering methods, but is packed into 16 bits in the Compatibility rendering method.
For the custom data to be used, ensure that Instance.UseCustomData is true.
This custom instance data has to be manually accessed in your custom shader using INSTANCE_CUSTOM.
func (Instance) SetInstanceTransform ¶
func (self Instance) SetInstanceTransform(instance int, transform Transform3D.BasisOrigin)
Sets the [Transform3D.BasisOrigin] for a specific instance.
func (Instance) SetInstanceTransform2d ¶
func (self Instance) SetInstanceTransform2d(instance int, transform Transform2D.OriginXY)
Sets the [Transform2D.OriginXY] for a specific instance.
func (Instance) SetPhysicsInterpolationQuality ¶
func (self Instance) SetPhysicsInterpolationQuality(value PhysicsInterpolationQuality)
func (Instance) SetTransformFormat ¶
func (self Instance) SetTransformFormat(value TransformFormat)
func (Instance) SetUseColors ¶
func (Instance) SetUseCustomData ¶
func (Instance) SetVisibleInstanceCount ¶
func (Instance) TransformFormat ¶
func (self Instance) TransformFormat() TransformFormat
func (Instance) UseCustomData ¶
func (Instance) VisibleInstanceCount ¶
type PhysicsInterpolationQuality ¶
type PhysicsInterpolationQuality int //gd:MultiMesh.PhysicsInterpolationQuality
const ( // Always interpolate using Basis lerping, which can produce warping artifacts in some situations. InterpQualityFast PhysicsInterpolationQuality = 0 // Attempt to interpolate using Basis slerping (spherical linear interpolation) where possible, otherwise fall back to lerping. InterpQualityHigh PhysicsInterpolationQuality = 1 )
type TransformFormat ¶
type TransformFormat int //gd:MultiMesh.TransformFormat
const ( // Use this when using 2D transforms. Transform2d TransformFormat = 0 // Use this when using 3D transforms. Transform3d TransformFormat = 1 )