Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. CodeRabbit Verify
|
|
I'm taking this one for review. |
|
Review notes (prepared with Claude Code) PR #276Verdict: hold for rework, then merge. The idea and the filter are right, but the branch no longer applies to main, and a straight port still has three gaps. What I checked
Changes requested
Smaller notes
I have a working port onto current main (item 1) with items 2 and 3 done, and it merges cleanly; item 4 is not done. I can share it if that helps, or you may prefer to do it so the change stays yours. 🤖 Generated with Claude Code |
Every reader of a baked map took one texel per output texel (nearest). The mesh-map view caps its texture at 2048, so an 8K bake was shown as 1 texel in 16 and thin AO creases came out dotted and stair-stepped. Viewport AO, the baked normal, mesh-map generators and export read the same way whenever the document resolution is below the bake's (storytold#195), and so does a UV tile painted below its block's resolution. Add texel::area_downsample, a box filter weighted by overlap that handles non-integer ratios and each axis on its own, and BakedMaps::view, which reads the listed maps through levels averaged down to what the reader samples. Bakes are read per UV tile through BlockScales::bake_uv, so there is one level per distinct tile scale, each block holding as many texels as the reader samples there, picked per texel with BlockScales::at; a set without tiles or overrides gets a single level at the reader's size. Averaged normals, world normals and bent normals are renormalised to unit length. ID maps are never averaged. Levels are cached by source data, so undo snapshots share them, with least-recently-used eviction past 1 GiB. The compositor, the display tiles (tile_bytes now takes a BakedView from display_view, so the GPU display reads what the CPU compositor reads), the mesh-map view and export all go through it. Reads at the same or a larger size are unchanged.
6a800ef to
d237c30
Compare
|
Thanks @SteamSmith, and for offering your port. I've pushed my own, d237c30, which is one commit on current main and replaces the old one. The description is updated.
From the smaller notes:
I ran |
Main's display writes half-float normals, the compositor evaluates through EvaluationInputs, and export owns more of the tiling. The averaged view carries over to each: - the Normal display reads the baked normal through the view (BakedView::has replaces the map lookup), keeping main's checks on invalid samples; - every Texel::new, including main's new ones in anchor heights, filter regions, input colors and folder thumbnails, takes a view made once before its parallel loop, from the evaluation's plain inputs; - the upload paths main added (selected display kinds, batched headless uploads, the automation perf test) pass a display view.
Fixes the display side of #195.
Updated: ported onto main's per-UV-tile bake layout, with the review's requests: renormalised directions, a byte-bounded cache and per-tile levels.
Cause
The bake is fine: 8×8 AA is an exact box filter in the baked data. The readers throw it away. Every reader of a baked map at a lower resolution than the bake used
BakedMaps::sample, which takes one texel per output texel (x·W/size, nearest):mesh_map_rgbafills the aux texture, capped at 2048 (aux_size), so an 8K bake is shown as 1 texel in 16. Thin AO creases come out dotted and stair-stepped, with AA on or off.display.rs, Orm) and the baked normal under the shown normal: they are read at the document resolution.BlockScales::bake_uv, so a tile at a quarter of its block's resolution reads one baked texel in four along each axis, even when the set matches the bake.Fix
texel::area_downsample: a box filter over dense float images. Each output texel averages the source texels it covers, weighted by overlap. It handles non-integer ratios and rectangular images, and each axis is filtered on its own. It is linear in source texels, rows run in parallel with rayon, and hostile sizes returnNone. It lives intexel(L0), the lowest crate every reader can reach;texelnow depends on rayon, asgeomalready does.BakedMaps::view(read, working, &BlockScales, maps) -> BakedView: there is one level per distinct tile scale. Each holds as many texels per block as the reader samples there, and it is picked per texel withBlockScales::at. A set without tiles or overrides gets a single level at the reader's size. Blocks at or above the bake's resolution read through main'ssample_working, unchanged. ID maps are never averaged, because their colours are labels. Averaged normals, world normals and bent normals are renormalised to unit length. The averaged levels are cached by source data identity: aWeakto the map'sArc, with least-recently-used eviction past 1 GiB.BakedMaps::mapsnow documents that baked data is replaced, never mutated in place, which the cache relies on. One view per composite block, upload pass or export costs a lock and a lookup. The averaging runs outside the lock, so rayon work-stealing can't deadlock on it. The cache is a process-widestatic, not a field onBakedMaps, because a new field would break the struct literals other crates use. I'm happy to move it if you'd rather have it owned by the session.Texelholds a view for AO, curvature and thickness, made once per pass before its parallel loop),tile_bytes(now takes aBakedViewfromdisplay_view, so the GPU display reads exactly what the CPU compositor reads),mesh_map_rgba, and export (Samplergets a view of the maps the planned files read).The averaging is linear in source texels. A quick single-run release measurement on an M3 Pro (machine under other load) gave: 8192² → 2048² in 14 ms for a scalar map and 27 ms for a 3-component map; 8192² → 4096² in 20 ms.
Verified
views_average_larger_bakes(store)baked_ao_is_averaged_down_to_the_set(Orm display)generators_average_a_larger_bake(AO generator: the result matches a same-size bake of the average, and differs from the nearest pick)a_larger_bake_is_averaged_not_point_sampled(mesh-map view)a_larger_bake_exports_averaged(export)BakedMaps::sample.viewforced to skip averaging (exactly the old nearest reads), all five reader tests fail, and so does the single-axis-shrink check. The ID guard passes either way, as it should.id_maps_are_never_averaged).levels_are_cached_by_their_data). Least-recently-used eviction within the byte budget: use refreshes an entry, an oversized level is kept alone, and dropped bakes are purged (the_level_cache_keeps_the_most_recently_used_within_its_byte_budget).each_tile_block_is_averaged_to_its_own_resolution,tile_blocks_at_or_above_the_bake_read_nearest,baked_ao_in_a_smaller_uv_tile_is_averaged_down_to_it(main reads white there, this reads 0.75) andeach_uv_tile_is_averaged_at_the_resolution_the_view_shows_it.averaged_directions_stay_unit.cargo nextest run --releaseon texel, compose, formats, render and engine (529 passed). Also clippy on the workspace with-D warnings, fmt,cargo xtask layersandcargo xtask wasm. I haven't re-runcargo +1.96.0 xtask cisince the port.Behaviour change
Documents whose resolution is below their bake resolution now composite, display and export generator masks, baked AO and baked normals from the averaged map instead of the nearest texel. Thin features keep their proportional weight instead of appearing or vanishing depending on where the grid falls. Documents at or above their bake resolution are unchanged.
Not changed
sizeoverride: the existingresizestep (box filter for integer factors, bilinear otherwise) is untouched.