diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-12 10:56:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | f2b02c455f2bcdfb905a015eefbb630a28b4b12e (patch) | |
| tree | c344c7ad42ec288dd5e1ebd0eb6d25f5aa2fbccc /addons/snake_shader/snake.post.frag | |
| parent | fc38c73c59f7855a4caad8aa4d3bb8e023309c13 (diff) | |
| download | pardes-f2b02c455f2bcdfb905a015eefbb630a28b4b12e.tar.gz pardes-f2b02c455f2bcdfb905a015eefbb630a28b4b12e.zip | |
addons: an addon can hand the frontend a GPU scene (ABI 3.1), and a snake drawn by shaders does; a commit's patch keeps its own +Diff pane; a real ZLS checked through the window build
ABI 3.1 appends an optional `gpu` callback and its context to pa_paint: one self-contained sketchbook SGPU v1 scene for the pane, at most 4 MiB, copied during the call, the last successful call winning. The SDL frontend runs it on its own GPU through sketchbook's executor and composites its target texture into the pane; replicas carry the scene beside the authoritative pane frame; cells and rasters stay the fallback for terminals, older hosts and frontends without an executor. addons/snake_shader is such an addon (`zig build snake-shader`, the SnakeShader word: a board that follows its pane, buffered turns, a CRT look), with test/gpu_snake.py, test/gpu_snake_interaction.py and test/gpu_upgrade.py.
Commit patches open as `+Diff-<short-hash>` and reuse only their own commit's pane, so another paged patch no longer replaces one already open.
The language-server client looks in the standard per-user bin directory, which desktop launchers often leave out of PATH, and takes an empty answer that beats the startup progress notification onto the wire; test/real_zls.py checks imports, hover, references, rename previews, diagnostics and completion against a real ZLS from a private home.
The dump's schema reader skips two fields older builds persisted, and a replica's shadow of a kind ticks when the authority's does. The reference, the guide, the building and setup notes and the changelog say so.
The working copy as it stood on 2026-11-12; message written by Claude from the diff, at the author's request.
Diffstat (limited to 'addons/snake_shader/snake.post.frag')
| -rw-r--r-- | addons/snake_shader/snake.post.frag | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/addons/snake_shader/snake.post.frag b/addons/snake_shader/snake.post.frag new file mode 100644 index 00000000..226e98de --- /dev/null +++ b/addons/snake_shader/snake.post.frag @@ -0,0 +1,34 @@ +#version 450 +layout(location = 0) in vec2 uv; +layout(location = 0) out vec4 color; +layout(set = 2, binding = 0) uniform sampler2D board; +layout(std140, set = 3, binding = 0) uniform Clock { vec4 phase; } clock; + +vec3 bright(vec2 at) { + vec3 rgb = texture(board, at).rgb; + return rgb * smoothstep(.16, .65, max(rgb.r, max(rgb.g, rgb.b))); +} +vec3 mapColor(vec3 rgb) { + // Soft highlights with a cool shadow tint; retain the dark board floor. + rgb *= vec3(.98, 1.02, 1.06); + return clamp((rgb * (2.51 * rgb + .03)) / (rgb * (2.43 * rgb + .59) + .14), 0, 1); +} +void main() { + vec2 size = vec2(textureSize(board, 0)); + vec2 pixel = uv * size; + vec2 pitch = vec2(3, 4); + vec2 sampleUV = (floor(pixel / pitch) + .5) * pitch / size; + vec4 source = texture(board, sampleUV); + vec3 bloom = vec3(0); + vec2 stepUV = vec2(4) / size; + for (int y = -1; y <= 1; y++) for (int x = -1; x <= 1; x++) { + float weight = float((x == 0 ? 2 : 1) * (y == 0 ? 2 : 1)); + bloom += bright(sampleUV + vec2(x, y) * stepUV) * weight / 16; + } + vec3 rgb = mapColor(source.rgb + bloom * .24); + vec3 mask = vec3(.65); + mask[int(mod(floor(pixel.x), 3))] = 1.45; + float scanline = mix(.5, 1, smoothstep(.15, .35, fract(pixel.y / 4))); + float shimmer = 1 + .006 * sin(clock.phase.x * 18.849556 + pixel.y * .12); + color = vec4(rgb * mask * scanline * shimmer, source.a); +} |
