SunLight class Lighting and environment
Aims a scene's directional light at a SunSky's sun, so cast shadows track the sky.
Assign one to Scene.sunLight to have the scene shade and shadow from the
same sun the sky draws: each frame the binding points its light opposite
the sky's sunDirection and recolors it from the sky's sun. Pair it with a
SkyEnvironment driven by the same sky so the soft image-based lighting and
the hard shadow agree:
final sky = PhysicalSkySource();
scene.skybox = Skybox(sky);
scene.skyEnvironment = SkyEnvironment(sky);
scene.sunLight = SunLight(sky, castsShadow: true);
While set, the binding owns Scene.directionalLight (it replaces and then
keeps updating that light); setting directionalLight by hand has no
lasting effect. Cascaded shadows need a perspective camera.
Constructors
- SunLight(SunSky source, {bool castsShadow = true, double intensityScale = 1.0, Vector3? color, double? intensity, double shadowSoftness = 0.08, double shadowMaxDistance = 150.0, int shadowCascadeCount = 4, int shadowMapResolution = 1024, double shadowDepthBias = 0.02, double shadowNormalBias = 0.02, double shadowFadeRange = 2.0, double shadowCascadeSplitLambda = 0.6, double shadowAmbientStrength = 0.0, ShadowCasterFaces shadowCasterFaces = ShadowCasterFaces.front})
-
Creates a binding that aims a directional light at
source's sun.
Properties
- castsShadow ↔ bool
-
Whether the derived light casts shadows.
getter/setter pair
- color ↔ Vector3?
-
Overrides the sky-derived sun color when non-null.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- intensity ↔ double?
-
Overrides the sky-derived sun intensity when non-null.
getter/setter pair
- intensityScale ↔ double
-
Multiplies the (sky-derived or overridden) intensity.
getter/setter pair
- light → DirectionalLight
-
The managed light. Mutated in place by resolve each frame so the scene
graph need not re-register a new light when the sun moves.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shadowAmbientStrength ↔ double
-
How much the shadow also darkens the IBL ambient; see
DirectionalLight.shadowAmbientStrength. Useful here because a
SkyEnvironment bakes the sun into the ambient, so a plain shadow leaves
shadowed areas reading as fully lit.
getter/setter pair
- shadowCascadeCount ↔ int
-
Number of shadow cascades; see DirectionalLight.shadowCascadeCount.
getter/setter pair
- shadowCascadeSplitLambda ↔ double
-
Cascade split blend; see DirectionalLight.shadowCascadeSplitLambda.
getter/setter pair
- shadowCasterFaces ↔ ShadowCasterFaces
-
Which faces are rendered into the shadow map; see
DirectionalLight.shadowCasterFaces.
getter/setter pair
- shadowDepthBias ↔ double
-
Depth bias; see DirectionalLight.shadowDepthBias.
getter/setter pair
- shadowFadeRange ↔ double
-
Far-edge fade band; see DirectionalLight.shadowFadeRange.
getter/setter pair
- shadowMapResolution ↔ int
-
Per-cascade shadow-map resolution; see
DirectionalLight.shadowMapResolution.
getter/setter pair
- shadowMaxDistance ↔ double
-
Shadow view distance; see DirectionalLight.shadowMaxDistance.
getter/setter pair
- shadowNormalBias ↔ double
-
Normal bias; see DirectionalLight.shadowNormalBias.
getter/setter pair
- shadowSoftness ↔ double
-
World-space penumbra radius; see DirectionalLight.shadowSoftness.
getter/setter pair
- source ↔ SunSky
-
The sky whose sun aims the light.
getter/setter pair
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
) → DirectionalLight - Updates light from the current sun and returns it. Called by the engine once per frame before the scene is shaded; not part of the app-facing API.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited