Lighting System
Overview
The lighting system supports multiple light types: point lights (up to 8), directional lights (up to 4), and spot lights (up to 4). All lights use Blinn-Phong shading with configurable attenuation.
Adding Lights in the Editor
To add a light to your scene:
- Create a new entity in the Scene Hierarchy
- In the Inspector, click Add Component and choose a light type:
- PointLight — emits light in all directions from the entity's position
- DirectionalLight — simulates a distant light (like the sun); direction comes from the entity's Transform rotation
- SpotLight — cone-shaped light; direction comes from Transform rotation
- Configure color, intensity, and attenuation in the Inspector
Components
PointLight
DirectionalLight
Direction is derived from the entity's Transform rotation.
SpotLight
Shader Details
- Shading model: Blinn-Phong (ambient + diffuse + specular)
- Ambient: 0.15 constant
- Specular: shininess = 32, intensity = 0.5
- Attenuation:
1 / (constant + linear*d + quadratic*d^2)for point/spot lights - Spot cone: smooth falloff between inner and outer cutoff angles
- Fallback: if no lights exist, uses default light at (5, 10, 5)
Integration Notes
- All light types are editable in the Inspector panel
- Light direction for DirectionalLight and SpotLight is derived from the entity's Transform rotation
- Maximum limits per frame: 8 point, 4 directional, 4 spot lights
- All components are serializable for scene save/load