What the painters were given

Stream 4: form and light for solids

notes/form.md · 125 lines · Notes

Given to 9 painters:

Stream 4: form and light for solids

Branch form. This stream answers fresh-painter findings 5 and 10: rocks read as "macarons, loaves, haystacks, beetles and soap bars", mountains as "weird sea with hard edges", and painters had to build their own height fields and shading. The engine now gives a painting program a solid to reason about. Each point of it has planes turned toward or away from one light, a core shadow, reflected light, cast shadows and a distance for aerial perspective. It also gives stroke-direction fields and masks derived from that solid. The engine still paints nothing: the rock and range motifs live in paintings/src/rocks.rs as one painter's example.

What changed

API, briefly

use paint::{Form, Light, Ridge, Sdf};
use paint::form::aerial;

let mut form = Form::new(c.frame());
// a boulder: a mass, turned, weathered, then broken by fracture planes
let rock = Sdf::ellipsoid(c3, [150.0, 110.0, 120.0])
    .turn(c3, 0.3, 0.1, -0.12)
    .rough(17.0, 150.0, 1, false)               // soft lumps
    .cut(top_pt, [-0.35, -1.0, 0.45], 10, 4.0)   // a sloping top: facet 10
    .cut(side_pt, [1.0, -0.15, 0.3], 11, 3.0)    // the flank away from the light
    .rough(0.9, 25.0, 2, true);                  // pitted grain
let id = form.add(&rock, 0.5);                   // dist 0.5 (aerial perspective)
let range = Ridge::new(0.0, 1000.0, |x| crest(x), 400.0, 7)
    .lean(0.9, 0.7).gullies(45.0, 0.5).base(valley_y);
let far = form.add_at(&range, &|_, _, z| 3.0 - 0.002 * z);
form.light(Light::new((-1.0, -0.7), 0.5).ambient(0.2).penumbra(0.05));

// then paint with fields from the form
let lit = form.mask(|s| if s.part == id { s.shade.lit(0.12) } else { 0.0 });
let edge = form.silhouette(&[id], |s| 0.4 + 5.0 * aerial(s.dist, 6.0).powi(2));
let hd = st.body()
    .color(|x, y| form.sample(x, y).map_or(sky(x, y), |s| stone.at(&s.shade)))
    .angle(|x, y| form.fall(x, y))
    .clip(true);
c.work(&lit.mul(&edge), &hd, 1);
let joints = form.edges(0.8, 3.0, 2.5).mul(&Mask::from_fn(f, |x, y| smoothstep(0.3, 0.7, -form.bend(x, y, 2.5))));

Evidence

What I saw, judged as a painter:

Known issues and next steps

Commits

Source