ReflectionProbe

package
v0.0.0-...-20ed0ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Captures its surroundings as a cubemap, and stores versions of it with increasing levels of blur to simulate different material roughnesses.

The ReflectionProbe is used to create high-quality reflections at a low performance cost (when UpdateMode is UpdateOnce). ReflectionProbes can be blended together and with the rest of the scene smoothly. ReflectionProbes can also be combined with VoxelGI, SDFGI (Environment.SdfgiEnabled) and screen-space reflections (Environment.SsrEnabled) to get more accurate reflections in specific areas. ReflectionProbes render all objects within their CullMask, so updating them can be quite expensive. It is best to update them once with the important static objects and then leave them as-is.

Note: Unlike VoxelGI and SDFGI, ReflectionProbes only source their environment from a WorldEnvironment node. If you specify an Environment resource within a Camera3D node, it will be ignored by the ReflectionProbe. This can lead to incorrect lighting within the ReflectionProbe.

Note: When using the Mobile rendering method, only 8 reflection probes can be displayed on each mesh resource, while the Compatibility rendering method only supports up to 2 reflection probes on each mesh. Attempting to display more than 8 reflection probes on a single mesh resource using the Mobile renderer will result in reflection probes flickering in and out as the camera moves, while the Compatibility renderer will not render any additional probes if more than 2 reflection probes are being used.

Note: When using the Mobile rendering method, reflection probes will only correctly affect meshes whose visibility AABB intersects with the reflection probe's AABB. If using a shader to deform the mesh in a way that makes it go outside its AABB, GeometryInstance3D.ExtraCullMargin must be increased on the mesh. Otherwise, the reflection probe may not be visible on the mesh.

Index

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 AmbientMode

type AmbientMode int //gd:ReflectionProbe.AmbientMode
const (
	// Do not apply any ambient lighting inside the [ReflectionProbe]'s box defined by its [Size].
	//
	// [ReflectionProbe]: https://pkg.go.dev/graphics.gd/classdb/ReflectionProbe
	// [Size]: https://pkg.go.dev/graphics.gd/classdb/#Instance.Size
	AmbientDisabled AmbientMode = 0
	// Apply automatically-sourced environment lighting inside the [ReflectionProbe]'s box defined by its [Size].
	//
	// [ReflectionProbe]: https://pkg.go.dev/graphics.gd/classdb/ReflectionProbe
	// [Size]: https://pkg.go.dev/graphics.gd/classdb/#Instance.Size
	AmbientEnvironment AmbientMode = 1
	// Apply custom ambient lighting inside the [ReflectionProbe]'s box defined by its [Size]. See [AmbientColor] and [AmbientColorEnergy].
	//
	// [AmbientColor]: https://pkg.go.dev/graphics.gd/classdb/#Instance.AmbientColor
	// [AmbientColorEnergy]: https://pkg.go.dev/graphics.gd/classdb/#Instance.AmbientColorEnergy
	// [ReflectionProbe]: https://pkg.go.dev/graphics.gd/classdb/ReflectionProbe
	// [Size]: https://pkg.go.dev/graphics.gd/classdb/#Instance.Size
	AmbientColor AmbientMode = 2
)

type Any

type Any interface {
	gd.IsClass
	AsReflectionProbe() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode3D

func (self *Extension[T]) AsNode3D() Node3D.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsReflectionProbe

func (self *Extension[T]) AsReflectionProbe() Instance

func (*Extension[T]) AsVisualInstance3D

func (self *Extension[T]) AsVisualInstance3D() VisualInstance3D.Instance

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.ReflectionProbe

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 New

func New() Instance

func (Instance) AmbientColor

func (self Instance) AmbientColor() Color.RGBA

The custom ambient color to use within the ReflectionProbe's box defined by its Size. Only effective if AmbientMode is AmbientColor.

func (Instance) AmbientColorEnergy

func (self Instance) AmbientColorEnergy() Float.X

The custom ambient color energy to use within the ReflectionProbe's box defined by its Size. Only effective if AmbientMode is AmbientColor.

func (Instance) AmbientMode

func (self Instance) AmbientMode() AmbientMode

The ambient color to use within the ReflectionProbe's box defined by its Size. The ambient color will smoothly blend with other ReflectionProbes and the rest of the scene (outside the ReflectionProbe's box defined by its Size).

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode3D

func (self Instance) AsNode3D() Node3D.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsReflectionProbe

func (self Instance) AsReflectionProbe() Instance

func (Instance) AsVisualInstance3D

func (self Instance) AsVisualInstance3D() VisualInstance3D.Instance

func (Instance) BlendDistance

func (self Instance) BlendDistance() Float.X

Defines the distance in meters over which a probe blends into the scene.

func (Instance) BoxProjection

func (self Instance) BoxProjection() bool

If true, enables box projection. This makes reflections look more correct in rectangle-shaped rooms by offsetting the reflection center depending on the camera's location.

Note: To better fit rectangle-shaped rooms that are not aligned to the grid, you can rotate the ReflectionProbe node.

func (Instance) CullMask

func (self Instance) CullMask() int

Sets the cull mask which determines what objects are drawn by this probe. Every VisualInstance3D with a layer included in this cull mask will be rendered by the probe. It is best to only include large objects which are likely to take up a lot of space in the reflection in order to save on rendering cost.

This can also be used to prevent an object from reflecting upon itself (for instance, a ReflectionProbe centered on a vehicle).

func (Instance) EnableShadows

func (self Instance) EnableShadows() bool

If true, computes shadows in the reflection probe. This makes the reflection probe slower to render; you may want to disable this if using the UpdateAlways UpdateMode.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) Intensity

