Shaders: alpha input on Output, Texture alpha node, fade recipe (#70)

root committed 2026-09-13 11:52:01 +02:00
1 parent 56dee13f8a
commit 7eac624fb1
2 files changed
+12 -4

No files matched your search

+2 -2
@@ -12,7 +12,7 @@ npm run check # typecheck + lint + format:check + tests, the gate CI runs
# code is lost (tail's is reported), so a red run reads as green # code is lost (tail's is reported), so a red run reads as green
npm run build # writes dist/ and regenerates index.html npm run build # writes dist/ and regenerates index.html
./build.sh # the same under `set -o pipefail`, for callers that pipe the output ./build.sh # the same under `set -o pipefail`, for callers that pipe the output
node tools/seed-e2e.mjs && node tools/e2e.mjs # 699 editor checks, screenshots in /tmp/gm-e2e-*.png node tools/seed-e2e.mjs && node tools/e2e.mjs # 703 editor checks, screenshots in /tmp/gm-e2e-*.png
GM_STEPS=20 node tools/e2e.mjs # or 1-12, or 6,20 — a subset while working on one step GM_STEPS=20 node tools/e2e.mjs # or 1-12, or 6,20 — a subset while working on one step
./e2e.sh start [GM_STEPS] # the same run detached, see below ./e2e.sh start [GM_STEPS] # the same run detached, see below
./e2e.sh status # live progress, or the last run's result ./e2e.sh status # live progress, or the last run's result
@@ -150,4 +150,4 @@ widths to find click points. The **render device is not in this repo** — `/dev
and a 1 GB `/dev/shm` come from `container.options` in the runner's own `config.yaml`, which and a 1 GB `/dev/shm` come from `container.options` in the runner's own `config.yaml`, which
applies to every job on that runner. Without them chromium falls back to llvmpipe, which gets applies to every job on that runner. Without them chromium falls back to llvmpipe, which gets
WebGL 1.0 only. Measured in the job container: `ANGLE (Intel, Vulkan 1.3.230, HD Graphics 630)`, WebGL 1.0 only. Measured in the job container: `ANGLE (Intel, Vulkan 1.3.230, HD Graphics 630)`,
WebGL 2.0, and the same 699 checks as here. WebGL 2.0, and the same 703 checks as here.
+10 -2
@@ -24,14 +24,22 @@ fed to a colour port is broadcast to all three channels. A colour cannot be fed
| Node | Ports | What it does | | Node | Ports | What it does |
|---|---|---| |---|---|---|
| **Texture color** | out `color` | The sprite's own pixel before the shader: its texture tinted by its colour, straight (unpremultiplied). | | **Texture color** | out `color` | The sprite's own pixel before the shader: its texture tinted by its colour, straight (unpremultiplied). |
| **Output** | in `color` | The colour the sprite is drawn with, clamped to 0-1. Its alpha stays the texture's. Left unconnected, the pixel passes through. One per graph. | | **Texture alpha** | out `value` | The opacity of the sprite's own pixel: 0 transparent, 1 opaque. |
| **Output** | in `color`, `alpha` (number) | What the sprite is drawn with: the colour, clamped to 0-1, and the opacity, clamped too. Each input left unconnected stays the texture's. One per graph. |
| **Property** | out `value` | Declares a number the sprite sets: `Name` is the row below the sprite's Shader dropdown and the uniform in the fragment; `Default`, `Min`, `Max` are the row's range. A name is one word (letters, digits, `_`), unique in the graph. | | **Property** | out `value` | Declares a number the sprite sets: `Name` is the row below the sprite's Shader dropdown and the uniform in the fragment; `Default`, `Min`, `Max` are the row's range. A name is one word (letters, digits, `_`), unique in the graph. |
| **Color** | out `color` | A constant colour, picked in the inspector. | | **Color** | out `color` | A constant colour, picked in the inspector. |
| **Add**, **Subtract**, **Multiply**, **Divide** | in `a`, `b` (any) · out `result` | Arithmetic, per channel for colours. An unconnected input is the number typed on the node (0, or 1 for the second input of Multiply and Divide). | | **Add**, **Subtract**, **Multiply**, **Divide** | in `a`, `b` (any) · out `result` | Arithmetic, per channel for colours. An unconnected input is the number typed on the node (0, or 1 for the second input of Multiply and Divide). |
| **Mix** | in `a`, `b` (any), `t` (number) · out `result` | Blends from `a` to `b`: `t` = 0 is `a`, 1 is `b`, beyond that it extrapolates. | | **Mix** | in `a`, `b` (any), `t` (number) · out `result` | Blends from `a` to `b`: `t` = 0 is `a`, 1 is `b`, beyond that it extrapolates. |
| **Luminance** | in `color` · out `value` | How bright a colour is (Rec. 709 weights), as one number. | | **Luminance** | in `color` · out `value` | How bright a colour is (Rec. 709 weights), as one number. |
A colour input with no field (Output, Luminance) that is left unconnected reads the texel's colour. An input with nothing to type on it (the Output's two, Luminance's colour) that is left unconnected
reads the texel: its colour for a colour port, its alpha for the Output's `alpha`. That is why the
Output's `alpha` has no inline number: a typed-in value would replace the texture's transparency.
The colour has no alpha of its own — a `Color` node and the sprite's colour are RGB. To fade a
sprite: Property *opacity* (default 1, 0 to 1) and `Texture alpha` into a `Multiply`, its result into
the Output's `alpha`; the sprite then blends with whatever is behind it, and a behavior can write
`opacity` every frame.
## Adjust colors ## Adjust colors