Quick Start
Lighting your scene
Add ambient, directional, point, and spot lights within engine limits.
Materials need light in the scene. The lighting model is described in the engine’s Lights Creation API; this page summarizes what you typically wire in app code.
Light types
| Type | Role |
|---|---|
| Ambient | Uniform base fill; prevents fully black shadows |
| Directional | Distant sun/moon; set direction via transform rotation |
| Point | Omni light at a position; range and decay on the point lamp |
| Spot | Cone; inner/outer angles and falloff on the spot lamp |
Engine limits
At most one ambient light is used (first enabled). At most four direct lights (directional + point + spot combined) participate; extras are culled in scene traversal order. Name lights and keep counts low for predictable results.
Factory-style creation
import zernikalos.objects.ZLight
import zernikalos.math.ZColor
import zernikalos.math.ZVector3
import zernikalos.math.ZEulerAngles
val ambient = ZLight.createAmbientLight()
ambient.intensity = 0.25f
val sun = ZLight.createDirectionalLight()
sun.color = ZColor(1f, 0.95f, 0.85f)
sun.intensity = 1.2f
sun.transform.rotation = ZEulerAngles(-45f, 30f, 0f)
val lamp = ZLight.createPointLight()
lamp.transform.position = ZVector3(2f, 3f, 2f)
lamp.intensity = 1.5f
scene.addChild(ambient)
scene.addChild(sun)
scene.addChild(lamp)Platform notes
- Android / Kotlin: A typical
onReadypath loads the.zko, builds aZScene, then addscreateDirectionalLight,createAmbientLight, aZCamera, and the loaded root. - iOS: Prefer
ZLight.companion.createAmbientLight()/createDirectionalLight(). Assign the lamp withlight.lampif you construct aZLightyourself. Ambient and direct lights are discovered from the scene graph each frame. - Web: Factory methods live on
ZLight.Companion(for exampleZLight.Companion.createAmbientLight()). You can also setlight.lampto aZDirectionalLamp(or another lamp type) directly.
Use light.enable() / light.disable() to toggle lights without removing nodes (isEnabled is read-only).
Related
- Scene & camera
- Loading a model
- Playing skeletal animations
- Lights Creation API — three-point setups, indoor/outdoor presets, spot/point parameters