Render a film stock on the GPU, and let it take over the rendering
The stock model landed in dr-film with no way to see it. This is the pipeline node, the two texture bindings it reads, and the end-to-end test that proves the shader agrees with the model. The design point is that a film simulation is not an adjustment. Every other node changes a picture; this one makes it. A stock's characteristic curve does the camera profile's base curve's job -- from measurements rather than from a curve somebody drew -- so running both renders the scene twice: the camera's rendering, and then a film's rendering of that. It looks like neither, and it reads as a colour-management bug with no colour-management bug to find. So `Operation::renders` is new. A node declaring it takes camera RGB and hands back linear sRGB, and the composer emits neither the base curve nor the conversion out of camera space. Both halves move together, and the composer keeps them as one string precisely so that getting half of it right is impossible. The tables are not parameters, for the reason vignetting's coefficients are not: they are measurements. dr-pipeline declares the layout as a plain struct and keeps its no-dependency property; the two crates share no types on purpose. `EditGraph::set_film_tables` offers them to every node rather than to the one that wants them, because knowing which concrete type is which is what the graph is organised not to know. Bindings 4 and 5 follow the masks precedent: declared unconditionally so one bind group layout serves every generated shader, bound to 1x1 placeholders when no stock is loaded. Both are interpolated by hand with textureLoad -- this pipeline binds no sampler, and adding one for two lookups would cost a binding in every shader. Uploads are keyed on content so an unchanged stock does not push half a megabyte across the bus per frame. The end-to-end test earned its place immediately: it found the density lookup being filled z-fastest while a 3D texture upload wants x-fastest, so the red and blue axes were transposed. Green matched exactly, which is what that bug looks like -- a plausible photograph of the wrong colour, and one that every unit test on either side of the seam passes. dr-film now pins the layout in a test that needs no device, and states it where the field is declared. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -212,11 +212,32 @@ half in Rust would be worse than either alone.
|
||||
Currently hand-written: `tone_curve` (one widget over four curves of five
|
||||
interpolated points — master, red, green, blue — each reaching the shader only
|
||||
when it has been moved), `colour_mixer` (thirty-six faceted parameters from
|
||||
twelve computed hue bands), `capture_sharpen` (a separable convolution) and
|
||||
`noise_reduction` (a kernel, and one that decides how many dispatches to emit
|
||||
at each resolution) — the last two for the reason the next section gives.
|
||||
`vignetting` is hand-written too but is not in the develop chain — it
|
||||
carries lens-profile coefficients that are not parameters. `distortion` and
|
||||
twelve computed hue bands), `film_sim` (a stock's measured tables, which are
|
||||
not parameters, and the one node that declares `Operation::renders` — see
|
||||
below), `capture_sharpen` (a separable convolution) and `noise_reduction` (a
|
||||
kernel, and one that decides how many dispatches to emit at each resolution) —
|
||||
the last two for the reason the next section gives. `vignetting` is
|
||||
hand-written too but is not in the develop chain — it carries lens-profile
|
||||
coefficients that are not parameters.
|
||||
|
||||
## The node that renders
|
||||
|
||||
`film_sim` is the only operation that returns `true` from
|
||||
`Operation::renders`, and it is worth knowing why before writing a second one.
|
||||
|
||||
Every other node *adjusts* a picture. That one *makes* it: a film stock's
|
||||
characteristic curve does the camera profile's base curve's job, from
|
||||
measurements rather than from a curve somebody drew. Running both renders the
|
||||
scene twice — the camera's rendering, and then a film's rendering of *that* —
|
||||
which looks like neither and reads as a colour-management bug with no
|
||||
colour-management bug to find.
|
||||
|
||||
So a node declaring `renders` takes camera RGB and hands back linear sRGB, and
|
||||
in exchange the composer emits neither the base curve nor the conversion out of
|
||||
camera space. Both halves move to the node, together: the base curve is defined
|
||||
in camera RGB and the matrix is what leaves it, so a node replacing one has
|
||||
necessarily replaced the other. `compose_full` keeps them as a single string
|
||||
for exactly that reason — it is what makes getting half of it right impossible. `distortion` and
|
||||
`aberration` are `Warp`s rather than operations: they rewrite coordinates
|
||||
before sampling rather than transforming a colour after it.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user