API Reference · Lights

SpotLight

Namespace: Ava3D

public sealed class SpotLight : Light

A light with a position, a direction and a cone: a torch, a stage lamp, a headlight.

Why this exists, and it is not "a point light with a mask". A point light casts in every direction, and a correct shadow for one needs six faces of a cube map. This library has one map, so a point light's shadow is a cone aimed by guesswork at the middle of whatever casts — and everything outside that cone is lit as though nothing blocked it. A spot light has no such problem, because the cone is not a compromise imposed on it: the cone is the light. Its shadow frustum is its own aperture, aimed along its own axis, and geometry outside it is unlit rather than falsely lit. Anything carried through a room in somebody's hand should be one of these.

The cone. Full brightness inside SpotLight.InnerConeDegrees, nothing outside SpotLight.OuterConeDegrees, and a smooth falloff between them — the glTF KHR_lights_punctual shape, so a light tuned in Blender, three.js or Godot arrives with the numbers meaning the same thing. Both angles are half-angles from the axis, which is also what those use; a 35° outer cone is a 70° beam.

The two are resolved against each other when the frame is built rather than in these setters, so they can be assigned in either order without one of them briefly clamping the other: the outer angle is held below a right angle, and the inner is then held at or below the outer. A spot with both equal is a hard-edged circle, which is legal and is what a slide projector is.

Properties

MemberDescription
float Decay { get; set; }

Falloff exponent along the beam: 1 is roughly linear, 2 is physical inverse-square.

Vector3 Direction { get; set; }

The direction the beam travels, in world space. Need not be normalised. Straight down by default, which is where a lamp points when nobody has said.

float InnerConeDegrees { get; set; }

Half-angle of the fully lit core, in degrees. 20 by default. Held at or below SpotLight.OuterConeDegrees when the frame is built.

float OuterConeDegrees { get; set; }

Half-angle at which the beam reaches zero, in degrees. 35 by default, and held below 89.9 — a cone at or past a right angle is a hemisphere, which is a point light with extra arithmetic and cannot be given a shadow frustum.

Vector3 Position { get; set; }

Where the light is, in world space.

float Range { get; set; }

Distance at which the light reaches exactly zero. Zero means unbounded inverse-square.

Worth setting for the same reason it is on PointLight.Range, and more so here: a cone reaching to infinity down a corridor puts a faint disc on a wall the beam was never meant to touch.

See also