Documentation
¶
Overview ¶
Base node for geometry-based visual instances. Shares some common functionality like visibility and custom materials.
Index ¶
- type Advanced
- type Any
- type Extension
- type GIMode
- type ID
- type Instance
- func (self Instance) AsGeometryInstance3D() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode3D() Node3D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsVisualInstance3D() VisualInstance3D.Instance
- func (self Instance) CastShadow() ShadowCastingSetting
- func (self Instance) CustomAabb() AABB.PositionSize
- func (self Instance) ExtraCullMargin() Float.X
- func (self Instance) GetInstanceShaderParameter(name string) any
- func (self Instance) GiLightmapScale() LightmapScale
- func (self Instance) GiLightmapTexelScale() Float.X
- func (self Instance) GiMode() GIMode
- func (self Instance) ID() ID
- func (self Instance) IgnoreOcclusionCulling() bool
- func (self Instance) LodBias() Float.X
- func (self Instance) MaterialOverlay() Material.Instance
- func (self Instance) MaterialOverride() Material.Instance
- func (self Instance) SetCastShadow(value ShadowCastingSetting)
- func (self Instance) SetCustomAabb(value AABB.PositionSize)
- func (self Instance) SetExtraCullMargin(value Float.X)
- func (self Instance) SetGiLightmapScale(value LightmapScale)
- func (self Instance) SetGiLightmapTexelScale(value Float.X)
- func (self Instance) SetGiMode(value GIMode)
- func (self Instance) SetIgnoreOcclusionCulling(value bool)
- func (self Instance) SetInstanceShaderParameter(name string, value any)
- func (self Instance) SetLodBias(value Float.X)
- func (self Instance) SetMaterialOverlay(value Material.Instance)
- func (self Instance) SetMaterialOverride(value Material.Instance)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetTransparency(value Float.X)
- func (self Instance) SetVisibilityRangeBegin(value Float.X)
- func (self Instance) SetVisibilityRangeBeginMargin(value Float.X)
- func (self Instance) SetVisibilityRangeEnd(value Float.X)
- func (self Instance) SetVisibilityRangeEndMargin(value Float.X)
- func (self Instance) SetVisibilityRangeFadeMode(value VisibilityRangeFadeMode)
- func (self Instance) Transparency() Float.X
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) VisibilityRangeBegin() Float.X
- func (self Instance) VisibilityRangeBeginMargin() Float.X
- func (self Instance) VisibilityRangeEnd() Float.X
- func (self Instance) VisibilityRangeEndMargin() Float.X
- func (self Instance) VisibilityRangeFadeMode() VisibilityRangeFadeMode
- type LightmapScale
- type ShadowCastingSetting
- type VisibilityRangeFadeMode
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]) AsGeometryInstance3D ¶
func (*Extension[T]) AsVisualInstance3D ¶
func (self *Extension[T]) AsVisualInstance3D() VisualInstance3D.Instance
type GIMode ¶
type GIMode int //gd:GeometryInstance3D.GIMode
const ( // Disabled global illumination mode. Use for dynamic objects that do not contribute to global illumination (such as characters). When using [VoxelGI] and SDFGI, the geometry will receive indirect lighting and reflections but the geometry will not be considered in GI baking. // // [VoxelGI]: https://pkg.go.dev/graphics.gd/classdb/VoxelGI GiModeDisabled GIMode = 0 // Baked global illumination mode. Use for static objects that contribute to global illumination (such as level geometry). This GI mode is effective when using [VoxelGI], SDFGI and [LightmapGI]. // // [LightmapGI]: https://pkg.go.dev/graphics.gd/classdb/LightmapGI // [VoxelGI]: https://pkg.go.dev/graphics.gd/classdb/VoxelGI GiModeStatic GIMode = 1 // Dynamic global illumination mode. Use for dynamic objects that contribute to global illumination. This GI mode is only effective when using [VoxelGI], but it has a higher performance impact than [GiModeStatic]. When using other GI methods, this will act the same as [GiModeDisabled]. When using [LightmapGI], the object will receive indirect lighting using lightmap probes instead of using the baked lightmap texture. // // [LightmapGI]: https://pkg.go.dev/graphics.gd/classdb/LightmapGI // [VoxelGI]: https://pkg.go.dev/graphics.gd/classdb/VoxelGI GiModeDynamic GIMode = 2 )
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 ¶
type Instance [1]gdclass.GeometryInstance3D
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) AsGeometryInstance3D ¶
func (Instance) AsVisualInstance3D ¶
func (self Instance) AsVisualInstance3D() VisualInstance3D.Instance
func (Instance) CastShadow ¶
func (self Instance) CastShadow() ShadowCastingSetting
The selected shadow casting flag.
func (Instance) CustomAabb ¶
func (self Instance) CustomAabb() AABB.PositionSize
Overrides the bounding box of this node with a custom one. This can be used to avoid the expensive AABB.PositionSize 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.PositionSize 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 RenderingServer.InstanceSetIgnoreCulling on the GeometryInstance3D's Resource.ID.
func (Instance) ExtraCullMargin ¶
The extra distance added to the GeometryInstance3D's bounding box (AABB.PositionSize) to increase its cull box.
func (Instance) GetInstanceShaderParameter ¶
Get the value of a shader parameter as set on this instance.
func (Instance) GiLightmapScale ¶
func (self Instance) GiLightmapScale() LightmapScale
The texel density to use for lightmapping in LightmapGI.
func (Instance) GiLightmapTexelScale ¶
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.
For example, doubling GiLightmapTexelScale doubles the lightmap texture resolution for this object on each axis, so it will quadruple the texel count.
func (Instance) 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 Light3D.LightBakeMode.
func (Instance) 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).
func (Instance) 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.
func (Instance) 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.
func (Instance) 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.
func (Instance) SetCastShadow ¶
func (self Instance) SetCastShadow(value ShadowCastingSetting)
SetCastShadow sets the property returned by [GetCastShadowsSetting].
func (Instance) SetCustomAabb ¶
func (self Instance) SetCustomAabb(value AABB.PositionSize)
SetCustomAabb sets the property returned by [GetCustomAabb].
func (Instance) SetExtraCullMargin ¶
SetExtraCullMargin sets the property returned by [GetExtraCullMargin].
func (Instance) SetGiLightmapScale ¶
func (self Instance) SetGiLightmapScale(value LightmapScale)
SetGiLightmapScale sets the property returned by [GetLightmapScale].
func (Instance) SetGiLightmapTexelScale ¶
SetGiLightmapTexelScale sets the property returned by [GetLightmapTexelScale].
func (Instance) SetIgnoreOcclusionCulling ¶
SetIgnoreOcclusionCulling sets the property returned by [IsIgnoringOcclusionCulling].
func (Instance) SetInstanceShaderParameter ¶
Set the value of a shader uniform for this instance only (per-instance uniform). See also ShaderMaterial.SetShaderParameter 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 only available in Spatial and CanvasItem shaders, but not for Fog, Sky, or Particles shaders.
func (Instance) SetLodBias ¶
SetLodBias sets the property returned by [GetLodBias].
func (Instance) SetMaterialOverlay ¶
SetMaterialOverlay sets the property returned by [GetMaterialOverlay].
func (Instance) SetMaterialOverride ¶
SetMaterialOverride sets the property returned by [GetMaterialOverride].
func (Instance) SetTransparency ¶
SetTransparency sets the property returned by [GetTransparency].
func (Instance) SetVisibilityRangeBegin ¶
SetVisibilityRangeBegin sets the property returned by [GetVisibilityRangeBegin].
func (Instance) SetVisibilityRangeBeginMargin ¶
SetVisibilityRangeBeginMargin sets the property returned by [GetVisibilityRangeBeginMargin].
func (Instance) SetVisibilityRangeEnd ¶
SetVisibilityRangeEnd sets the property returned by [GetVisibilityRangeEnd].
func (Instance) SetVisibilityRangeEndMargin ¶
SetVisibilityRangeEndMargin sets the property returned by [GetVisibilityRangeEndMargin].
func (Instance) SetVisibilityRangeFadeMode ¶
func (self Instance) SetVisibilityRangeFadeMode(value VisibilityRangeFadeMode)
SetVisibilityRangeFadeMode sets the property returned by [GetVisibilityRangeFadeMode].
func (Instance) 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.
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 being 0.0.
func (Instance) 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.
func (Instance) 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 VisibilityRangeFadeDisabled, this acts as a hysteresis distance. If VisibilityRangeFadeMode is VisibilityRangeFadeSelf or VisibilityRangeFadeDependencies, this acts as a fade transition distance and must be set to a value greater than 0.0 for the effect to be noticeable.
func (Instance) 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.
func (Instance) 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 VisibilityRangeFadeDisabled, this acts as a hysteresis distance. If VisibilityRangeFadeMode is VisibilityRangeFadeSelf or VisibilityRangeFadeDependencies, this acts as a fade transition distance and must be set to a value greater than 0.0 for the effect to be noticeable.
func (Instance) VisibilityRangeFadeMode ¶
func (self Instance) VisibilityRangeFadeMode() VisibilityRangeFadeMode
Controls which instances will be faded when approaching the limits of the visibility range.
type LightmapScale ¶
type LightmapScale int //gd:GeometryInstance3D.LightmapScale
const ( // The standard texel density for lightmapping with [LightmapGI]. // // [LightmapGI]: https://pkg.go.dev/graphics.gd/classdb/LightmapGI LightmapScale1x LightmapScale = 0 // Multiplies texel density by 2× for lightmapping with [LightmapGI]. To ensure consistency in texel density, use this when scaling a mesh by a factor between 1.5 and 3.0. // // [LightmapGI]: https://pkg.go.dev/graphics.gd/classdb/LightmapGI LightmapScale2x LightmapScale = 1 // Multiplies texel density by 4× for lightmapping with [LightmapGI]. To ensure consistency in texel density, use this when scaling a mesh by a factor between 3.0 and 6.0. // // [LightmapGI]: https://pkg.go.dev/graphics.gd/classdb/LightmapGI LightmapScale4x LightmapScale = 2 // Multiplies texel density by 8× for lightmapping with [LightmapGI]. To ensure consistency in texel density, use this when scaling a mesh by a factor greater than 6.0. // // [LightmapGI]: https://pkg.go.dev/graphics.gd/classdb/LightmapGI LightmapScale8x LightmapScale = 3 // Represents the size of the [LightmapScale] enum. LightmapScaleMax LightmapScale = 4 )
type ShadowCastingSetting ¶
type ShadowCastingSetting int //gd:GeometryInstance3D.ShadowCastingSetting
const ( // Will not cast any shadows. Use this to improve performance for small geometry that is unlikely to cast noticeable shadows (such as debris). ShadowCastingSettingOff ShadowCastingSetting = 0 // 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. ShadowCastingSettingOn ShadowCastingSetting = 1 // 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. ShadowCastingSettingDoubleSided ShadowCastingSetting = 2 // 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. ShadowCastingSettingShadowsOnly ShadowCastingSetting = 3 )
type VisibilityRangeFadeMode ¶
type VisibilityRangeFadeMode int //gd:GeometryInstance3D.VisibilityRangeFadeMode
const ( // 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. See [VisibilityRangeBegin] and [Node3D.VisibilityParent] for more information. // // [Node3D.VisibilityParent]: https://pkg.go.dev/graphics.gd/classdb/Node3D#Instance.VisibilityParent // [VisibilityRangeBegin]: https://pkg.go.dev/graphics.gd/classdb/#Instance.VisibilityRangeBegin VisibilityRangeFadeDisabled VisibilityRangeFadeMode = 0 // Will fade-out itself when reaching the limits of its own visibility range. This is slower than [VisibilityRangeFadeDisabled], but it can provide smoother transitions. The fading range is determined by [VisibilityRangeBeginMargin] and [VisibilityRangeEndMargin]. // // Note: Only supported when using the Forward+ rendering method. When using the Mobile or Compatibility rendering method, this mode acts like [VisibilityRangeFadeDisabled] but with hysteresis disabled. // // [VisibilityRangeBeginMargin]: https://pkg.go.dev/graphics.gd/classdb/#Instance.VisibilityRangeBeginMargin // [VisibilityRangeEndMargin]: https://pkg.go.dev/graphics.gd/classdb/#Instance.VisibilityRangeEndMargin VisibilityRangeFadeSelf VisibilityRangeFadeMode = 1 // Will fade-in its visibility dependencies (see [Node3D.VisibilityParent]) when reaching the limits of its own visibility range. This is slower than [VisibilityRangeFadeDisabled], but it can provide smoother transitions. The fading range is determined by [VisibilityRangeBeginMargin] and [VisibilityRangeEndMargin]. // // Note: Only supported when using the Forward+ rendering method. When using the Mobile or Compatibility rendering method, this mode acts like [VisibilityRangeFadeDisabled] but with hysteresis disabled. // // [Node3D.VisibilityParent]: https://pkg.go.dev/graphics.gd/classdb/Node3D#Instance.VisibilityParent // [VisibilityRangeBeginMargin]: https://pkg.go.dev/graphics.gd/classdb/#Instance.VisibilityRangeBeginMargin // [VisibilityRangeEndMargin]: https://pkg.go.dev/graphics.gd/classdb/#Instance.VisibilityRangeEndMargin VisibilityRangeFadeDependencies VisibilityRangeFadeMode = 2 )