SpotLight class Lighting and environment

A light that radiates from a world-space point within a cone, combining a PointLight's distance falloff with an angular falloff between an inner and outer cone.

Attach one by adding a SpotLightComponent to a node; the light's world position is the node's world translation and its aim is the node's world-space rotation applied to direction. The analytic contribution is layered on top of the image-based-lighting ambient term.

When castsShadow is true and the scene's spot-shadow budget has room, the renderer renders the spot's cone into a perspective shadow map and the light is occluded by geometry between it and the surface.

Constructors

SpotLight({Vector3? color, double intensity = 1.0, double range = 0.0, double falloffExponent = 2.0, double radius = 0.0, Vector3? direction, double innerConeAngle = 0.0, double outerConeAngle = math.pi / 4.0, bool castsShadow = false, int shadowMapResolution = 1024, double shadowNear = 0.1, double shadowDepthBias = 0.0, double shadowNormalBias = 0.1, double shadowSoftness = 1.0, double? shadowFieldOfView, ShadowCasterFaces shadowCasterFaces = ShadowCasterFaces.front, int channelMask = 0xFF, int shadowCasterChannelMask = 0xFF})
Creates a SpotLight.

Properties

castsShadow ↔ bool
Whether this spot casts a shadow. When true, the renderer renders the cone into a perspective shadow map if the scene's spot-shadow budget has room (shadow-casting spots are limited; the rest shade unshadowed).
getter/setter pair
channelMask ↔ int Lighting and environment
The light channels this spot illuminates, an 8-bit mask (default 0xFF, every channel). A node receives this light only when channelMask & node.lightChannelMask is nonzero, so a zero mask on either side never intersects. Channels do not affect image-based (environment) lighting, which every node receives.
getter/setter pair
color ↔ Vector3
Linear RGB color of the light.
getter/setter pair
direction ↔ Vector3
The cone's aim, in the owning node's local space. Need not be unit length. Rotated to world by the node's transform.
getter/setter pair
falloffExponent ↔ double
The distance-falloff exponent (see PointLight.falloffExponent).
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
innerConeAngle ↔ double
Half-angle of the inner cone, in radians. Within this angle of the axis the light is at full brightness.
getter/setter pair
intensity ↔ double
Scalar multiplier applied to color; the radiance at unit distance.
getter/setter pair
outerConeAngle ↔ double
Half-angle of the outer cone, in radians. Between innerConeAngle and this the light falls off to zero; past it the light contributes nothing.
getter/setter pair
radius ↔ double
World-space radius of the emitter (see PointLight.radius).
getter/setter pair
range ↔ double
World-space distance at which the light's influence smoothly reaches zero. 0 means infinite range (pure inverse-square falloff).
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shadowCasterChannelMask ↔ int Lighting and environment
The light channels whose nodes render into this spot's shadow map, an 8-bit mask (default 0xFF, every channel). A node casts only when shadowCasterChannelMask & node.lightChannelMask is nonzero.
getter/setter pair
shadowCasterFaces ↔ ShadowCasterFaces
Which faces are rendered into the shadow map. ShadowCasterFaces.back (second-depth) removes the shadow detaching from a solid caster's base (peter-panning) by recording the far side; ShadowCasterFaces.front is the general default.
getter/setter pair
shadowDepthBias ↔ double
Clip-space depth bias subtracted from the receiver before the shadow test. Defaults to 0: a constant clip-space bias is badly behaved in a perspective shadow (tiny near the light, large far away, which detaches the shadow from a caster's base), so the normal-offset bias below does the work instead. Raise it only to fight grazing-angle self-shadow acne.
getter/setter pair
shadowFieldOfView ↔ double?
Vertical field of view of the shadow frustum, in radians, or null to cover the cone (outerConeAngle with a small margin). A narrower frustum spends the tile's texels on the core of a wide, soft-edged cone.
getter/setter pair
shadowMapResolution ↔ int
Pixel resolution of this spot's (square) shadow map. It renders at this size unless the frame's shadows overflow the shared atlas, which halves every spot and point shadow until they fit.
getter/setter pair
shadowNear ↔ double
Near clip distance of the shadow frustum. Geometry closer to the light than this does not occlude.
getter/setter pair
shadowNormalBias ↔ double
World-space offset along the surface normal applied to the receiver before the shadow lookup ("normal-offset shadows"). This is the main acne/peter-panning control for a spot; being world-space it scales with the scene, so very small scenes may want a smaller value.
getter/setter pair
shadowSoftness ↔ double
Radius, in shadow-map texels, of the soft-shadow PCF kernel. 0 gives a hard edge.
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shadowViewProjection(Vector3 worldPosition, Vector3 worldDirection) → Matrix4
The world -> clip matrix that renders and samples this spot's perspective shadow map, for a light at worldPosition aimed along worldDirection (both from the owning node's transform). The frustum is the cone, a vertical field of view of twice outerConeAngle (with a small margin) and a square aspect, out to range (or a default when the range is infinite).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited