GeometryInstance3D

Inherits:VisualInstance3D<Node3D<Node<Object

Inherited By:CPUParticles3D,CSGShape3D,GPUParticles3D,Label3D,MeshInstance3D,MultiMeshInstance3D,SpriteBase3D

Base node for geometry-based visual instances.

Description

Base node for geometry-based visual instances. Shares some common functionality like visibility and custom materials.

Tutorials

Properties

ShadowCastingSetting

cast_shadow

1

AABB

custom_aabb

AABB(0,0,0,0,0,0)

float

extra_cull_margin

0.0

LightmapScale

gi_lightmap_scale

0

float

gi_lightmap_texel_scale

1.0

GIMode

gi_mode

1

bool

ignore_occlusion_culling

false

float

lod_bias

1.0

Material

material_overlay

Material

material_override

float

transparency

0.0

float

visibility_range_begin

0.0

float

visibility_range_begin_margin

0.0

float

visibility_range_end

0.0

float

visibility_range_end_margin

0.0

VisibilityRangeFadeMode

visibility_range_fade_mode

0

Methods

Variant

get_instance_shader_parameter(name:StringName)const

void

set_instance_shader_parameter(name:StringName, value:Variant)


Enumerations

enumShadowCastingSetting:🔗

ShadowCastingSettingSHADOW_CASTING_SETTING_OFF =0

Will not cast any shadows. Use this to improve performance for small geometry that is unlikely to cast noticeable shadows (such as debris).

ShadowCastingSettingSHADOW_CASTING_SETTING_ON =1

Will cast shadows from all visible faces in the GeometryInstance3D.

Will take culling into account, so faces not being rendered will not be taken into account when shadow casting.

ShadowCastingSettingSHADOW_CASTING_SETTING_DOUBLE_SIDED =2

Will cast shadows from all visible faces in the GeometryInstance3D.

Will not take culling into account, so all faces will be taken into account when shadow casting.

ShadowCastingSettingSHADOW_CASTING_SETTING_SHADOWS_ONLY =3

Will only show the shadows casted from this object.

In other words, the actual mesh will not be visible, only the shadows casted from the mesh will be.


enumGIMode:🔗

GIModeGI_MODE_DISABLED =0

Disabled global illumination mode. Use for dynamic objects that do not contribute to global illumination (such as characters). When usingVoxelGI and SDFGI, the geometry willreceive indirect lighting and reflections but the geometry will not be considered in GI baking.

GIModeGI_MODE_STATIC =1

Baked global illumination mode. Use for static objects that contribute to global illumination (such as level geometry). This GI mode is effective when usingVoxelGI, SDFGI andLightmapGI.

GIModeGI_MODE_DYNAMIC =2

Dynamic global illumination mode. Use for dynamic objects that contribute to global illumination. This GI mode is only effective when usingVoxelGI, but it has a higher performance impact thanGI_MODE_STATIC. When using other GI methods, this will act the same asGI_MODE_DISABLED. When usingLightmapGI, the object will receive indirect lighting using lightmap probes instead of using the baked lightmap texture.


enumLightmapScale:🔗

LightmapScaleLIGHTMAP_SCALE_1X =0

Deprecated: Usegi_lightmap_texel_scale instead.

The standard texel density for lightmapping withLightmapGI.

LightmapScaleLIGHTMAP_SCALE_2X =1

Deprecated: Usegi_lightmap_texel_scale instead.

Multiplies texel density by 2× for lightmapping withLightmapGI. To ensure consistency in texel density, use this when scaling a mesh by a factor between 1.5 and 3.0.

LightmapScaleLIGHTMAP_SCALE_4X =2

Deprecated: Usegi_lightmap_texel_scale instead.

Multiplies texel density by 4× for lightmapping withLightmapGI. To ensure consistency in texel density, use this when scaling a mesh by a factor between 3.0 and 6.0.

LightmapScaleLIGHTMAP_SCALE_8X =3

Deprecated: Usegi_lightmap_texel_scale instead.

Multiplies texel density by 8× for lightmapping withLightmapGI. To ensure consistency in texel density, use this when scaling a mesh by a factor greater than 6.0.

LightmapScaleLIGHTMAP_SCALE_MAX =4

Deprecated: Usegi_lightmap_texel_scale instead.

Represents the size of theLightmapScale enum.


enumVisibilityRangeFadeMode:🔗

VisibilityRangeFadeModeVISIBILITY_RANGE_FADE_DISABLED =0

Will not fade itself nor its visibility dependencies, hysteresis will be used instead. This is the fastest approach to manual LOD, but it can result in noticeable LOD transitions depending on how the LOD meshes are authored. Seevisibility_range_begin andNode3D.visibility_parent for more information.

VisibilityRangeFadeModeVISIBILITY_RANGE_FADE_SELF =1

Will fade-out itself when reaching the limits of its own visibility range. This is slower thanVISIBILITY_RANGE_FADE_DISABLED, but it can provide smoother transitions. The fading range is determined byvisibility_range_begin_margin andvisibility_range_end_margin.

Note: Only supported when using the Forward+ rendering method. When using the Mobile or Compatibility rendering method, this mode acts likeVISIBILITY_RANGE_FADE_DISABLED but with hysteresis disabled.

VisibilityRangeFadeModeVISIBILITY_RANGE_FADE_DEPENDENCIES =2

Will fade-in its visibility dependencies (seeNode3D.visibility_parent) when reaching the limits of its own visibility range. This is slower thanVISIBILITY_RANGE_FADE_DISABLED, but it can provide smoother transitions. The fading range is determined byvisibility_range_begin_margin andvisibility_range_end_margin.

Note: Only supported when using the Forward+ rendering method. When using the Mobile or Compatibility rendering method, this mode acts likeVISIBILITY_RANGE_FADE_DISABLED but with hysteresis disabled.


Property Descriptions

ShadowCastingSettingcast_shadow =1🔗

The selected shadow casting flag. SeeShadowCastingSetting for possible values.


AABBcustom_aabb =AABB(0,0,0,0,0,0)🔗

Overrides the bounding box of this node with a custom one. This can be used to avoid the expensiveAABB recalculation that happens when a skeleton is used with aMeshInstance3D or to have precise control over theMeshInstance3D's bounding box. To use the default AABB, set value to anAABB with all fields set to0.0. To avoid frustum culling, setcustom_aabb to a very large AABB that covers your entire game world such asAABB(-10000,-10000,-10000,20000,20000,20000). To disable all forms of culling (including occlusion culling), callRenderingServer.instance_set_ignore_culling() on theGeometryInstance3D'sRID.


floatextra_cull_margin =0.0🔗

The extra distance added to the GeometryInstance3D's bounding box (AABB) to increase its cull box.


LightmapScalegi_lightmap_scale =0🔗

Deprecated: Usegi_lightmap_texel_scale instead.

The texel density to use for lightmapping inLightmapGI.


floatgi_lightmap_texel_scale =1.0🔗

The texel density to use for lightmapping inLightmapGI. Greater scale values provide higher resolution in the lightmap, which can result in sharper shadows for lights that have both direct and indirect light baked. However, greater scale values will also increase the space taken by the mesh in the lightmap texture, which increases the memory, storage, and bake time requirements. When using a single mesh at different scales, consider adjusting this value to keep the lightmap texel density consistent across meshes.

For example, doublinggi_lightmap_texel_scale doubles the lightmap texture resolution for this objecton each axis, so it willquadruple the texel count.


GIModegi_mode =1🔗

The global illumination mode to use for the whole geometry. To avoid inconsistent results, use a mode that matches the purpose of the mesh during gameplay (static/dynamic).

Note: Lights' bake mode will also affect the global illumination rendering. SeeLight3D.light_bake_mode.


boolignore_occlusion_culling =false🔗

Iftrue, disables occlusion culling for this instance. Useful for gizmos that must be rendered even when occlusion culling is in use.

