Table of Contents

Class DirectionalLight3D

Namespace
LibGFX.Graphics.Lights
Assembly
LibGFX.dll

An directional light in 3D space. TODO: Create an uniform for the bias

public class DirectionalLight3D : Light, IIdentifier, ISerialization
Inheritance
DirectionalLight3D
Implements
Inherited Members

Constructors

DirectionalLight3D()

Initializes a new instance of the DirectionalLight3D class.

public DirectionalLight3D()

DirectionalLight3D(Vector3, Vector4, float)

Creates a new instance of the DirectionalLight3D class.

public DirectionalLight3D(Vector3 direction, Vector4 color, float intensity)

Parameters

direction Vector3
color Vector4
intensity float

Properties

Ambient

The ambient color of the light.

public Vector3 Ambient { get; set; }

Property Value

Vector3

Bias

The Bias of the light shadow map.

public float Bias { get; set; }

Property Value

float

Direction

The direction of the light.

public Vector3 Direction { get; set; }

Property Value

Vector3

HasShadowMap

Gets a value indicating whether this object supports a shadow map.

public override bool HasShadowMap { get; }

Property Value

bool

Specular

The specular color of the light.

public Vector3 Specular { get; set; }

Property Value

Vector3

Methods

Deserialize(JObject, SerializationContext, Func<JObject, bool>)

Populates the properties of the current instance from the specified JSON object using the provided serialization context.

public override void Deserialize(JObject obj, SerializationContext serializationContext, Func<JObject, bool> callback = null)

Parameters

obj JObject
serializationContext SerializationContext

A SerializationContext that provides context or settings for the deserialization process.

callback Func<JObject, bool>

Remarks

This method updates the state of the current object based on the values found in jObject. All expected properties must be present in the JSON object for correct deserialization.

Dispose(IRenderDevice)

Releases all resources used by the shadow map associated with the directional light.

public override void Dispose(IRenderDevice renderer)

Parameters

renderer IRenderDevice

The rendering device to use when disposing of resources. Cannot be null.

Init(IRenderDevice)

Initializes the shadow map resources for the directional light using the specified render device.

public override void Init(IRenderDevice renderer)

Parameters

renderer IRenderDevice

The render device used to create the shadow map render target. Cannot be null.

Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)

Serializes the current light object to a JSON representation suitable for storage or transmission.

public override void Serialize(JsonWriter writer, SerializationContext serializationContext, Action<JsonWriter> callback = null)

Parameters

writer JsonWriter
serializationContext SerializationContext

The context that provides information and services required for serialization.

callback Action<JsonWriter>

Remarks

The returned JSON object includes type information and key light properties such as color, position, intensity, shadow map size, direction, ambient, specular, and bias. This method is typically used to persist or transfer light configuration data.