Class GeometryInstance3D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Base node for geometry-based visual instances. Shares some common functionality like visibility and custom materials.
public class GeometryInstance3D : VisualInstance3D, IDisposable
- Inheritance
-
GeometryInstance3D
- Implements
- Derived
- Inherited Members
Constructors
GeometryInstance3D()
public GeometryInstance3D()
Properties
CastShadow
The selected shadow casting flag. See GeometryInstance3D.ShadowCastingSetting for possible values.
public GeometryInstance3D.ShadowCastingSetting CastShadow { get; set; }
Property Value
CustomAabb
Overrides the bounding box of this node with a custom one. This can be used to avoid the expensive Aabb recalculation that happens when a skeleton is used with a MeshInstance3D or to have precise control over the MeshInstance3D's bounding box. To use the default AABB, set value to an Aabb with all fields set to 0.0
. To avoid frustum culling, set CustomAabb to a very large AABB that covers your entire game world such as AABB(-10000, -10000, -10000, 20000, 20000, 20000)
. To disable all forms of culling (including occlusion culling), call InstanceSetIgnoreCulling(Rid, bool) on the GeometryInstance3D's Rid.
public Aabb CustomAabb { get; set; }
Property Value
ExtraCullMargin
The extra distance added to the GeometryInstance3D's bounding box (Aabb) to increase its cull box.
public float ExtraCullMargin { get; set; }
Property Value
GILightmapScale
The texel density to use for lightmapping in LightmapGI. 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.
public GeometryInstance3D.LightmapScale GILightmapScale { get; set; }
Property Value
GIMode
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. See LightBakeMode.
public GeometryInstance3D.GIModeEnum GIMode { get; set; }
Property Value
IgnoreOcclusionCulling
If true
, disables occlusion culling for this instance. Useful for gizmos that must be rendered even when occlusion culling is in use.
Note:
IgnoreOcclusionCulling does not affect frustum culling (which is what happens when an object is not visible given the camera's angle). To avoid frustum culling, set CustomAabb to a very large AABB that covers your entire game world such as AABB(-10000, -10000, -10000, 20000, 20000, 20000)
.
public bool IgnoreOcclusionCulling { get; set; }
Property Value
LodBias
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.
public float LodBias { get; set; }
Property Value
MaterialOverlay
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.
public Material MaterialOverlay { get; set; }
Property Value
MaterialOverride
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.
public Material MaterialOverride { get; set; }
Property Value
Transparency
The transparency applied to the whole geometry (as a multiplier of the materials' existing transparency). 0.0
is fully opaque, while 1.0
is fully transparent. Values greater than 0.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, setting Transparency to a value greater than 0.0
(exclusive) will not disable shadow rendering.
In spatial shaders, 1.0 - transparency
is set as the default value of the ALPHA
built-in.
Note:
Transparency is clamped between 0.0
and 1.0
, so this property cannot be used to make transparent materials more opaque than they originally are.
public float Transparency { get; set; }
Property Value
VisibilityRangeBegin
Starting distance from which the GeometryInstance3D will be visible, taking VisibilityRangeBeginMargin into account as well. The default value of 0 is used to disable the range check.
public float VisibilityRangeBegin { get; set; }
Property Value
VisibilityRangeBeginMargin
Margin for the VisibilityRangeBegin threshold. The GeometryInstance3D will only change its visibility state when it goes over or under the VisibilityRangeBegin threshold by this amount.
If VisibilityRangeFadeMode is Disabled, this acts as a hysteresis distance. If VisibilityRangeFadeMode is Self or Dependencies, this acts as a fade transition distance and must be set to a value greater than 0.0
for the effect to be noticeable.
public float VisibilityRangeBeginMargin { get; set; }
Property Value
VisibilityRangeEnd
Distance from which the GeometryInstance3D will be hidden, taking VisibilityRangeEndMargin into account as well. The default value of 0 is used to disable the range check.
public float VisibilityRangeEnd { get; set; }
Property Value
VisibilityRangeEndMargin
Margin for the VisibilityRangeEnd threshold. The GeometryInstance3D will only change its visibility state when it goes over or under the VisibilityRangeEnd threshold by this amount.
If VisibilityRangeFadeMode is Disabled, this acts as a hysteresis distance. If VisibilityRangeFadeMode is Self or Dependencies, this acts as a fade transition distance and must be set to a value greater than 0.0
for the effect to be noticeable.
public float VisibilityRangeEndMargin { get; set; }
Property Value
VisibilityRangeFadeMode
Controls which instances will be faded when approaching the limits of the visibility range. See GeometryInstance3D.VisibilityRangeFadeModeEnum for possible values.
public GeometryInstance3D.VisibilityRangeFadeModeEnum VisibilityRangeFadeMode { get; set; }
Property Value
Methods
GetInstanceShaderParameter(StringName)
Get the value of a shader parameter as set on this instance.
public Variant GetInstanceShaderParameter(StringName name)
Parameters
name
StringName
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
SetInstanceShaderParameter(StringName, Variant)
Set the value of a shader uniform for this instance only (per-instance uniform). See also SetShaderParameter(StringName, Variant) to assign a uniform on all instances using the same ShaderMaterial.
Note: For a shader uniform to be assignable on a per-instance basis, it must be defined with instance uniform ...
rather than uniform ...
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 currently only available in 3D, so there is no 2D equivalent of this method.
public void SetInstanceShaderParameter(StringName name, Variant value)
Parameters
name
StringNamevalue
Variant