Skip to content

Add real photographed environments as built-ins - #954

Draft
Rebornim wants to merge 26 commits into
storytold:mainfrom
Rebornim:feat/hdri-pass
Draft

Rebornim wants to merge 26 commits into
storytold:mainfrom
Rebornim:feat/hdri-pass

Conversation

@Rebornim

@Rebornim Rebornim commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Draft. Built, reviewed (three review rounds, a correctness review pass and an optimization pass) and green on the full gate on Linux and Windows. Left: the image files themselves are not in git; they wait on the maintainer's starter-asset setup, so this PR stays a draft until that exists. A test build is out with hand testers.

Real photographed environments and our own studio light setups become the built-in choices; the six drawn ones stay for older projects and for installs without the starter folder.

Part of #727.

What the user saw

The six built-in environments are drawn in code (soft boxes and gradients), so materials look flat next to a real HDR. A real HDR only works if every user imports one into each project.

Cause

There was no way to ship environment images with the app: built-in names only map to the drawn environments.

What changed

  • core::starter_environment: ten CC0 maps (Poly Haven), each with its file name, an exposure offset (Studio Small 03 is 1.3 stops hot) and the drawn environment that stands in for it when its file is missing.

  • compose::starter_registry + compose::environment_image::resolve: the last three decoded starter images, outside the project, and one lookup every environment reader now uses (viewport, headless render, path tracer, Environment Lighting, composite keys), so a starter image is never saved into a project and never counts as a used resource.

  • engine::starter_environment_loader: reads starter_assets/environments/<file> beside the executable (or TEXTURECRAFT_STARTER_ASSETS for a checkout); checks file size and texel count before decoding, applies the exposure offset once, turns unusable values into 0. display.set accepts the new names; it and project open reply with a warning naming the stand-in when a file is missing.

  • display.environments: every built-in environment with its kind (drawn or starter), whether its file is installed, and its stand-in.

  • The CLI prints a project's open warning (warning: ... on stderr) for every subcommand that opens one, so a render without the starter folder says what it showed instead.

  • Desktop and headless sessions read the starter folder at start. The browser has no install folder: starter names show their stand-in there.

  • Environment images (imports and starter maps) get their own prefilter (ibl::Prefiltered::image): no 64 clamp, so a sun or lamp keeps its light in rough reflections; up to 8 levels (one per halving, 6 for small images) on a perceptual curve (ibl::roughness_to_lod: level = sqrt(roughness)), so a low roughness reads one softened level instead of the sharp image over a blurred copy; trilinear pyramid reads and 512 samples from level 2, so an unclamped sun blurs without streaks; each level reads the pyramid at its own resolution or coarser, so narrow lobes don't alias. The shaders read the curve from the sign of Globals.env.y (env_lod in mesh.wgsl); background blur uses the same curve.

  • Key light from the image (compose::environment_key_light, ibl::Prefiltered::lit_image, ibl::EnvLight): around an image's brightest texel, what stands over a threshold within 8° becomes one directional light when it carries at least 15% of the image's energy (a sun, a bright lamp). Its direction, colour and angular size come from the image; it casts the shadows and stays on with shadows off, because its energy leaves the rough reflection levels and the diffuse SH (counted once, not twice). Level 0 keeps the light itself, so mirrors still show the sun; the direct highlight fades in as roughness leaves level 0 and is widened by the light's size (mesh.wgsl). An image without such a light turns the display's key light toward its brightest side (the first SH band) instead of the fixed direction. A starter entry can set the direction instead (StarterKeyLight::Toward, for the generated studio setups).

  • The viewport filters environments on a worker thread (ui-egui gpu::environment_job): the frame used to run the filter itself, so picking a 2K image froze the app for about a second. At most one job runs and one waits (a newer pick replaces the waiting one); the viewport keeps the previous environment until the result is ready, and the last three results are kept, so switching back is instant. The renderer's filter is split into ibl::PreparedEnvironment::new (pure, levels packed as f16 texels) and Renderer::upload_environment; set_environment stays as both for headless renders. Starter files are still decoded by display.set (tens of milliseconds), so every path sees the image when the command returns. The browser filters inline (no threads).

  • The environment picker and the shelf's Environments tab list each starter environment whose file is installed, after the drawn ones (ui-egui starter_environments: the folder is looked up once per starter folder, not per frame). Their thumbnails are read from the file by the shelf's preview worker (ShelfPreview::StarterEnvironment), averaged down to the swatch, and only the swatch is kept; a file that is missing gives no tile. The slot and tiles show the name through tr().

  • cargo xtask studio-rigs <dir> [rig ...] (xtask/src/studio_rigs, layouts in rigs.json): ten studio light setups of our own as 2048x1024 Radiance maps (about 12 MB together), listed after the photographed maps: Three-Point Studio, Light Tent, Twin Strips, Overhead Panel, Raking Spot, Rim Backlight, Gradient Sweep, Ring Light, Window Grid, Beauty Dish. Each is a small scene ray-traced from the ball: real-size softboxes, strips, an octa, a ring light, a window grid, a curved gradient scrim, a fresnel spot or a beauty dish at real distances, bounce cards, a dark floor the lights light, or a fabric tent lit from outside, in a near-black void with faint halation. Every map is scaled so a white ball's brightest side gets the same light, so switching setups keeps the model's brightness. Deterministic (seeded SplitMix64 for the diffuser wrinkles), threads via std::thread::scope, written with image's HDR encoder (new xtask dependency, already a workspace one); about 45 s for all ten on a 4-core runner. Their entries set the shadow direction to each setup's main light (StarterKeyLight::Toward); Raking Spot takes its light from the image. The names were checked under naming rule 4 (docs/feature-names.md).

  • With any starter environment installed, the picker and the Assets panel list the installed ones (and imported images) instead of the six drawn ones (InstalledStarterEnvironments::drawn_listed); display.set and display.environments still take and list the drawn names, so a project saved with one opens and shows it. Without the starter folder (browser, a bare build) the drawn ones are listed as before. project.new, project.sample, file.new, file.open of a mesh file, the MCP/RPC server's starting project, headless mesh import/open, and the desktop app's start with a mesh argument or a --control project start with Three-Point Studio when its file is installed (Session::start_with_starter_environment; not an edit, not an undo step), else Studio Soft as before (an unreadable file keeps Studio Soft and the log says so, naming Studio Soft). Only the long-running servers (mcp, serve) do this for their starting project, so one-shot CLI commands don't decode a map they would replace. DisplaySettings::default stays Studio Soft, so a saved file without the field opens as before.

  • Environment tiles (picker and Assets panel) wrap their name onto two lines (TileLabel, the tile grows by one line), breaking between words, so names that differ only at the end, like Studio Small 08 and Studio Small 03, are no longer both cut to "Studio Small…". Other tiles keep one line; shelf rows are top-aligned (shelf::tiles) so an environment tile beside one-line tiles (Show all, search) keeps the thumbnails level.

  • ATTRIBUTION.md: a row per starter image (Poly Haven page, exact 2K file, MD5) and one for the generated setups; docs/architecture.md: where the starter folder is looked for and how its images are shared and filtered. docs/parity.md is unchanged: no menu item changed.

