VisualInstance3D
Parent of all visual 3D nodes.
Parent of all visual 3D nodes.
The VisualInstance3D is used to connect a resource to a visual representation. All visual 3D nodes inherit from the VisualInstance3D. In general, you should not access the VisualInstance3D properties directly as they are accessed and managed by the nodes that inherit from VisualInstance3D. VisualInstance3D is the node representation of the RenderingServer instance.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
VisualInstance3DConstructor
public VisualInstance3D();Properties3
LayersProperty
public uint Layers { get; set; }The render layer(s) this VisualInstance3D is drawn on.
This object will only be visible for Camera3Ds whose cull mask includes any of the render layers this VisualInstance3D is set to.
For Light3Ds, this can be used to control which VisualInstance3Ds are affected by a specific light. For GpuParticles3D, this can be used to control which particles are effected by a specific attractor. For Decals, this can be used to control which VisualInstance3Ds are affected by a specific decal.
To adjust VisualInstance3D.Layers more easily using a script, use VisualInstance3D.GetLayerMaskValue and VisualInstance3D.SetLayerMaskValue.
Note: VoxelGI, SDFGI and LightmapGI will always take all layers into account to determine what contributes to global illumination. If this is an issue, set GeometryInstance3D.GIMode to GeometryInstance3D.GIModeEnum.Disabled for meshes and Light3D.LightBakeMode to Light3D.BakeMode.Disabled for lights to exclude them from global illumination.
SortingOffsetProperty
public float SortingOffset { get; set; }The amount by which the depth of this VisualInstance3D will be adjusted when sorting by depth. Uses the same units as the engine (which are typically meters). Adjusting it to a higher value will make the VisualInstance3D reliably draw on top of other VisualInstance3Ds that are otherwise positioned at the same spot. To ensure it always draws on top of other objects around it (not positioned at the same spot), set the value to be greater than the distance between this VisualInstance3D and the other nearby VisualInstance3Ds.
SortingUseAabbCenterProperty
public bool SortingUseAabbCenter { get; set; }If true, the object is sorted based on the Aabb center. The object will be sorted based on the global position otherwise.
The Aabb center based sorting is generally more accurate for 3D models. The position based sorting instead allows to better control the drawing order when working with GpuParticles3D and CpuParticles3D.
Methods13
GetAabbAabb
public Aabb GetAabb();Returns local geometry bounds for the concrete VisualInstance3D type. MeshInstance3D returns Mesh.GetAabb(), or an empty Aabb without a Mesh. The Entity transform, CustomAabb, ExtraCullMargin and GPU deformation are not included. The base VisualInstance3D implementation calls _GetAabb; native derived types may implement their own GetAabb.
AabbThe local geometry Aabb supplied by the type implementation, not world-space or final server-side culling bounds.
GetBaseRid
public Rid GetBase();Returns the RID of the resource associated with this VisualInstance3D. For example, if the Entity is a MeshInstance3D, this will return the RID of the associated Mesh.
RidGetInstanceRid
public Rid GetInstance();Returns the RID of this instance. This RID is the same as the RID returned by RenderingServer.InstanceCreate. This RID is needed if you want to call RenderingServer functions directly on this VisualInstance3D.
RidGetLayerMaskuint
public uint GetLayerMask();uintGetLayerMaskValuebool
public bool GetLayerMaskValue(int layerNumber);Returns whether or not the specified layer of the VisualInstance3D.Layers is enabled, given a layer_number between 1 and 20.
| Name | Type | Default |
|---|---|---|
layerNumber | int | — |
boolGetSortingOffsetfloat
public float GetSortingOffset();floatIsSortingUseAabbCenterbool
public bool IsSortingUseAabbCenter();boolSetBasevoid
public void SetBase(Rid @base);Sets the resource that is instantiated by this VisualInstance3D, which changes how the engine handles the VisualInstance3D under the hood. Equivalent to RenderingServer.InstanceSetBase.
| Name | Type | Default |
|---|---|---|
base | Rid | — |
SetLayerMaskvoid
public void SetLayerMask(uint mask);| Name | Type | Default |
|---|---|---|
mask | uint | — |
SetLayerMaskValuevoid
public void SetLayerMaskValue(int layerNumber, bool value);Based on value, enables or disables the specified layer in the VisualInstance3D.Layers, given a layer_number between 1 and 20.
| Name | Type | Default |
|---|---|---|
layerNumber | int | — |
value | bool | — |
SetSortingOffsetvoid
public void SetSortingOffset(float offset);| Name | Type | Default |
|---|---|---|
offset | float | — |
SetSortingUseAabbCentervoid
public void SetSortingUseAabbCenter(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
_GetAabbAabb
public virtual Aabb _GetAabb();Virtual local-bounds callback for a custom type based on VisualInstance3D. The base GetAabb implementation calls this method. A native derived type implementing its own GetAabb may bypass the callback; use CustomAabb or ExtraCullMargin to configure MeshInstance3D culling.
AabbBounds of the custom geometry in local coordinates. This is a separate contract from configuring CustomAabb on the rendering instance.