Note:ignore_occlusion_culling does not affect frustum culling (which is what happens when an object is not visible given the camera's angle). To avoid frustum culling, setcustom_aabb to a very large AABB that covers your entire game world such asAABB(-10000,-10000,-10000,20000,20000,20000).


floatlod_bias =1.0🔗

Changes how quickly the mesh transitions to a lower level of detail. A value of 0 will force the mesh to its lowest level of detail, a value of 1 will use the default settings, and larger values will keep the mesh in a higher level of detail at farther distances.

Useful for testing level of detail transitions in the editor.


Materialmaterial_overlay🔗

The material overlay for the whole geometry.

If a material is assigned to this property, it will be rendered on top of any other active material for all the surfaces.


Materialmaterial_override🔗

The material override for the whole geometry.

If a material is assigned to this property, it will be used instead of any material set in any material slot of the mesh.


floattransparency =0.0🔗

The transparency applied to the whole geometry (as a multiplier of the materials' existing transparency).0.0 is fully opaque, while1.0 is fully transparent. Values greater than0.0 (exclusive) will force the geometry's materials to go through the transparent pipeline, which is slower to render and can exhibit rendering issues due to incorrect transparency sorting. However, unlike using a transparent material, settingtransparency to a value greater than0.0 (exclusive) willnot disable shadow rendering.

In spatial shaders,1.0-transparency is set as the default value of theALPHA built-in.

Note:transparency is clamped between0.0 and1.0, so this property cannot be used to make transparent materials more opaque than they originally are.

Note: Only supported when using the Forward+ rendering method. When using the Mobile or Compatibility rendering method,transparency is ignored and is considered as always being0.0.


floatvisibility_range_begin =0.0🔗

Starting distance from which the GeometryInstance3D will be visible, takingvisibility_range_begin_margin into account as well. The default value of 0 is used to disable the range check.


floatvisibility_range_begin_margin =0.0🔗

Margin for thevisibility_range_begin threshold. The GeometryInstance3D will only change its visibility state when it goes over or under thevisibility_range_begin threshold by this amount.

Ifvisibility_range_fade_mode isVISIBILITY_RANGE_FADE_DISABLED, this acts as a hysteresis distance. Ifvisibility_range_fade_mode isVISIBILITY_RANGE_FADE_SELF orVISIBILITY_RANGE_FADE_DEPENDENCIES, this acts as a fade transition distance and must be set to a value greater than0.0 for the effect to be noticeable.


floatvisibility_range_end =0.0🔗

Distance from which the GeometryInstance3D will be hidden, takingvisibility_range_end_margin into account as well. The default value of 0 is used to disable the range check.


floatvisibility_range_end_margin =0.0🔗

Margin for thevisibility_range_end threshold. The GeometryInstance3D will only change its visibility state when it goes over or under thevisibility_range_end threshold by this amount.

Ifvisibility_range_fade_mode isVISIBILITY_RANGE_FADE_DISABLED, this acts as a hysteresis distance. Ifvisibility_range_fade_mode isVISIBILITY_RANGE_FADE_SELF orVISIBILITY_RANGE_FADE_DEPENDENCIES, this acts as a fade transition distance and must be set to a value greater than0.0 for the effect to be noticeable.


VisibilityRangeFadeModevisibility_range_fade_mode =0🔗

Controls which instances will be faded when approaching the limits of the visibility range. SeeVisibilityRangeFadeMode for possible values.


Method Descriptions

Variantget_instance_shader_parameter(name:StringName)const🔗

Get the value of a shader parameter as set on this instance.


voidset_instance_shader_parameter(name:StringName, value:Variant)🔗

Set the value of a shader uniform for this instance only (per-instance uniform). See alsoShaderMaterial.set_shader_parameter() to assign a uniform on all instances using the sameShaderMaterial.

Note: For a shader uniform to be assignable on a per-instance basis, itmust be defined withinstanceuniform... rather thanuniform... in the shader code.

Note:name is case-sensitive and must match the name of the uniform in the code exactly (not the capitalized name in the inspector).

Note: Per-instance shader uniforms are only available in Spatial and CanvasItem shaders, but not for Fog, Sky, or Particles shaders.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.