Drawn environments keep their filter, levels, curve and fixed key light, so projects that use them render as before. Imported resource: environments load, save and embed as before; their lighting now uses the image filter (brighter rough reflections where the image has a sun or lamp) and its key light. Browser limit: on wasm32 images keep the drawn environments' filter and fixed key light, since the image filter is too slow without threads.

Tests

  • view_cmds::tests::display_set_accepts_starter_environment: a starter name is accepted, its file is read from the session's folder and is what the renderers resolve; nothing is added to the project (fails on main: the name is rejected).

  • view_cmds::tests::display_set_starter_environment_without_folder_warns: without its file the name is kept and the reply names the stand-in.

  • environment_image::tests::starter_image_drives_filter_sh: Environment Lighting reads the loaded image, not the stand-in.

  • view_cmds::tests::environments_lists_drawn_and_installed_starter_ones: a starter environment is listed as available only when its file is installed (new command).

  • CLI starter_environments::render_finds_starter_folder (real binary, TEXTURECRAFT_STARTER_ASSETS): a project set to a starter environment renders without a warning; without the folder it still renders and says what stood in (fails on main: the name is rejected).

  • engine starter_environments::{starter_environment_name_round_trips_without_embedding, project_with_missing_starter_environment_warns_on_open, export_lit_with_starter_environment_uses_its_light}: saved by name only, the open warning, and Baked Lighting Environment lit by the starter image rather than its stand-in.

  • session::panic_hunt_starter_environment_files: empty, truncated, oversized-header, PNG and garbage files are refused with a warning; a one-texel file and texels near the float limit load; nothing panics while drawing.

  • ibl::tests::prefilter_keeps_hot_source_energy: a 10 000-nit spot gives every level 200x the light of a 50-nit one (fails on main: the 64 clamp).

  • ibl::tests::rough_reflection_has_no_ghost: a 1-texel line at roughness 0.1 is one soft lobe, not a spike over a blurred copy (main's linear curve reads 50% unfiltered level 0).

  • ibl::tests::{rough_level_is_smooth_around_a_sun, unclamped_filter_has_no_sparkles} (guards): levels around a 20 000-nit sun and among scattered hot texels stay within 5% of a converged 4096-sample filter; the cheap filter (128 samples, nearest level) is asserted to fail the same bound.

  • ibl::tests::level_count_follows_image_height.

  • environment_key_light::tests::{extracts_a_sun_and_conserves_energy, no_light_in_an_even_sky, hostile_images_give_no_light}: the light points at the sun, keeps its colour, and image plus light hold the image's energy.

  • ibl::tests::key_light_follows_image_sun: shadows come from the image's sun (main: always the fixed light); the light stays on with shadows off; diffuse light toward the sun is kept within 10% while the sun leaves the rough levels; level 0 is unchanged.

  • ibl::tests::key_light_without_sun_uses_dominant_direction, key_light_override_replaces_extracted, key_light_unchanged_for_synthetic (guard: every drawn environment keeps the fixed light, on and off).

  • starter_environment_loader::tests::{exposure_offset_scales_the_loaded_image, missing_file_warns_with_the_fallback}, starter_registry::tests::looked_up_image_outlives_older_ones, starter_environment::tests::every_starter_environment_falls_back_to_a_drawn_one.

  • gpu::environment_job::tests::{latest_request_wins, stale_result_is_not_shown, switching_back_skips_the_filter, new_image_under_the_same_name_is_filtered_again}: A, B, A picked while A filters gives one filter run of A and shows A; a finished environment the viewport moved away from is not shown; switching back reuses the kept result; a re-imported image under the same name is filtered again.

  • ibl::tests::prepared_environment_packs_every_level: every level is packed whole, level 0 being the image itself.

  • ui-egui kittests display_environment::environment_picker_lists_found_starter_environments and shelf_panel::shelf_lists_starter_environments_with_thumbnails: with a starter folder holding one file, that environment is offered and picking it sets it; one without its file is not offered; the shelf tile gets a thumbnail from the worker (fail on main: no starter environment is listed).

  • starter_environment_loader::tests::a_new_project_starts_with_the_installed_starter_environment: with the file installed project.new and file.open of a mesh start with Three-Point Studio and the project is unmodified; an unreadable file keeps the drawn default and logs it; without the folder it keeps the drawn default (fails on main: always Studio Soft). shelf_panel::shelf_lists_starter_environments_with_thumbnails now also asserts Studio Soft is not listed once a starter one is installed. shelf::tests::an_environment_tile_label_wraps_instead_of_cutting_its_end: "Studio Small 08" keeps its "08".

  • preview_request::tests::a_starter_environment_preview_shows_its_file_and_none_without_it: the thumbnail is read from the file (bright half stays bright), none without the file.

  • xtask studio_rigs::tests::exposure_is_normalised: every setup's written file, read back, lights a white ball to its set level within 2% (through the encoder and the mantissa rounding); backdrop_behind_the_ball_stays_dark: behind the ball, as the default camera sees it, the void stays under 5% of the brightest light (both new code).

Verification

  • cargo check of the touched crates and apps (with tests) on Linux, Rust 1.95.
  • The tests above: GitHub runner (ubuntu-24.04, Rust 1.96): commit 5: the 4 environment_job tests and the packing test passed; commit 1's 7 passed; at commit 2 all 10 starter tests (engine lib, engine it, session hunt, CLI it) passed; at commit 3 the render ibl tests passed (9); commit 4: the 7 key-light tests (compose 3, render ibl 4) passed; commit 6: the 2 new kittests with the 11 existing environment/shelf kittests (13) and the thumbnail unit test passed; commit 8: both studio_rigs tests passed, and the generator's ten maps match the prototype it was ported from to within one RGBE step (largest difference 1.1% of a map's peak, no texel more than 2% off, same file sizes). Commit 9 (snapshot test): run on the GitHub runner with the ten photographed maps downloaded from their source and the ten setups generated by cargo xtask studio-rigs. Not run for commits 6-9: whole-workspace tests, clippy, xtask wasm, xtask layers (the upstream gate runs them once the PR is ready).
  • Commit 10 (final, after three review rounds): GitHub runner (ubuntu-24.04, Rust 1.96): -p texturecraft-engine -p texturecraft-core -p texturecraft-automation --lib starter (7 passed), -p texturecraft-ui-egui --test it -- environment shelf_ starter (79 passed, 1 ignored), -p texturecraft-ui-egui --lib -- shelf starter (13 passed), -p texturecraft-cli --test it (27 passed). A Windows exe and a Linux release build of this commit went out to hand testers with the 20 starter maps beside them.
  • Commits after commit 10 (review fixes, cleanup, optimization): see Validation and limits and Optimization below.
  • Not run by us: the desktop app by hand with a real starter folder (a test build is out with testers). The key light's shader part (lobe widening, fade-in, tint) has no CPU test; it is checked by eye in the snapshot round.

Validation and limits

  • Local (Linux VM, Rust 1.95.0): cargo fmt --all -- --check, cargo check --all-targets for core, compose, render, engine, automation, ui-egui, the CLI, the desktop app and xtask, and git diff --check: all clean on the final commit.
  • Regression tests, each run first with its fix removed and seen failing on the defect itself (GitHub, Ubuntu, Rust 1.96.0): picking a starter environment in Display Settings loads its file; display.set writes an unreadable file's warning to the Log; undo back to a starter environment loads it again; the viewport cache frees an environment whose image is gone. All four pass with their fixes.
  • Touched tests on GitHub at the review commit: engine lib 18, engine it starter module 4, the panic hunt including the hostile starter files 3, render/compose/core 32 (one ignored benchmark), ui-egui it 40 and lib 15, CLI it 1, automation lib 32, xtask studio rigs 2.
  • The six drawn environments' prefilter and SH hash identical to main, and four regenerated studio rig maps are byte-identical before and after this pass's renames.
  • Fork CI (fmt, layers, clippy -D warnings, tests, wasm; Ubuntu and Windows): green on both at the review pass's last commit and again at the optimization pass's last commit (the head of this PR); wasm runs on the Linux leg only, by xtask ci design. Linux 4312 tests passed, Windows 4290, none failed after one rerun (see the flaky test below).
  • Snapshots: not rerun in this pass (no pixels or layout changed); the starter-environment snapshot set from before is the visual record.
  • N/A cells: browser has no starter folder, so starter environments show their drawn stand-in there and the light extraction and off-thread filtering are compiled out; headless filters inline by design (no frame to keep); GPU-only paths (shader key light, filter look) are covered by CPU tests of the same math and by snapshots, since CI has no GPU adapter; Environment Lighting is project-wide, so a several-texture-set test adds nothing.
  • Limits: Linux with software Vulkan; Windows interaction, GPU memory, screen readers and real thread-spawn failure are not exercised.
  • Accepted operator decisions: the 20 starter environments (10 Poly Haven photo maps, 10 generated studio setups), the six drawn ones hidden from the picker and Assets panel once a starter environment is installed but still accepted by display.set, new projects on Three-Point Studio, two-line environment tile labels.
  • Known flaky test, not from this branch: materialcraft_link::image_with_material_extension_reopens_as_an_image can lose the process-wide RAM allowance to a concurrent cook test, issue Flaky engine tests: parallel tests share the process-global MaterialCraft RAM allowance, so a save can fail with "a MaterialCraft cook is using the RAM allowance" #832; it failed once on Linux and passed on rerun of the same commit.
  • Overlaps with open PRs on shared files: Add custom GLSL shaders and searchable sphere previews #895, fix(render): repeat textures and wrap samples across offset UV boundaries (#375) #414 and feat(render): add displacement height scale setting (#430) #497 (renderer, viewport GPU, render modes), Add turntable export: animated GIF and PNG sequence #266 and Orbit around the part of the mesh you panned to #845 (render and display commands), Add library normal maps generated in code to the Textures tab #918, Pattern looks: every starter pattern drawn to tile, with its own controls #946 and Preview user smart materials in the shelf #405 (shelf entries and thumbnails). This PR changes only the environment parts of those files.

Optimization

Each row compares the PR code right before the change with the changed code, on the same workload; release build, GitHub ubuntu-24.04, 4 cores, median of 3 interleaved runs (texturecraft-builds 47155153094, 47151949423). Each workload is three distinct environments prepared for the viewport (PreparedEnvironment::new, what every environment switch runs).

Workload and metric Before After Reduction
Three 2048x1024 maps with an extracted sun, peak live heap per switch 117,449,344 B 67,117,664 B 42.85%
Same, cumulative allocation 444,861,863 B 293,867,111 B 33.94%
Three 2K Poly Haven photo maps, peak live heap per switch 92,283,520 B 55,923,726 B 39.40%
Same, cumulative allocation 419,736,840 B 268,742,088 B 35.97%
Three 2K studio rigs, peak live heap per switch 92,283,520 B 55,923,730 B 39.40%
Three 1600x800 imports, peak live heap per switch 56,330,808 B 34,132,962 B 39.41%
Three 2K photo maps, peak live heap, levels dropped as packed 55,923,726 B 50,356,224 B 9.96%
Three 2K photo maps, filter time (pyramid level tabulated) 9,212.7 ms 8,921.5 ms 3.16%
Three 2K studio rigs, filter time 9,142.3 ms 8,798.2 ms 3.76%
1,000 warm viewport frames, allocations in the environment poll 1,000 calls (11,000 B) 0 calls 1,000 fewer

Output hashes (every packed level, SH and key light) matched before and after in every workload and every run. Copy removal: the image filter now takes its image and returns it as level 0 instead of cloning it for the pyramid, for level 0 and (with an extracted light) once more. Filter time ranges did not overlap (photo 9,203-9,240 ms before, 8,897-8,930 ms after; 3.2-3.8% across all five workloads); the copy removal itself left time within noise. Nothing new stays in memory. Rejected: reserving packed levels at exact size (already exact: 67,107,840 B retained for 2K before and after; removed again); hoisting the starter-name lookup out of the drawn sky (2.3-3.0 ns of a 62 ns texel); the registry lookup per tile (about 8 ns, no allocation). Deferred as follow-ups: thumbnails decode the whole 2K file per swatch (a smaller cached preview would fix it), and the filter's sample counts set the remaining ~3 s per 2K map (lowering them changes pixels, so it needs its own visual review). Not measured: GPU memory and shader cost, Windows, browser.

Memory

Five distinct starter images in a registry kept three (1,573,355 B) and released all of them with it (0 B above baseline). Six distinct imported environments shown in the viewport job, then dropped: their filtered levels were pruned and live heap returned to baseline (0 B), one drawn entry kept. Every prepared environment released all its memory when dropped (0 B, all workloads). The process-wide starter registry stays bounded at three images across project close by design.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@Rebornim
Rebornim force-pushed the feat/hdri-pass branch 6 times, most recently from 2ceaba9 to 66f2b0a Compare December 3, 2026 10:34
Ten photographed environments (CC0 maps) become built-in names that
display.set accepts. Their images are read from the install's starter
folder (starter_assets/environments beside the executable, or
TEXTURECRAFT_STARTER_ASSETS for a checkout), never from the project, so
nothing new is saved into it.

- core: the starter list with each map's file, exposure offset and the
  drawn environment that stands in for it when the file is missing
- compose: a small registry of the last decoded starter images and one
  resolver that every environment reader now uses (viewport, headless
  render, path tracer, Environment Lighting, composite keys)
- engine: the loader (size and texel limits before decoding, exposure
  applied once, unusable values as 0), Session::starter_dir, and a
  warning in display.set and project open replies when a file is missing
- desktop and headless sessions read the starter folder at start

Drawn environments and imported resource: environments are unchanged.
- display.environments lists the drawn and the starter environments, with
  whether each starter file is installed and what stands in for it
- the CLI prints a project's open warning (a starter environment whose
  file is missing) for every subcommand that opens a project
- tests: CLI render with and without the starter folder, project
  round trip by name only, open warning, Baked Lighting Environment lit
  by a starter image, and hostile starter files in the panic hunt
…r reflections

Environment images (imports and starter maps) get their own prefilter;
the six drawn environments keep theirs, so old projects render as before.

- no 64 clamp: a sun or a lamp keeps its light in rough reflections
  instead of half the image's energy disappearing above roughness 0
- up to 8 levels (one per halving, from 6 for small images) on a
  perceptual curve (level = sqrt(roughness)): a low roughness reads one
  softened level instead of the sharp image under a blurred copy
- trilinear pyramid reads and 512 samples from level 2 on, so an
  unclamped sun blurs smoothly instead of drawing streaks; each level
  reads at least its own resolution, so a narrow lobe cannot alias
- shaders take the curve from the sign of the lod scale; background blur
  and the sampled bake view use the same levels
- the browser keeps the drawn environments' filter for images (no
  threads there: the new one is too slow on one core)
- tests: hot spot light kept in every level, no ghost line at roughness
  0.1, no streaks around a sun or sparkles from hot texels against a
  converged filter (with the cheap filter shown to fail), level count
A bright light in an imported or starter environment image becomes the key light: its
direction, colour and size come from the image, it stays on with shadows off, and its
energy leaves the rough reflection levels and the diffuse light so it is not counted
twice. Images without one turn the key light toward their brightest side. Drawn
environments keep the fixed light.
Picking an environment image filtered it inside the frame, so the app
froze for about a second on a 2K map. The viewport now filters on one
worker thread (at most one job running and one waiting; a newer pick
replaces the waiting one), keeps showing the previous environment until
the result is ready, and keeps the last three results so switching back
is instant. The renderer's filter is split into PreparedEnvironment::new
(pure, any thread) and upload_environment; set_environment stays as
both, for headless renders. The browser filters inline (no threads).
… shelf

The picker and the Environments shelf tab show each starter environment
whose image file is in the starter folder, after the drawn ones. The
folder is looked up once per starter folder, not per frame. Thumbnails
are read from the file by the preview worker and only the swatch is
kept; a missing or unreadable file gives no tile.
…d from

ATTRIBUTION lists the ten 2K Poly Haven images the install's starter
folder carries, with their exact files and checksums. The architecture
notes say where the folder is looked for, what a project saves, and how
the images are shared, filtered and lit.
…ents

cargo xtask studio-rigs <dir> writes ten studio light rigs in a dark void
(Three-Point Studio, Light Tent, Twin Strips, Overhead Panel, Raking Spot,
Rim Backlight, Gradient Sweep, Ring Light, Window Grid, Beauty Dish) as
2048x1024 Radiance maps, each scaled so a white ball gets the same light.
The starter list gains them, with shadows toward each rig's main light.
…each starter environment

An ignored snapshot test reads the starter folder named in TEXTURECRAFT_STARTER_ASSETS and
writes the viewport under every installed environment (the sample material, then a smooth
white metal), the Environment Map picker with a tile hovered, the Assets panel's
Environments type and the Properties orb; TC_UI_THEMES adds the dark and light themes.
@Rebornim
Rebornim force-pushed the feat/hdri-pass branch 3 times, most recently from abb707e to 1b906d0 Compare December 3, 2026 13:29
…oint Studio and wrap environment names

With the starter folder installed, the environment picker and the Assets panel list its environments
instead of the six drawn ones; display.set still takes the drawn names, so older projects keep theirs.
project.new, project.sample and file.new start with Three-Point Studio when its file is there.
Environment tile names wrap onto two lines, so Studio Small 08 and Studio Small 03 are told apart.
The panel writes the display settings directly instead of running
display.set, so it never loaded the picked starter environment: the
viewport, Rendering mode and Environment Lighting showed its drawn
stand-in until something else loaded it. The panel now reads it, as
display.set does, and logs the warning when the file can't be read.
The desktop Assets panel ignores display.set's reply, so an installed
but unreadable starter file showed its stand-in with no word. The
warning now also goes to the Log, as it does on file.open.
The registry keeps only the last three starter images, so undoing to a
project state whose environment had been dropped showed its drawn
stand-in in the viewport and Environment Lighting.
A closed project's imported environment or an evicted starter image can
never be shown again, yet its filtered levels stayed in the viewport's
cache until three newer environments pushed them out.
…its steps