func (self Instance) Intensity() Float.X

Defines the reflection intensity. Intensity modulates the strength of the reflection.

func (Instance) Interior

func (self Instance) Interior() bool

If true, reflections will ignore sky contribution.

func (Instance) MaxDistance

func (self Instance) MaxDistance() Float.X

The maximum distance away from the ReflectionProbe an object can be before it is culled. Decrease this to improve performance, especially when using the UpdateAlways UpdateMode.

Note: The maximum reflection distance is always at least equal to the probe's extents. This means that decreasing MaxDistance will not always cull objects from reflections, especially if the reflection probe's box defined by its Size is already large.

func (Instance) MeshLodThreshold

func (self Instance) MeshLodThreshold() Float.X

The automatic LOD bias to use for meshes rendered within the ReflectionProbe (this is analog to Viewport.MeshLodThreshold). Higher values will use less detailed versions of meshes that have LOD variations generated. If set to 0.0, automatic LOD is disabled. Increase MeshLodThreshold to improve performance at the cost of geometry detail, especially when using the UpdateAlways UpdateMode.

Note: MeshLodThreshold does not affect GeometryInstance3D visibility ranges (also known as "manual" LOD or hierarchical LOD).

func (Instance) OriginOffset

func (self Instance) OriginOffset() Vector3.XYZ

Sets the origin offset to be used when this ReflectionProbe is in BoxProjection mode. This can be set to a non-zero value to ensure a reflection fits a rectangle-shaped room, while reducing the number of objects that "get in the way" of the reflection.

func (Instance) ReflectionMask

func (self Instance) ReflectionMask() int

Sets the reflection mask which determines what objects have reflections applied from this probe. Every VisualInstance3D with a layer included in this reflection mask will have reflections applied from this probe. See also CullMask, which can be used to exclude objects from appearing in the reflection while still making them affected by the ReflectionProbe.

func (Instance) SetAmbientColor

func (self Instance) SetAmbientColor(value Color.RGBA)

SetAmbientColor sets the property returned by [GetAmbientColor].

func (Instance) SetAmbientColorEnergy

func (self Instance) SetAmbientColorEnergy(value Float.X)

SetAmbientColorEnergy sets the property returned by [GetAmbientColorEnergy].

func (Instance) SetAmbientMode

func (self Instance) SetAmbientMode(value AmbientMode)

SetAmbientMode sets the property returned by [GetAmbientMode].

func (Instance) SetBlendDistance

func (self Instance) SetBlendDistance(value Float.X)

SetBlendDistance sets the property returned by [GetBlendDistance].

func (Instance) SetBoxProjection

func (self Instance) SetBoxProjection(value bool)

SetBoxProjection sets the property returned by [IsBoxProjectionEnabled].

func (Instance) SetCullMask

func (self Instance) SetCullMask(value int)

SetCullMask sets the property returned by [GetCullMask].

func (Instance) SetEnableShadows

func (self Instance) SetEnableShadows(value bool)

SetEnableShadows sets the property returned by [AreShadowsEnabled].

func (Instance) SetIntensity

func (self Instance) SetIntensity(value Float.X)

SetIntensity sets the property returned by [GetIntensity].

func (Instance) SetInterior

func (self Instance) SetInterior(value bool)

SetInterior sets the property returned by [IsSetAsInterior].

func (Instance) SetMaxDistance

func (self Instance) SetMaxDistance(value Float.X)

SetMaxDistance sets the property returned by [GetMaxDistance].

func (Instance) SetMeshLodThreshold

func (self Instance) SetMeshLodThreshold(value Float.X)

SetMeshLodThreshold sets the property returned by [GetMeshLodThreshold].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetOriginOffset

func (self Instance) SetOriginOffset(value Vector3.XYZ)

SetOriginOffset sets the property returned by [GetOriginOffset].

func (Instance) SetReflectionMask

func (self Instance) SetReflectionMask(value int)

SetReflectionMask sets the property returned by [GetReflectionMask].

func (Instance) SetSize

func (self Instance) SetSize(value Vector3.XYZ)

SetSize sets the property returned by [GetSize].

func (Instance) SetUpdateMode

func (self Instance) SetUpdateMode(value UpdateMode)

SetUpdateMode sets the property returned by [GetUpdateMode].

func (Instance) Size

func (self Instance) Size() Vector3.XYZ

The size of the reflection probe. The larger the size, the more space covered by the probe, which will lower the perceived resolution. It is best to keep the size only as large as you need it.

Note: To better fit areas that are not aligned to the grid, you can rotate the ReflectionProbe node.

func (Instance) UpdateMode

func (self Instance) UpdateMode() UpdateMode

Sets how frequently the ReflectionProbe is updated. Can be UpdateOnce or UpdateAlways.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type UpdateMode

type UpdateMode int //gd:ReflectionProbe.UpdateMode
const (
	// Update the probe once on the next frame (recommended for most objects). The corresponding radiance map will be generated over the following six frames. This takes more time to update than [UpdateAlways], but it has a lower performance cost and can result in higher-quality reflections. The ReflectionProbe is updated when its transform changes, but not when nearby geometry changes. You can force a [ReflectionProbe] update by moving the [ReflectionProbe] slightly in any direction.
	//
	// [ReflectionProbe]: https://pkg.go.dev/graphics.gd/classdb/ReflectionProbe
	UpdateOnce UpdateMode = 0
	// Update the probe every frame. This provides better results for fast-moving dynamic objects (such as cars). However, it has a significant performance cost. Due to the cost, it's recommended to only use one ReflectionProbe with [UpdateAlways] at most per scene. For all other use cases, use [UpdateOnce].
	UpdateAlways UpdateMode = 1
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL