Skip to content

Lighting: shadow views, SSAO, baked light, and what HDR draws of a grade - #136

Merged
larelgit merged 7 commits into
mainfrom
claude/lighting-mechanisms
Nov 27, 2026
Merged

larelgit merged 7 commits into
mainfrom
claude/lighting-mechanisms

Conversation

@larelgit

Copy link
Copy Markdown
Owner

Lighting mechanisms for games whose levels look flat under a small shadow budget and no baked light (Cranium's Level 1 tunnels). Everything is opt-in and off by default: a game that asks for none of it draws exactly as before.

What it adds

  • Shadow budget in views (graphics.shadow_views, 0 to 384, default 0). Counts the budget in shadow views instead of lights, so a point light costs 6 and a spot 1, and many spots can cast where one point would. At 0, shadow_lights works as before, tool texts included.
  • SSAO from camera content (picture.ssao: Some((quality, radius, thickness))). The world camera gets Bevy's ScreenSpaceAmbientOcclusion, the depth and normal prepasses, and Msaa::Off. Taking it out gives the camera back its own MSAA and prepasses. The view-model camera follows the world camera's MSAA and has no SSAO.
  • Baked light for levels. Level nodes name their baked files (lightmap, lightmap_rect, irradiance_volume, reflection_probe, probe_falloff), and the picture-only content kind baked_light names a level's sets. A drawn level puts Bevy's Lightmap on its meshes (second UV map) and LightProbe with IrradianceVolume / EnvironmentMapLight on its probe boxes. select_baked_set switches sets at run time, for example when a story beat turns lamps off. A content light with baked: true skips lightmapped meshes' diffuse. Two Bevy 0.20 limits are worked around: a changed Lightmap is ignored, and adding or removing one doesn't re-pick the pipeline.
  • Confining a light to a room: researched, not built. Bevy's clustered lights carry no volume, so this needs a patched bevy_pbr. The manual says what that would take.
  • Colour grading and HDR, documented. Without HDR, Bevy draws only a grade's exposure; white balance, sectional grading and hue rotation exist only in the tone-mapping pass. Bloom puts a camera in HDR, so a grade tuned without HDR draws for the first time. In Cranium that turned the picture black and red. Rendering is unchanged here. What changed:
    • the docs give the real scale of temperature and tint, and the contrast pivot;
    • the lights query gains a drawn: line;
    • Grading::hdr_only and grade_drawn_in_full are new;
    • an offscreen test pins Bevy's behaviour.

Tests

  • Offscreen tests: a lightmapped mesh draws its lightmap, switches sets, and still takes dynamic lights.
  • Offscreen test: SSAO through the first-person cameras.
  • The grading behaviour test.
  • An ignored measurement of SSAO's GPU cost.
  • shards_light and shards_motion tests, the sandbox scenarios, and the lights and first-person GPU tests pass locally. Clippy is clean.

Not done

  • Grading the first-person arms under HDR (drawing them before the world camera's tone mapping).
  • Narrowing the temperature/tint range check. That would fail Cranium's content until its grades are retuned.

🤖 Generated with Claude Code

…spot 1

graphics.shadow_views (0 to 384, default 0) counts the shadow budget in
shadow views instead of lights: the lights that ask go nearest first, each
taking its views while they fit, and a farther light that fits may still
cast one. Above 0 it replaces shadow_lights; at 0 nothing changes, tool
texts included. The lights query and ai/status say the budget in views,
how many are taken, and what a light that missed out takes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
picture.ssao: Some((quality, radius, thickness)) in the camera content gives
the world cameras Bevy's ScreenSpaceAmbientOcclusion, the depth and normal
prepasses they lack and Msaa::Off (Bevy draws no SSAO under MSAA), put
back when another module takes a prepass away. Taking it out gives the
camera back its own SSAO, MSAA and prepasses. The view model's camera
follows the world camera's MSAA and has no SSAO. Off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…run time

Level nodes name their baked files (lightmap, lightmap_rect,
irradiance_volume, reflection_probe, probe_falloff); the picture-only
content kind baked_light names the folders of a level's sets and their
exposure. A drawn level puts Bevy's Lightmap on the meshes (by their
second UV map) and LightProbe with IrradianceVolume / EnvironmentMapLight
on the probe boxes. select_baked_set switches a level's set (BakedLight, a
resource of the picture); tools baked_light and baked_light_set. A content
light with baked: true lights no lightmapped mesh's diffuse.

Two Bevy 0.20 limits are worked around: a changed Lightmap on a mesh that
has one is ignored (a switch takes the old one off for a frame once the
new image is loaded), and a Lightmap that comes or goes does not pick the
mesh's pipeline again (the mesh is marked changed with every one, or wgpu
fails validation and Bevy stops drawing). Offscreen tests: a lightmapped
mesh draws its lightmap, switches sets and still takes dynamic lights;
and an ignored measurement of what SSAO costs on the GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The manual's picture, settings, lights and levels sections, the agents'
notes, CHANGELOG and engine-progress. Confining a light to a room was
researched and not done: Bevy's clustered lights carry no volume, so it
needs a patched bevy_pbr; the manual says what that would take.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…meras

Drawn for real in the sandbox: SSAO on the first-person camera with the view
model's camera following its MSAA, a depth prepass taken away for a frame
put back with the frames going on, and SSAO out again giving both cameras
their MSAA back. Each picture is taken once the pipelines are compiled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bevy grades a camera that does not draw in HDR in each material's shader,
where only the exposure is applied (WHITE_BALANCE, SECTIONAL_COLOR_GRADING
and HUE_ROTATE exist only in the tone mapping pass's pipeline). A bloom
puts the camera in HDR and draws the rest of a grade for the first time,
so a grade tuned without HDR (a game's temperature 0.2, contrast 1.2)
turned its picture black and red. Nothing draws differently: the docs
now say which fields need HDR, the real scale of temperature and tint
(an offset to the CIE white point) and the contrast pivot, and the
lights query adds a drawn: line. Grading::hdr_only, grade_drawn_in_full,
and an offscreen test that pins Bevy's behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grading::hdr_only takes a field within 0.0005 of neutral as neutral, as the
lights query prints it, so the end of a blend never says "leaves out" beside
"shows: neutral". The tint's scale is stated as Bevy's formula gives it,
not as a measured range. engine-progress counts the shards_light tests
(9 and 19) and names the new ones; the agents' cookbook has the drawn: line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@larelgit
larelgit merged commit 5de6b4c into main Nov 27, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants