DirectionalLight class
An infinitely-distant light source (e.g. the sun) that illuminates the whole scene from a single direction.
Attach one to a Scene via Scene.directionalLight; leaving it null gives image-based lighting only (the historical behavior). The analytic contribution is layered on top of the IBL ambient term. The shader normalizes direction, so it need not be unit length.
When castsShadow is true the renderer adds a depth-only shadow pass. Shadows are cascaded: the camera view is split into shadowCascadeCount depth ranges out to shadowMaxDistance, each fit with its own shadow map so near geometry stays crisp over a long view distance. The penumbra is a soft Poisson-disk PCF kernel of radius shadowSoftness, and shadowing fades back to lit at the far edge over shadowFadeRange. Cascaded shadows require the scene to render with a PerspectiveCamera.
Constructors
- DirectionalLight({Vector3? direction, Vector3? color, double intensity = 3.0, bool castsShadow = false, double shadowFadeRange = 2.0, double shadowSoftness = 0.08, int shadowCascadeCount = 4, double shadowMaxDistance = 150.0, double shadowCascadeSplitLambda = 0.6, int shadowMapResolution = 1024, double shadowDepthBias = 0.02, double shadowNormalBias = 0.02})
- Creates a DirectionalLight.
Properties
- castsShadow ↔ bool
-
Whether this light casts shadows (adds a shadow-map pass).
getter/setter pair
- color ↔ Vector3
-
Linear RGB color of the light.
getter/setter pair
- direction ↔ Vector3
-
The direction the light travels, in world space (from the light
toward the scene). Need not be unit length.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- intensity ↔ double
-
Scalar multiplier applied to color.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shadowCascadeCount ↔ int
-
Number of shadow cascades, clamped to 1 through 4. More cascades
keep shadows crisp over a longer view distance, each at the cost
of one more depth pass. Used by computeCascades.
getter/setter pair
- shadowCascadeSplitLambda ↔ double
-
Blends the cascade split spacing between logarithmic (
1.0) and uniform (0.0). Higher values give the near cascades proportionally more resolution. Used by computeCascades.getter/setter pair - shadowDepthBias ↔ double
-
World-space depth bias subtracted from the receiver before the
shadow test. Converted into each cascade's clip-space depth range,
so a caster's shadow appears at the same world-height threshold in
every cascade rather than fading out in the coarser far ones.
getter/setter pair
- shadowFadeRange ↔ double
-
World-space width of the band at the far shadow cascade's edge
over which shadowing fades back to lit, so the shadow distance
limit is soft rather than a hard cutoff.
0disables the fade.getter/setter pair - shadowMapResolution ↔ int
-
Pixel resolution of the (square) shadow map. With cascades this is
the resolution of each cascade's tile.
getter/setter pair
- shadowMaxDistance ↔ double
-
View distance, in world units, out to which computeCascades
spreads the shadow cascades. Beyond it surfaces are unshadowed.
getter/setter pair
- shadowNormalBias ↔ double
-
World-space offset along the surface normal applied to the receiver
before the shadow lookup ("normal-offset shadows"). Flutter GPU has
no slope-scaled depth-bias rasterizer state, so this carries the
load of acne removal on grazing surfaces.
getter/setter pair
- shadowSoftness ↔ double
-
World-space radius of the shadow penumbra. Larger values give a
softer shadow edge;
0gives a hard edge. Sampled by a rotated Poisson-disk PCF kernel.getter/setter pair
Methods
-
computeCascades(
PerspectiveCamera camera, double aspectRatio) → List< ShadowCascade> -
Builds the shadowCascadeCount shadow cascades that cover
camera's view out to shadowMaxDistance, for a render target of the givenaspectRatio. Returned near-to-far. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited