Light2D

package
v0.0.0-...-357ca8a Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Casts light in a 2D environment. A light is defined as a color, an energy value, a mode (see constants), and various other parameters (range and shadows-related).

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 Any

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

type BlendMode

type BlendMode int //gd:Light2D.BlendMode
const (
	// Adds the value of pixels corresponding to the Light2D to the values of pixels under it. This is the common behavior of a light.
	BlendModeAdd BlendMode = 0
	// Subtracts the value of pixels corresponding to the Light2D to the values of pixels under it, resulting in inversed light effect.
	BlendModeSub BlendMode = 1
	// Mix the value of pixels corresponding to the Light2D to the values of pixels under it by linear interpolation.
	BlendModeMix BlendMode = 2
)

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

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsLight2D

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

func (*Extension[T]) AsNode

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

func (*Extension[T]) AsNode2D

func (self *Extension[T]) AsNode2D() Node2D.Instance

func (*Extension[T]) AsObject

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

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.Light2D

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) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsLight2D

func (self Instance) AsLight2D() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode2D

func (self Instance) AsNode2D() Node2D.Instance

func (Instance) AsObject

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

func (Instance) BlendMode

func (self Instance) BlendMode() BlendMode

The Light2D's blend mode.

func (Instance) Color

func (self Instance) Color() Color.RGBA

The Light2D's Color.RGBA.

func (Instance) EditorOnly

func (self Instance) EditorOnly() bool

If true, Light2D will only appear when editing the scene.

func (Instance) Enabled

func (self Instance) Enabled() bool

If true, Light2D will emit light.

func (Instance) Energy

func (self Instance) Energy() Float.X

The Light2D's energy value. The larger the value, the stronger the light.

func (Instance) GetHeight

func (self Instance) GetHeight() Float.X

Returns the light's height, which is used in 2D normal mapping. See PointLight2D.Height and DirectionalLight2D.Height.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) RangeItemCullMask

func (self Instance) RangeItemCullMask() int

The layer mask. Only objects with a matching CanvasItem.LightMask will be affected by the Light2D. See also ShadowItemCullMask, which affects which objects can cast shadows.

Note: RangeItemCullMask is ignored by DirectionalLight2D, which will always light a 2D node regardless of the 2D node's CanvasItem.LightMask.

func (Instance) RangeLayerMax

func (self Instance) RangeLayerMax() int

Maximum layer value of objects that are affected by the Light2D.

func (Instance) RangeLayerMin

func (self Instance) RangeLayerMin() int

Minimum layer value of objects that are affected by the Light2D.

func (Instance) RangeZMax

func (self Instance) RangeZMax() int

Maximum z value of objects that are affected by the Light2D.

func (Instance) RangeZMin

func (self Instance) RangeZMin() int

Minimum z value of objects that are affected by the Light2D.

func (Instance) SetBlendMode

func (self Instance) SetBlendMode(value BlendMode)

SetBlendMode sets the property returned by [GetBlendMode].

func (Instance) SetColor

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

SetColor sets the property returned by [GetColor].

func (Instance) SetEditorOnly

func (self Instance) SetEditorOnly(value bool)

SetEditorOnly sets the property returned by [IsEditorOnly].

func (Instance) SetEnabled

func (self Instance) SetEnabled(value bool)

SetEnabled sets the property returned by [IsEnabled].

func (Instance) SetEnergy

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

SetEnergy sets the property returned by [GetEnergy].

func (Instance) SetHeight

func (self Instance) SetHeight(height Float.X)

Sets the light's height, which is used in 2D normal mapping. See PointLight2D.Height and DirectionalLight2D.Height.

func (*Instance) SetObject

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

func (Instance) SetRangeItemCullMask

func (self Instance) SetRangeItemCullMask(value int)

SetRangeItemCullMask sets the property returned by [GetItemCullMask].

func (Instance) SetRangeLayerMax

func (self Instance) SetRangeLayerMax(value int)

SetRangeLayerMax sets the property returned by [GetLayerRangeMax].

func (Instance) SetRangeLayerMin

func (self Instance) SetRangeLayerMin(value int)

SetRangeLayerMin sets the property returned by [GetLayerRangeMin].

func (Instance) SetRangeZMax

func (self Instance) SetRangeZMax(value int)

SetRangeZMax sets the property returned by [GetZRangeMax].

func (Instance) SetRangeZMin

func (self Instance) SetRangeZMin(value int)

SetRangeZMin sets the property returned by [GetZRangeMin].

func (Instance) SetShadowColor

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

SetShadowColor sets the property returned by [GetShadowColor].

func (Instance) SetShadowEnabled

func (self Instance) SetShadowEnabled(value bool)

SetShadowEnabled sets the property returned by [IsShadowEnabled].

func (Instance) SetShadowFilter

func (self Instance) SetShadowFilter(value ShadowFilter)

SetShadowFilter sets the property returned by [GetShadowFilter].

func (Instance) SetShadowFilterSmooth

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

SetShadowFilterSmooth sets the property returned by [GetShadowSmooth].

func (Instance) SetShadowItemCullMask

func (self Instance) SetShadowItemCullMask(value int)

SetShadowItemCullMask sets the property returned by [GetItemShadowCullMask].

func (Instance) ShadowColor

func (self Instance) ShadowColor() Color.RGBA

Color.RGBA of shadows cast by the Light2D.

func (Instance) ShadowEnabled

func (self Instance) ShadowEnabled() bool

If true, the Light2D will cast shadows.

func (Instance) ShadowFilter

func (self Instance) ShadowFilter() ShadowFilter

Shadow filter type.

func (Instance) ShadowFilterSmooth

func (self Instance) ShadowFilterSmooth() Float.X

Smoothing value for shadows. Higher values will result in softer shadows, at the cost of visible streaks that can appear in shadow rendering. ShadowFilterSmooth only has an effect if ShadowFilter is ShadowFilterPcf5 or ShadowFilterPcf13.

func (Instance) ShadowItemCullMask

func (self Instance) ShadowItemCullMask() int

The shadow mask. Used with LightOccluder2D to cast shadows. Only occluders with a matching CanvasItem.LightMask will cast shadows. See also RangeItemCullMask, which affects which objects can receive the light.

func (Instance) Virtual

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

type ShadowFilter

type ShadowFilter int //gd:Light2D.ShadowFilter
const (
	// No filter applies to the shadow map. This provides hard shadow edges and is the fastest to render. See [ShadowFilter].
	//
	// [ShadowFilter]: https://pkg.go.dev/graphics.gd/classdb/#Instance.ShadowFilter
	ShadowFilterNone ShadowFilter = 0
	// Percentage closer filtering (5 samples) applies to the shadow map. This is slower compared to hard shadow rendering. See [ShadowFilter].
	//
	// [ShadowFilter]: https://pkg.go.dev/graphics.gd/classdb/#Instance.ShadowFilter
	ShadowFilterPcf5 ShadowFilter = 1
	// Percentage closer filtering (13 samples) applies to the shadow map. This is the slowest shadow filtering mode, and should be used sparingly. See [ShadowFilter].
	//
	// [ShadowFilter]: https://pkg.go.dev/graphics.gd/classdb/#Instance.ShadowFilter
	ShadowFilterPcf13 ShadowFilter = 2
)

Jump to

Keyboard shortcuts

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