Casts light in a 2D environment.
    public class Light2D : Node2D

Casts light in a 2D environment. Light is defined by a (usually grayscale) texture, a color, an energy value, a mode (see constants), and various other parameters (range and shadows-related). Note that Light2D can be used as a mask.

Inheritance Chain

Constructors

    public Light2D()

Properties

    public Color Color { get; set; }

The Light2D’s Color.

    public bool EditorOnly { get; set; }

If true, Light2D will only appear when editing the scene. Default value: false.

    public bool Enabled { get; set; }

If true, Light2D will emit light. Default value: true.

    public float Energy { get; set; }

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

    public ModeEnum Mode { get; set; }

The Light2D’s mode. See MODE_* constants for values.

    public Vector2 Offset { get; set; }

The offset of the Light2D’s texture.

    public float RangeHeight { get; set; }

The height of the Light2D. Used with 2D normal mapping.

    public int RangeItemCullMask { get; set; }

The layer mask. Only objects with a matching mask will be affected by the Light2D.

    public int RangeLayerMax { get; set; }

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

    public int RangeLayerMin { get; set; }

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

    public int RangeZMax { get; set; }

Maximum Z value of objects that are affected by the Light2D. Default value: 1024.

    public int RangeZMin { get; set; }

Minimum z value of objects that are affected by the Light2D. Default value: -1024.

    public int ShadowBufferSize { get; set; }

Shadow buffer size. Default value: 2048.

    public Color ShadowColor { get; set; }

Color of shadows cast by the Light2D.

    public bool ShadowEnabled { get; set; }

If true, the Light2D will cast shadows. Default value: false.

    public ShadowFilterEnum ShadowFilter { get; set; }

Shadow filter type. Use ShadowFilter constants as values. Default value: SHADOW_FILTER_NONE.

    public float ShadowFilterSmooth { get; set; }

Smoothing value for shadows.

    public float ShadowGradientLength { get; set; }

Smooth shadow gradient length.

    public int ShadowItemCullMask { get; set; }

The shadow mask. Used with LightOccluder2D to cast shadows. Only occluders with a matching shadow mask will cast shadows.

    public Texture Texture { get; set; }

Texture used for the Light2D’s appearance.

    public float TextureScale { get; set; }

The texture’s scale factor.

Methods

    public Color GetColor()

Getter for Color

    public float GetEnergy()

Getter for Energy

    public float GetHeight()

Getter for RangeHeight

    public int GetItemCullMask()

Getter for RangeItemCullMask

    public int GetItemShadowCullMask()

Getter for ShadowItemCullMask

    public int GetLayerRangeMax()

Getter for RangeLayerMax

    public int GetLayerRangeMin()

Getter for RangeLayerMin

    public ModeEnum GetMode()

Getter for Mode

    public int GetShadowBufferSize()

Getter for ShadowBufferSize

    public Color GetShadowColor()

Getter for ShadowColor

    public ShadowFilterEnum GetShadowFilter()

Getter for ShadowFilter

    public float GetShadowGradientLength()

Getter for ShadowGradientLength

    public float GetShadowSmooth()

Getter for ShadowFilterSmooth

    public Texture GetTexture()

Getter for Texture

    public Vector2 GetTextureOffset()

Getter for Offset

    public float GetTextureScale()

Getter for TextureScale

    public int GetZRangeMax()

Getter for RangeZMax

    public int GetZRangeMin()

Getter for RangeZMin

    public bool IsEditorOnly()

Getter for EditorOnly

    public bool IsEnabled()

Getter for Enabled

    public bool IsShadowEnabled()

Getter for ShadowEnabled

    public void SetColor(Color color)

Setter for Color

    public void SetEditorOnly(bool editorOnly)

Setter for EditorOnly

    public void SetEnabled(bool enabled)

Setter for Enabled

    public void SetEnergy(float energy)

Setter for Energy

    public void SetHeight(float height)

Setter for RangeHeight

    public void SetItemCullMask(int itemCullMask)

Setter for RangeItemCullMask

    public void SetItemShadowCullMask(int itemShadowCullMask)

Setter for ShadowItemCullMask

    public void SetLayerRangeMax(int layer)

Setter for RangeLayerMax

    public void SetLayerRangeMin(int layer)

Setter for RangeLayerMin

    public void SetMode(ModeEnum mode)

Setter for Mode

    public void SetShadowBufferSize(int size)

Setter for ShadowBufferSize

    public void SetShadowColor(Color shadowColor)

Setter for ShadowColor

    public void SetShadowEnabled(bool enabled)

Setter for ShadowEnabled

    public void SetShadowFilter(ShadowFilterEnum filter)

Setter for ShadowFilter

    public void SetShadowGradientLength(float multiplier)

Setter for ShadowGradientLength

    public void SetShadowSmooth(float smooth)

Setter for ShadowFilterSmooth

    public void SetTexture(Texture texture)

Setter for Texture

    public void SetTextureOffset(Vector2 textureOffset)

Setter for Offset

    public void SetTextureScale(float textureScale)

Setter for TextureScale

    public void SetZRangeMax(int z)

Setter for RangeZMax

    public void SetZRangeMin(int z)

Setter for RangeZMin

Inner Types

ModeEnum

Name Value Description
Add 0 Adds the value of pixels corresponding to the Light2D to the values of pixels under it. This is the common behaviour of a light.
Sub 1 Subtracts the value of pixels corresponding to the Light2D to the values of pixels under it, resulting in inversed light effect.
Mix 2 Mix the value of pixels corresponding to the Light2D to the values of pixels under it by linear interpolation.
Mask 3 The light texture of the Light2D is used as a mask, hiding or revealing parts of the screen underneath depending on the value of each pixel of the light (mask) texture.

ShadowFilterEnum

Name Value Description
None 0 No filter applies to the shadow map. See [member shadow_filter].
Pcf3 1 Percentage closer filtering (3 samples) applies to the shadow map. See [member shadow_filter].
Pcf5 2 Percentage closer filtering (5 samples) applies to the shadow map. See [member shadow_filter].
Pcf7 3 Percentage closer filtering (7 samples) applies to the shadow map. See [member shadow_filter].
Pcf9 4 Percentage closer filtering (9 samples) applies to the shadow map. See [member shadow_filter].
Pcf13 5 Percentage closer filtering (13 samples) applies to the shadow map. See [member shadow_filter].
Tags: