Skip to content

Game.Rendering.LightState

Assembly: Game
Namespace: Game.Rendering

Type: struct

Base: IBufferElementData, IEmptySerializable

Summary:
LightState is a small ECS buffer element used to represent per-light parameters in the rendering system. It is marked with [InternalBufferCapacity(0)] so buffer storage is fully dynamic (no inline/internal capacity). The struct is blittable (two floats) and suitable for use in Unity DOTS/ECS jobs and burst-compiled code. IEmptySerializable indicates it participates in Colossal Order's custom serialization pipeline.


Fields

  • public System.Single m_Intensity
    Represents the light intensity (linear brightness). Typical range depends on the rendering code that consumes it; treat as a floating-point multiplier.

  • public System.Single m_Color
    Packed color representation stored as a single float. The exact packing (e.g., encoded RGBA or index into a lookup) is determined by the rendering subsystem that reads this buffer. Consult consuming code to interpret this value correctly.

Properties

  • None

Constructors

  • Default (compiler-generated) constructor
    No explicit constructors are defined; instances are created with default initialization or via object initializers.

Methods

  • None

Usage Example

// Example: adding and populating a DynamicBuffer<LightState> on an entity
public partial class LightSetupSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities
            .WithName("SetupLightBuffers")
            .ForEach((Entity entity, int entityInQueryIndex, ref SomeLightComponent comp) =>
            {
                var buffer = EntityManager.GetBuffer<LightState>(entity);
                buffer.Clear();
                buffer.Add(new LightState { m_Intensity = 1.0f, m_Color = /* packed color */ 0f });
                // Add more entries as needed...
            }).WithoutBurst().Run();
    }
}

Notes and tips: - Because [InternalBufferCapacity(0)] is set, the buffer stores all elements out-of-line; resizing causes heap allocations—avoid frequent resizing in tight loops. - The struct size is 8 bytes (two floats). It is blittable and safe for use in jobs and Burst-compiled code. - Interpret m_Color according to the renderer's expectations (it may be a packed float color or an index); inspect call sites that read LightState to choose encoding/decoding. - If modifying in jobs, use DynamicBuffer in job-friendly forms (e.g., IJobChunk or Entities.ForEach with proper safety).