diff options
| author | user <user@clank> | 2026-08-15 00:02:51 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-15 00:02:51 +0200 |
| commit | 599da705d93f27efb2a4c62b0747356d97e8f9b3 (patch) | |
| tree | 34dca7208797dba5088c52abdf328095b33fde90 /src | |
| parent | contrib: draw the shadertoy preview at the size it means (diff) | |
| download | slosh-599da705d93f27efb2a4c62b0747356d97e8f9b3.tar.gz slosh-599da705d93f27efb2a4c62b0747356d97e8f9b3.tar.xz slosh-599da705d93f27efb2a4c62b0747356d97e8f9b3.zip | |
contrib: presets worth stealing, and a test that they do anything
Eleven examples, grouped, and most of them are less "effect" than
*instrument*: a cursor line, a crosshair, indent guides, a right margin at
three quarters, a torch that dims everything more than eight cells from where
you are looking. Things that tell you where you are, inside a program that
has never heard of any of them -- which is the argument for shading contents
rather than chrome, made in examples instead of prose.
Then the fun: phosphor and amber CRTs (grayscale, tint, scanlines, vignette
as a four-pass chain), film grain, a rolling bar, an interlace flicker; sonar
pings expanding from the cursor, ripples, a barber pole, plasma from two
triangle waves, matrix rain with a fading tail; and every built-in written as
an expression, because `vignette` being `dim` with an argument is the whole
design and is better shown than argued.
Two rules the presets follow, both about staying identical to the C: never
multiply `t` (it is a millisecond clock and gets large -- divide it down
first and the arithmetic stays in an int32 forever), and keep hash
coefficients small for the same reason. `(x * 11) % 23` is fine; the usual
Knuth constant is a different number in C than in JavaScript.
The test now lifts the *presets* out of the page as well as the evaluator, so
one added later is conformance-checked without anyone remembering to add it.
And it evaluates every preset over a whole pane at four points in time and
fails any that is zero everywhere -- an example that does nothing reads as a
broken shader system rather than a bad example.
That check caught its own first draft: sampling every other row made three
`y % 2` effects look dead when they were fine. It samples every cell now,
which costs six hundredths of a second for four hundred thousand
evaluations, because the thing being tested is quick.
Diffstat (limited to 'src')
0 files changed, 0 insertions, 0 deletions
