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: Light2D can also 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.

    public bool Enabled { get; set; }

If true, Light2D will emit light.

    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.

    public int RangeLayerMin { get; set; }

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

    public int RangeZMax { get; set; }

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

    public int RangeZMin { get; set; }

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

    public int ShadowBufferSize { get; set; }

Shadow buffer size.

    public Color ShadowColor { get; set; }

Color of shadows cast by the Light2D.

    public bool ShadowEnabled { get; set; }

If true, the Light2D will cast shadows.

    public ShadowFilterEnum ShadowFilter { get; set; }

Shadow filter type. See ShadowFilter for possible values.

    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

    [Obsolete("GetColor is deprecated. Use the Color property instead.")]
    public Color GetColor()

Getter for Color

    [Obsolete("GetEnergy is deprecated. Use the Energy property instead.")]
    public float GetEnergy()

Getter for Energy

    [Obsolete("GetHeight is deprecated. Use the RangeHeight property instead.")]
    public float GetHeight()

Getter for RangeHeight

    [Obsolete("GetItemCullMask is deprecated. Use the RangeItemCullMask property instead.")]
    public int GetItemCullMask()

Getter for RangeItemCullMask

    [Obsolete("GetItemShadowCullMask is deprecated. Use the ShadowItemCullMask property instead.")]
    public int GetItemShadowCullMask()

Getter for ShadowItemCullMask

    [Obsolete("GetLayerRangeMax is deprecated. Use the RangeLayerMax property instead.")]
    public int GetLayerRangeMax()

Getter for RangeLayerMax

    [Obsolete("GetLayerRangeMin is deprecated. Use the RangeLayerMin property instead.")]
    public int GetLayerRangeMin()

Getter for RangeLayerMin

    [Obsolete("GetMode is deprecated. Use the Mode property instead.")]
    public ModeEnum GetMode()

Getter for Mode

    [Obsolete("GetShadowBufferSize is deprecated. Use the ShadowBufferSize property instead.")]
    public int GetShadowBufferSize()

Getter for ShadowBufferSize

    [Obsolete("GetShadowColor is deprecated. Use the ShadowColor property instead.")]
    public Color GetShadowColor()

Getter for ShadowColor

    [Obsolete("GetShadowFilter is deprecated. Use the ShadowFilter property instead.")]
    public ShadowFilterEnum GetShadowFilter()

Getter for ShadowFilter

    [Obsolete("GetShadowGradientLength is deprecated. Use the ShadowGradientLength property instead.")]
    public float GetShadowGradientLength()

Getter for ShadowGradientLength

    [Obsolete("GetShadowSmooth is deprecated. Use the ShadowFilterSmooth property instead.")]
    public float GetShadowSmooth()

Getter for ShadowFilterSmooth

    [Obsolete("GetTexture is deprecated. Use the Texture property instead.")]
    public Texture GetTexture()

Getter for Texture

    [Obsolete("GetTextureOffset is deprecated. Use the Offset property instead.")]
    public Vector2 GetTextureOffset()

Getter for Offset

    [Obsolete("GetTextureScale is deprecated. Use the TextureScale property instead.")]
    public float GetTextureScale()

Getter for TextureScale

    [Obsolete("GetZRangeMax is deprecated. Use the RangeZMax property instead.")]
    public int GetZRangeMax()

Getter for RangeZMax

    [Obsolete("GetZRangeMin is deprecated. Use the RangeZMin property instead.")]
    public int GetZRangeMin()

Getter for RangeZMin

    [Obsolete("IsEditorOnly is deprecated. Use the EditorOnly property instead.")]
    public bool IsEditorOnly()

Getter for EditorOnly

    [Obsolete("IsEnabled is deprecated. Use the Enabled property instead.")]
    public bool IsEnabled()

Getter for Enabled

    [Obsolete("IsShadowEnabled is deprecated. Use the ShadowEnabled property instead.")]
    public bool IsShadowEnabled()

Getter for ShadowEnabled

    [Obsolete("SetColor is deprecated. Use the Color property instead.")]
    public void SetColor(Color color)

Setter for Color

    [Obsolete("SetEditorOnly is deprecated. Use the EditorOnly property instead.")]
    public void SetEditorOnly(bool editorOnly)

Setter for EditorOnly

    [Obsolete("SetEnabled is deprecated. Use the Enabled property instead.")]
    public void SetEnabled(bool enabled)

Setter for Enabled

    [Obsolete("SetEnergy is deprecated. Use the Energy property instead.")]
    public void SetEnergy(float energy)

Setter for Energy

    [Obsolete("SetHeight is deprecated. Use the RangeHeight property instead.")]
    public void SetHeight(float height)

Setter for RangeHeight

    [Obsolete("SetItemCullMask is deprecated. Use the RangeItemCullMask property instead.")]
    public void SetItemCullMask(int itemCullMask)

Setter for RangeItemCullMask

    [Obsolete("SetItemShadowCullMask is deprecated. Use the ShadowItemCullMask property instead.")]
    public void SetItemShadowCullMask(int itemShadowCullMask)

Setter for ShadowItemCullMask

    [Obsolete("SetLayerRangeMax is deprecated. Use the RangeLayerMax property instead.")]
    public void SetLayerRangeMax(int layer)

Setter for RangeLayerMax

    [Obsolete("SetLayerRangeMin is deprecated. Use the RangeLayerMin property instead.")]
    public void SetLayerRangeMin(int layer)

Setter for RangeLayerMin

    [Obsolete("SetMode is deprecated. Use the Mode property instead.")]
    public void SetMode(ModeEnum mode)

Setter for Mode

    [Obsolete("SetShadowBufferSize is deprecated. Use the ShadowBufferSize property instead.")]
    public void SetShadowBufferSize(int size)

Setter for ShadowBufferSize

    [Obsolete("SetShadowColor is deprecated. Use the ShadowColor property instead.")]
    public void SetShadowColor(Color shadowColor)

Setter for ShadowColor

    [Obsolete("SetShadowEnabled is deprecated. Use the ShadowEnabled property instead.")]
    public void SetShadowEnabled(bool enabled)

Setter for ShadowEnabled

    [Obsolete("SetShadowFilter is deprecated. Use the ShadowFilter property instead.")]
    public void SetShadowFilter(ShadowFilterEnum filter)

Setter for ShadowFilter

    [Obsolete("SetShadowGradientLength is deprecated. Use the ShadowGradientLength property instead.")]
    public void SetShadowGradientLength(float multiplier)

Setter for ShadowGradientLength

    [Obsolete("SetShadowSmooth is deprecated. Use the ShadowFilterSmooth property instead.")]
    public void SetShadowSmooth(float smooth)

Setter for ShadowFilterSmooth

    [Obsolete("SetTexture is deprecated. Use the Texture property instead.")]
    public void SetTexture(Texture texture)

Setter for Texture

    [Obsolete("SetTextureOffset is deprecated. Use the Offset property instead.")]
    public void SetTextureOffset(Vector2 textureOffset)

Setter for Offset

    [Obsolete("SetTextureScale is deprecated. Use the TextureScale property instead.")]
    public void SetTextureScale(float textureScale)

Setter for TextureScale

    [Obsolete("SetZRangeMax is deprecated. Use the RangeZMax property instead.")]
    public void SetZRangeMax(int z)

Setter for RangeZMax

    [Obsolete("SetZRangeMin is deprecated. Use the RangeZMin property instead.")]
    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 behavior 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: