pub enum ViewLighting {
Scene,
Fixed {
key: DirectionalLight,
environment: Vec3,
},
}Expand description
What lights a view’s surfaces — see ViewDesc::lighting.
Variants§
Scene
The frame’s own light: the sun and every light row
ForwardRenderer::set_lights handed over, the sky’s irradiance, the
irradiance probes, the reflections and the fog. What the primary camera
is lit by, and what every view was lit by before this choice existed.
Fixed
One constant light, whatever the frame is lit by: the key’s direction
and colour as the only direct light, its
ambient as the only diffuse indirect one,
and environment as the only thing a reflection sees.
For a picture that must not change with the world around it, such as a model rendered into an inventory icon: the same model under the same fixed light draws the same pixels in a sunlit level and a dark one.
§What it ignores
- The frame’s sun and every light row — a point, spot or rectangle light near the view’s camera included. The key light is the view’s one row, which is a choice rather than a limit: an icon’s model is placed away from the world, so a local light that did reach it would be lighting it by accident.
- Every shadow. The key light is not occluded — not by the frame’s
cascades, which were fitted to the primary camera and cover whatever
happens to be there, and not by contact shadows. The view’s frame
block names no shadow map: every atlas rectangle in it is empty, which
the shaders read as a map never rendered and answer lit. The frame’s
atlas is still drawn and the view’s instances may still cast into it;
see
ForwardRenderer::set_instance_casts_shadow. - The sky and the irradiance probes: the view’s frame block carries
no sky rows and an empty probe header, and the view binds a probe
table of one zeroed row in place of the scene’s — to the forward pass,
the reflection march and the water surface alike — so the diffuse
ambient is the fill alone and a reflection that finds no geometry
sees
environmentalone. - The air:
Self::SCENE_EFFECTSare dropped from the view’s effects whateverViewDesc::effectsasked for, and the height fog isFog::NONE.
What it keeps is everything the view’s own geometry decides: its
materials and emission, its ambient occlusion, its reflections of
itself, and every effect after the forward pass. The background is
ViewDesc::background’s, so a view asking for
ViewBackground::Scene still draws the frame’s sky behind a model it
does not light.
Fields
key: DirectionalLightThe one direct light, and in its
ambient the diffuse fill.
environment: Vec3The radiance a reflection sees in every direction — a uniform
environment, in linear RGB, that may exceed 1.0 like the key’s
colour. It is what gives a dark glossy surface its sheen: a
near-black dielectric scatters almost none of the key and the fill,
and still reflects this at its F0, rising towards grazing angles
by the split-sum Fresnel term — so what the camera sees edge-on
reads brighter than what faces it. A metal reflects it tinted by
its base colour.
Specular only. A uniform environment of radiance L would also
reach a diffuse surface, as π·L — what Self::Scene adds for
a uniform crate::Sky of that radiance — but here that half
is the key’s ambient and nothing else, so the two are never
summed and the fill means what it meant before this field existed.
A caller who wants the pair to describe one physical environment
sets ambient to π times this.
It reaches a surface through the reflection pass, so it needs
RenderEffects::REFLECTIONS in both the frame’s effects and
ViewDesc::effects; a view drawn without it reflects nothing.
Zero is a view whose reflections find nothing but its own geometry.
Implementations§
Source§impl ViewLighting
impl ViewLighting
Sourcepub const SCENE_EFFECTS: RenderEffects
pub const SCENE_EFFECTS: RenderEffects
The effects a ViewLighting::Fixed view never draws, because each
brings the frame’s light into it: the froxel volume is lit by the sun
and the scene’s lights, and the contact march shadows along the frame’s
sun.
Reflections are not among them. The march’s fallback is the probe table
and the sky rows, and a fixed view hands it its own — the zeroed row and
a sky of environment in every direction — so what it reflects is the
view’s own geometry and the fixed environment.