Class Light
Represents a light source in the Genesis framework.
Inherited Members
Namespace: Genesis.Core
Assembly: Genesis.dll
Syntax
public abstract class Light : GameElement
Constructors
Light(string, Vec3, bool)
Creates a new instance of the Light class with the specified name and location.
Declaration
public Light(string name, Vec3 location, bool castShadows = true)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the light. |
Vec3 | location | The 3D location of the light. |
bool | castShadows |
Light(string, Vec3, float, bool)
Creates a new instance of the Light class with the specified name, location and intensity.
Declaration
public Light(string name, Vec3 location, float intensity, bool castShadows = true)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the light. |
Vec3 | location | The 3D location of the light. |
float | intensity | The intensity of the light. |
bool | castShadows |
Properties
CastShadows
Gets or sets a value indicating whether the light should cast shadows.
Declaration
public bool CastShadows { get; set; }
Property Value
Type | Description |
---|---|
bool |
|
Intensity
Gets or sets the intensity of the light.
Declaration
public float Intensity { get; set; }
Property Value
Type | Description |
---|---|
float |
LightColor
Gets or sets the color of the light.
Declaration
public Color LightColor { get; set; }
Property Value
Type | Description |
---|---|
Color |
ShadowResolution
Gets or sets the resolution of the shadow map.
Declaration
public Vec3 ShadowResolution { get; set; }
Property Value
Type | Description |
---|---|
Vec3 | A Vec3 object specifying the width and height of the shadow map. Default resolution is 2048x2048. |
Shadowmap
Gets or sets the shadow map for the light.
Declaration
public Framebuffer Shadowmap { get; set; }
Property Value
Type | Description |
---|---|
Framebuffer | A Framebuffer object that stores the shadow map used for shadow calculations. |
Methods
GetLightColor()
Returns the light color in RGB values normalized between 0 and 1.
Declaration
public Vec3 GetLightColor()
Returns
Type | Description |
---|---|
Vec3 | A Vec3 representing the normalized RGB values of the light color. |
GetLightDirection(Camera)
Returns the direction vector from the light to the camera.
Declaration
public Vec3 GetLightDirection(Camera camera)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera to which the direction is calculated. |
Returns
Type | Description |
---|---|
Vec3 | The normalized vector representing the light direction. |
GetLightProjectionMatrix(PerspectiveCamera, Viewport)
Gets the light projection matrix for the specified camera and viewport. This abstract method must be implemented in subclasses to return the appropriate light projection matrix.
Declaration
public abstract mat4 GetLightProjectionMatrix(PerspectiveCamera camera, Viewport viewport)
Parameters
Type | Name | Description |
---|---|---|
PerspectiveCamera | camera | The perspective camera used for the calculation. |
Viewport | viewport | The viewport that defines the rendering area. |
Returns
Type | Description |
---|---|
mat4 | A GlmSharp.mat4 representing the projection matrix for this light. |
GetLightViewMatrix()
Gets the light view matrix for rendering. This abstract method must be implemented in subclasses to return the appropriate light view matrix.
Declaration
public abstract mat4 GetLightViewMatrix()
Returns
Type | Description |
---|---|
mat4 | A GlmSharp.mat4 representing the view matrix for this light. |
Init(Game, IRenderDevice)
Initializes the light with the provided game and render device. This method prepares the shadow map for rendering.
Declaration
public override void Init(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game object that this light belongs to. |
IRenderDevice | renderDevice | The render device used to build the shadow map. |