Lysa Nodes  0.0
Lysa Nodes — Scene Graph for the Lysa Engine
Lights and environment

Overview

Like all nodes, lights are automatically registered with and removed from the renderer when they are added to or removed from the scene tree.

Environment

Environment sets the constant-colour ambient term for the scene. The single constructor argument combines RGB colour and intensity in a float4:

addChild(std::make_shared<Environment>(lysa::float4{1.0f, 1.0f, 1.0f, 0.20f}));

The first three components are the RGB sky colour; the fourth is the intensity multiplier (0–1). A neutral white at 0.20 keeps shadowed surfaces visible without a colour cast.

At most one Environment node is active per scene. Adding a second one replaces the first.

DirectionalLight

DirectionalLight inherits from Light, which inherits from both Node and lysa::Light. The constructor takes a float4{r, g, b, intensity}:

auto dirLight = std::make_shared<DirectionalLight>(
lysa::float4{1.00f, 0.95f, 0.85f, 1.5f});

Direction is encoded in the node's transform (rotation only; translation has no effect on a directional light):

dirLight->setTransform(lysa::mul(
lysa::float4x4::rotation_x(lysa::radians(-50.0f)),
lysa::float4x4::rotation_y(lysa::radians(35.0f))));

Shadow maps are configured via dedicated methods before addChild:

dirLight->setCastShadows(true);
dirLight->setShadowMapSize(2048);
dirLight->setShadowMapCascadesCount(3); // 2 to DirectionalLight::MAX_SHADOW_MAP_CASCADES
dirLight->setCascadeSplitLambda(0.75f); // 0 = uniform splits, 1 = logarithmic
addChild(dirLight);

The float4x4 multiplication convention follows the rest of the engine: mul(A, B) applies A first, then B. Composing rotation_x(-50°) outer with rotation_y(35°) inner places the sun in the upper-right hemisphere.

OmniLight

OmniLight represents a point light with spherical attenuation. Its primary constructor takes range first, then colour:

auto omniLight = std::make_shared<OmniLight>(
12.0f, // light radius in world units
lysa::float4{0.30f, 0.40f, 0.60f, 0.6f} // cool-blue, intensity 0.6
);
omniLight->setPosition(0.0f, -2.0f, 3.0f);
addChild(omniLight);

setPosition uses the standard Node method; the light's world position is derived from globalTransform[3].xyz via the Light::updateGlobalTransform override, which calls lysa::Scene::updateLight automatically.

Keeping lights as scene members

Light nodes share shared_ptr ownership with the scene tree and live as long as either the tree or any external reference holds them. Declaring them as member fields of RotatingAssetScene is unnecessary but is still a valid pattern.

To remove a light at runtime call removeChild(lightNode). There is no separate removeLight call; the _detachFromScene path unregisters the light from the renderer automatically.

Next : Rotation