Named constants for the key light's extraction threshold and the
prefilter's sample counts, a clearer name for the pyramid read, and a
blank line after early exits in the methods this branch changed.
Spec::f becomes Spec::number, and the generator's k, img, p and e read
as scale, map, texel and error; the maps it writes are unchanged.
LodCurve, EnvLight, Prefiltered and PreparedEnvironment move out of
ibl.rs into ibl/, re-exported at the same paths; the viewport job's key
is spelled EnvironmentKey and its shared state moves to
environment_worker_state.rs. Moves and renames only.
A thread that fails to spawn drops its job, so the request stayed
marked as running and no later environment was ever filtered, while
the log claimed it was filtered on the UI thread. Also the nested if
that clippy's collapsible_if refuses.
The image filter took its source by reference, so it cloned the image for the
pyramid and again for level 0, and the extracted-light path cloned it once more
through struct update syntax. The filter now takes the image and moves it.
The viewport keeps the last three packed environments. Each level grew byte by
byte, so a size that is not a power of two kept up to twice its bytes; it is
now reserved once at its final size, and each filtered level is dropped once
it is packed.
The viewport asks for its environment every frame. Building the lookup key
copied the name into a new string first, even when the environment already
showed; that case is now answered from the shown key directly.
Measured, the packed levels already came out at their exact size: collecting
from fixed-size arrays sizes the vector up front. The reservation added in the
previous commit changed nothing, so it and its test assertion go; dropping each
filtered level once it is packed stays, since it lowers the peak.

This branch has not been deployed

No deployments
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.

1 participant