Class Light
This class represents all properties of a light.
Inheritance
Implements
Inherited Members
Namespace: Evergine.Framework.Graphics
Assembly: Evergine.Framework.dll
Syntax
public abstract class Light : Component, IDependencyObject
Constructors
Light()
Initializes a new instance of the Light class.
Declaration
public Light()
Fields
ReverseZBuffer
Indicates whether the light uses reverse Z projection. The reference values resides in the GraphicsContext. We also cache this value here to detect when the value in the GraphicsContext has changed, and update the projection matrix accordingly.
Declaration
protected bool ReverseZBuffer
Field Value
| Type | Description |
|---|---|
| bool |
Transform
Transforms 2D or 3D.
Declaration
[BindComponent(true, true, BindComponentSource.Owner, null, true)]
public Transform3D Transform
Field Value
| Type | Description |
|---|---|
| Transform3D |
boundingFrustum
The bounding frustum.
Declaration
protected BoundingFrustum boundingFrustum
Field Value
| Type | Description |
|---|---|
| BoundingFrustum |
color
The color.
Declaration
protected LinearColor color
Field Value
| Type | Description |
|---|---|
| LinearColor |
graphicsContextCapabilities
Get the cached GraphicsContext capabilities.
Declaration
protected GraphicsContextCapabilities graphicsContextCapabilities
Field Value
| Type | Description |
|---|---|
| GraphicsContextCapabilities |
projection
The projection.
Declaration
protected Matrix4x4 projection
Field Value
| Type | Description |
|---|---|
| Matrix4x4 |
renderProjection
The render projection.
Declaration
protected Matrix4x4 renderProjection
Field Value
| Type | Description |
|---|---|
| Matrix4x4 |
renderProjectionInverse
The render projection inverse.
Declaration
protected Matrix4x4 renderProjectionInverse
Field Value
| Type | Description |
|---|---|
| Matrix4x4 |
renderViewProjection
The view projection.
Declaration
protected Matrix4x4 renderViewProjection
Field Value
| Type | Description |
|---|---|
| Matrix4x4 |
renderViewProjectionInverse
The render view-projection inverse.
Declaration
protected Matrix4x4 renderViewProjectionInverse
Field Value
| Type | Description |
|---|---|
| Matrix4x4 |
shadowBias
The depth bias.
Declaration
protected float shadowBias
Field Value
| Type | Description |
|---|---|
| float |
shadowOpacity
The opacity of the shadow. 0 represents transparent and 1 represents opaque.
Declaration
protected float shadowOpacity
Field Value
| Type | Description |
|---|---|
| float |
view
The view.
Declaration
protected Matrix4x4 view
Field Value
| Type | Description |
|---|---|
| Matrix4x4 |
viewProjection
The view projection.
Declaration
protected Matrix4x4 viewProjection
Field Value
| Type | Description |
|---|---|
| Matrix4x4 |
viewProjectionInverse
The view projection inverse.
Declaration
protected Matrix4x4 viewProjectionInverse
Field Value
| Type | Description |
|---|---|
| Matrix4x4 |
Properties
BoundingFrustum
Gets the light-bounding frustum.
Declaration
public BoundingFrustum BoundingFrustum { get; }
Property Value
| Type | Description |
|---|---|
| BoundingFrustum |
CascadeCount
Gets the number of cascades associated with this light.
Declaration
public abstract int CascadeCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Color
Gets or sets the light color.
Declaration
public virtual Color Color { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | The diffuse color. |
Intensity
Gets or sets the light intensity.
Declaration
public virtual float Intensity { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
IsShadowEnabled
Gets or sets a value indicating whether shadows are enabled.
Declaration
[RenderProperty(Tag = 1, CustomPropertyName = "Shadow enabled")]
public virtual bool IsShadowEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
LightDrawContext
Gets the associated light draw context.
Declaration
public LightDrawContext LightDrawContext { get; }
Property Value
| Type | Description |
|---|---|
| LightDrawContext |
LightType
Gets the type of light.
Declaration
public abstract LightType LightType { get; }
Property Value
| Type | Description |
|---|---|
| LightType |
LinearColor
Gets or sets the light color in linear space.
Declaration
public LinearColor LinearColor { get; set; }
Property Value
| Type | Description |
|---|---|
| LinearColor |
Projection
Gets the projection matrix.
Declaration
public Matrix4x4 Projection { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4x4 |
RenderProjection
Gets the render projection matrix.
Declaration
public Matrix4x4 RenderProjection { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4x4 |
RenderProjectionInverse
Gets the render projection inverse matrix.
Declaration
public Matrix4x4 RenderProjectionInverse { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4x4 |
RenderViewProjection
Gets the rendered view projection.
Declaration
public Matrix4x4 RenderViewProjection { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4x4 |
RenderViewProjectionInverse
Gets the render projection inverse matrix.
Declaration
public Matrix4x4 RenderViewProjectionInverse { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4x4 |
ShadowBias
Gets or sets the shadow's depth bias.
Declaration
[RenderProperty(AttachToTag = 1, AttachToValue = true, CustomPropertyName = "Shadow Bias")]
public virtual float ShadowBias { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
ShadowOpacity
Gets or sets the shadow's opacity value. This property must be in the range of 0.0 (transparent) to 1.0 (opaque). The default value is 0.0.
Declaration
[RenderPropertyAsFInput(AsSlider = true, MaxLimit = 1, MinLimit = 0, AttachToTag = 1, AttachToValue = true, CustomPropertyName = "Shadow Opacity")]
public virtual float ShadowOpacity { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
View
Gets the view matrix.
Declaration
public Matrix4x4 View { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4x4 |
ViewProjection
Gets the view projection.
Declaration
public Matrix4x4 ViewProjection { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4x4 |
ViewProjectionInverse
Gets the view projection inverse.
Declaration
public Matrix4x4 ViewProjectionInverse { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4x4 |
Methods
ComputeBoundingBox(out BoundingBox)
Computes the bounding box of the light.
Declaration
public abstract void ComputeBoundingBox(out BoundingBox boundingBox)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | boundingBox | The bounding box. |
FireOnShadowEnabledChanged()
Fires the OnShadowEnabledChanged event.
Declaration
protected void FireOnShadowEnabledChanged()
Intersects(ref BoundingBox)
Checks if the current light intersects with the specified bbox.
Declaration
public abstract bool Intersects(ref BoundingBox aabb)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | aabb | The frustum. |
Returns
| Type | Description |
|---|---|
| bool | Whether the light is inside the frustum view. |
Intersects(ref BoundingFrustum)
Checks if the current light is inside the specified frustum.
Declaration
public abstract bool Intersects(ref BoundingFrustum frustum)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingFrustum | frustum | The frustum. |
Returns
| Type | Description |
|---|---|
| bool | Whether the light is inside the frustum view. |
OnAttached()
Attaches the camera to the system.
Declaration
protected override bool OnAttached()
Returns
| Type | Description |
|---|---|
| bool | True if everything is OK. |
Overrides
OnDetached()
Detaches the camera from the system.
Declaration
protected override void OnDetached()
Overrides
Events
OnColorChanged
Event fires when the color of the light changes.
Declaration
public event EventHandler<Color> OnColorChanged
Event Type
| Type | Description |
|---|---|
| EventHandler<Color> |
OnIntensityChanged
Event fired when the intensity of the light has been changed.
Declaration
public event EventHandler<float> OnIntensityChanged
Event Type
| Type | Description |
|---|---|
| EventHandler<float> |
OnShadowEnabledChanged
OnShadowEnabledChanged is called when the light shadow enable property changes.
Declaration
public event EventHandler<bool> OnShadowEnabledChanged
Event Type
| Type | Description |
|---|---|
| EventHandler<bool> |