Overview
Atlas provides a comprehensive lighting system with support for ambient, directional, point, spot, and area lights. All light types support shadow mapping and are optimized for GPU rendering with aligned buffer structures.Light Types
AmbientLight
Ambient light provides uniform illumination across the entire scene.The color of the ambient light reflected into all objects.
The intensity with which the ambient light is applied.
DirectionalLight
Directional lights simulate distant light sources like the sun, with parallel rays.Constructor
Creates a new directional light.Parameters:
dir- Direction vector (will be normalized) (default:{0.0f, -1.0f, 0.0f})color- Light color (default:Color::white())shineColor- Specular highlight color (default:Color::white())intensity- Light intensity (default:1.0f)
Properties
Direction in which the light is pointing (normalized vector).
The color of the light.
The color used for specular highlights.
The light intensity multiplier.
Render target that holds the shadow map (when shadows are enabled).
Methods
Sets the light color.Parameters:
color- New color for the light
Enables shadow casting for this light.Parameters:
window- The window in which to cast shadowsresolution- Shadow map resolution (default:4096)
Light (Point Light)
Point lights emit light in all directions from a single point, with distance-based attenuation.Constructor
Creates a new point light.Parameters:
pos- Position in 3D space (default:{0.0f, 0.0f, 0.0f})color- Light color (default:Color::white())distance- Distance the light reaches (default:50.0f)shineColor- Specular highlight color (default:Color::white())intensity- Light intensity (default:1.0f)
Properties
Position of the light in 3D space.
The color of the light.
The color used for specular highlights.
Light intensity multiplier.
Distance to which the light reaches.
Render target that holds the shadow cubemap.
Debug object for visualizing the light in the scene.
Methods
Sets the light color.Parameters:
newColor- New color for the light
Calculates attenuation constants for the point light.Returns: Structure containing distance, constant, linear, quadratic, and radius values
Enables shadow casting for this light.Parameters:
window- The window in which to cast shadowsresolution- Shadow map resolution (default:2048)
Creates a debug object to visualize the light in the scene.
Adds the debug object to the window.Parameters:
window- The window to add the debug object to
Spotlight
Spotlights emit light in a cone from a specific position and direction.Constructor
Creates a new spotlight.Parameters:
pos- Position in 3D space (default:{0.0f, 0.0f, 0.0f})dir- Direction vector (default:{0.0f, -1.0f, 0.0f})color- Light color (default:Color::white())angle- Inner cone angle in degrees (default:35.0f)outerAngle- Outer cone angle in degrees (default:40.0f)shineColor- Specular highlight color (default:Color::white())intensity- Light intensity (default:1.0f)range- Light range (default:50.0f)
Properties
Position of the spotlight in 3D space.
Direction in which the spotlight is pointing.
The color of the spotlight.
The color used for specular highlights.
Light intensity multiplier.
Maximum range of the spotlight.
Inner cone angle of the spotlight (cosine of angle in radians).
Outer cone angle of the spotlight (cosine of angle in radians).
Render target for shadow mapping.
Debug object for visualizing the spotlight.
Methods
Sets the spotlight color.Parameters:
newColor- New color for the spotlight
Makes the spotlight look at a target position.Parameters:
target- Position to look at
Enables shadow casting.Parameters:
window- The window in which to cast shadowsresolution- Shadow map resolution (default:2048)
Creates a debug object to visualize the spotlight.
Adds the debug object to the window.Parameters:
window- The window to add the debug object to
Updates the rotation of the debug object to match the spotlight direction.
AreaLight
Area lights are rectangular light sources with controllable emission angle and two-sided emission.Properties
Center position of the rectangular light.
Oriented axis for width direction (normalized).
Oriented axis for height direction (normalized).
Width and height of the rectangle.
Diffuse/emissive color of the light.
Specular highlight color.
Light intensity multiplier.
Maximum range of the light.
Emission cone half-angle in degrees around the plane normal (90 = hemisphere).
If true, the light emits on both sides of the rectangle plane.
Rotation tracking for the area light in degrees.
Optional debug object for visualizing the area light.
Render target for shadow mapping.
Methods
Computes the plane normal (normalize(cross(right, up))).Returns: Normalized normal vector
Sets the diffuse color.Parameters:
c- New color
Sets absolute rotation and updates right/up axes accordingly.Parameters:
r- Rotation in degrees (roll Z, pitch X, yaw Y)
Applies a delta rotation and updates right/up axes.Parameters:
delta- Delta rotation in degrees
Creates a debug object to visualize the area light rectangle.
Adds the debug object to the window.Parameters:
window- The window to add the debug object to
Enables shadow casting.Parameters:
window- The window in which to cast shadowsresolution- Shadow map resolution (default:2048)
GPU Buffer Structures
Atlas provides GPU-aligned structures for efficient light data transfer:GPUDirectionalLight- Matches GLSL DirectionalLight structGPUPointLight- Matches GLSL PointLight structGPUSpotLight- Matches GLSL SpotLight structGPUAreaLight- Matches GLSL AreaLight structGPUShadowParams- Matches GLSL ShadowParameters struct
alignas(16) to ensure proper GPU memory alignment.