Extend the Lighting module with a per-cell lightmap. LightmapBuilder (pure, tested) fills an ambient base, shades occluder cells, and adds point lights that attenuate with distance and are blocked by occluders between source and cell (grid-traced soft shadows). Lightmap holds the grid plus a greyscale texture (Upload) and a bilinear SampleAt for the simulation; a PointLight component places lights in the world. LightmapSystem rebuilds the grid a few times a second (ambient from the day/night cycle with a night floor, occluders from a game-supplied grid, point lights from the ECS); LightmapRenderSystem multiplies the lightmap over the world after the sprite flush and under the HUD. Wired via scene.UseLighting(...), sampled through Lighting.SampleAt. Docs updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d0104df304
commit
79d406a9f4
@@ -0,0 +1,21 @@
|
||||
using Friflo.Engine.ECS;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace MrGameEng.Lighting;
|
||||
|
||||
/// <summary>
|
||||
/// A point light: an entity with this component plus a <see cref="MrGameEng.Graphics.Transform2D"/>
|
||||
/// adds light around its world position, attenuating to zero at <see cref="Radius"/> and casting
|
||||
/// grid-traced shadows behind occluders. Picked up by the lighting system into the lightmap.
|
||||
/// </summary>
|
||||
public struct PointLight : IComponent
|
||||
{
|
||||
/// <summary>Reach of the light in world units (light fades to zero at this distance).</summary>
|
||||
public float Radius;
|
||||
|
||||
/// <summary>Light tint (reserved for colored lights; intensity currently drives brightness).</summary>
|
||||
public Color Color;
|
||||
|
||||
/// <summary>Peak brightness added at the light's centre (0..1+).</summary>
|
||||
public float Intensity;
|
||||
}
|
||||
Reference in New Issue
Block a user