Repository navigation
A cutout's map answers an emitter's shadow ray - #304
Merged
Merged
Conversation
To an emitter's shadow ray every alpha-cutout was opaque (`A_CUTOUT_EMITTERS`): the leaves of a tree blocked as whole cards. Testing their alpha instead costs a read of each triangle's corners, material and texture, and, on the hardware path, a new query past every hole. A cutout's triangles now have maps (cutout.rs): a lattice of cells about two texels wide, each solid, a hole, or a part of both with its larger part, made once from the base texture's alpha where the scene is prepared; triangles with the same texture coordinates and material share one. They are a stream of the words' heap, and an instance's row says where its section's begin. - Hardware traversal: the sections that have maps are not flagged opaque. Every other ray forces opacity as before; an emitter's shadow ray at a camera hit does not, is handed each such triangle in its one query, and confirms it or passes it by the map. - Software traversal asks the map where it tested the alpha. - A material or texture edited in place drops its rows' maps (the cutout is then opaque to these rays, as before); an instance placed at run time takes its mesh's. Offline rendering tests the alpha as ever. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To an emitter's shadow ray every alpha-cutout was opaque (
A_CUTOUT_EMITTERS): the leaves of a tree blocked as whole cards. A cutout's triangles now have maps, and those rays ask them, in the one query they are.Why
Measured against offline renders of the same pose (all figures: Apple M4, half resolution): beside the potted bushes and the hedge of Bistro's walk the picture had 0.78 and 0.71 of the offline light, moving or held. With their alpha tested instead: 0.97 and 0.99, for 18 % more of the frame at the street's first view and 24 % over the walk.
Where that cost lies: Bistro has 285,355 cutout triangles (a tenth of the scene; 3,195 with texture coordinates of their own), 2,200 texels across in the median and three fifths hole. A shadow ray through a crown crosses dozens of cards through their holes, and on the hardware path each hole was a new query from where the last ended. With maps in place of the alpha's reads but the stepping kept, the frame cost what the test costs (18.3 and 20.8 ms for 18.2 and 20.6); one query with the alpha tested in its candidate loop had saved nothing earlier (docs/RUNTIME.md). Both had to go: the reads and the queries.
What
renderer/src/cutout.rs). A cutout's triangle is laid over with a lattice of cells about two texels of its base texture wide (4^7 at most), a cell's state two bits: nothing there, all there, or a part with which is the larger. Made where the scene is prepared, in parallel; triangles with the same texture coordinates and material share one. A stream of the words' heap; an instance's row says where its section's begin.Results
What it costs
bench-object-ghostingandbench-ghosting --quick --checkas they were.The candidate loop on Metal
trace_hw.wgsl records that the ray query's candidate loop lost hits on Metal when every ray's cutouts went through it with their alpha tested (0.1 % of rays near foliage, differently from run to run). In this form (these rays only, the sections with maps only): two offline renders of Bistro's walk pose, 64 samples, every emitter ray by the maps, differ in 2 of 921,600 pixels (with the alpha tested and stepped: 32), and from the same rays stepped in order in 0.19 % of the pixels, their mean within 1e-5.
Validation
shadow/cutout-emitter-live,shadow/cutout-emitter-side,shadow/cutout-emitter-side-live; on main the two live ones read black). The cutout tests pass under software traversal too.npm run typecheck;npm test324 pass, 1 skipped.Not done
A_CUTOUT_PATHS); the analytic lights' and the sky's shadow rays at a camera hit still test the alpha and step. Both could go by the maps.🤖 Generated with Claude Code