onejs-sl 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ Real control flow: an `if` runs only the side it picks, a loop that cannot unroll runs as a loop, and `int`, `uint` and `bool` are types. A program with an `if` statement gets a new hash, which a build regenerates; every other program keeps its hash and its shader.
6
+
7
+ - `if` is a real branch, and `return` works anywhere
8
+ - `while`, `break`, `continue` and `switch`; a case never falls through
9
+ - A `for` unrolls when its turns are known, 64 or fewer, and nothing leaves early; any other loop is real, with a turn limit
10
+ - `int`, `uint` and `bool`; two ints divide toward zero; bit operators and `5u` literals
11
+ - Braces on their own are a block with its own scope
12
+ - A local declared without a value holds zero
13
+ - `sl.branch` and `sl.loop` record control flow from code
14
+ - IR 4: `if`, `loop`, `param` and `proj` nodes and int, uint and bool values; a program without them stays IR 3
15
+ - `fromGLSL` keeps `int`, `uint` and `bool`
16
+
3
17
  ## 0.4.0
4
18
 
5
19
  Every hash changes once, so a program built in code is recorded again: run the app in the editor once, then build. A program from a `.sl` file needs only the app rebuilt. A host reading programs as JSON reads 0.3.0's files as before.
package/README.md CHANGED
@@ -341,27 +341,44 @@ IR 2 came with #129. A shape takes as many parameters as it reads
341
341
  used to take four and lose the rest. IR 3 added `SAMPLE_LOD`, and made an
342
342
  SDF's shape parameters and a noise's octave count operands, where they were
343
343
  immediates, so they can be any value; a constant one still prints as its
344
- number. `fromJSON` moves an older file's immediates to operands.
344
+ number. `fromJSON` moves an older file's immediates to operands. IR 4 added
345
+ control flow (the `if` and `loop` nodes, a loop's `param`s and each result's
346
+ `proj`) and int, uint and bool values (a node's `kind`). A program that uses
347
+ none of them is still IR 3 and keeps its hash; one with an `if` statement is
348
+ IR 4, since the statement is now a real branch rather than a select.
345
349
 
346
350
  ## Control flow
347
351
 
348
- There is none in the IR, deliberately. `sl.select`, `sl.step`, `sl.smoothstep` and
349
- `sl.mix` cover branching without branching, and `sl.repeat(n, body, seed)`
350
- unrolls at record time because `n` is a JavaScript number.
351
-
352
- `repeat` is honest about being a macro rather than a loop. It covers fbm,
353
- layered noise and small iterated distance fields, which is most of what 2D
354
- shaders loop for. A loop with a runtime count is `Specs/SL_NEXT.md` proposal
355
- 3b. Because it unrolls, the count multiplies the body's operation count.
356
- `compile` has no ceiling, so a long program costs what it costs, as any shader
357
- does; `corpus/long.sl` is over a thousand operations.
358
-
359
- Every loop that reaches a GPU is therefore bounded by a constant: `repeat` is
360
- unrolled, fbm's octaves are held to 1 to 4 even when the count is a value, the
361
- helper loops in the noise and Voronoi functions have fixed trip counts. No program can hang a GPU today,
362
- so the compiled backends carry no loop cap. A data dependent loop (the
363
- raymarching tier) would need one emitted into every loop it prints, since a GPU
364
- reset takes the whole page's device, Unity's included.
352
+ IR 4 has it: an `if` node runs one of its two regions and gives back their
353
+ results, and a `loop` node carries its values through turns while its
354
+ condition holds. `sl.branch(cond, whenTrue, whenFalse)` and
355
+ `sl.loop(init, cond, body, max)` record them, and the text form lowers `if`,
356
+ `for`, `while`, `break`, `continue`, `switch` and a `return` anywhere onto the
357
+ two (`src/lang/lower.ts` says how: a return or break that only some ways
358
+ through reach is a flag, and what follows runs under a branch on it). No
359
+ emitter ever prints a statement that returns or breaks from inside a region;
360
+ every one prints the same structured body.
361
+
362
+ `structure.ts` decides where each node is computed: in the innermost region
363
+ every use of it is inside. A value only a branch needs is computed only when
364
+ the branch runs, one only a loop's body reads is computed each turn, and one
365
+ needed on both sides is computed once, before either. It also marks the
366
+ regions whose flow differs between neighbouring pixels, where a texture
367
+ sample has no neighbours to take its mip level from; every emitter samples
368
+ level 0 there, so every backend draws the same picture.
369
+
370
+ A `for` in the text form still unrolls when its turns are known, are 64 or
371
+ fewer, and nothing in it leaves early, and `sl.repeat(n, body, seed)` still
372
+ unrolls at record time because `n` is a JavaScript number. Everything else is
373
+ a real loop.
374
+
375
+ Every real loop has a turn limit, `max`, emitted into the loop itself: the
376
+ count a constant bound gives, the `[Range]` maximum of a uniform bound, or
377
+ 1024 when the bound says neither. A loop that reaches it leaves as if its
378
+ condition had failed. That is what keeps a data dependent loop, a ray march
379
+ say, from hanging a GPU, whose reset takes the whole page's device, Unity's
380
+ included. `Tools/sl-loop-timing` in the container times a loop that breaks
381
+ early against the same maths unrolled, on each backend.
365
382
 
366
383
  ## See also
367
384
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "generatedBy": "onejs-sl goldens/run.mjs",
3
- "package": "0.4.0",
4
- "ir": 3,
3
+ "package": "0.5.0",
4
+ "ir": 4,
5
5
  "target": "rgba8unorm-srgb: straight alpha, 8 bit, sRGB encoded, the stored bytes of a Linear OneJS game's element",
6
6
  "size": [
7
7
  64,
@@ -22,7 +22,7 @@
22
22
  "exact": "a fixture marked exact has to draw its samples to the byte, not within 1/255",
23
23
  "fixtures": {
24
24
  "branch.sl": {
25
- "hash": "e8f6cc47",
25
+ "hash": "f5ab226f",
26
26
  "source": "// A branch, a colour literal and a function that returns a vector.\nuniform float4 tint = #ff8040;\n\nfloat2 swirl(float2 p, float a) {\n float c = cos(a);\n float s = sin(a);\n return float2(p.x * c - p.y * s, p.x * s + p.y * c);\n}\n\nfloat4 main() {\n float2 q = swirl(uv - 0.5, time * 0.3);\n float v = 0.25;\n if (q.x > 0.1) { v = 0.75; } else { v = fbm(q * 3, 4); }\n return float4(tint.rgb * v, 1);\n}\n",
27
27
  "samples": {
28
28
  "0": [205,102,49,255,208,104,50,255,191,95,45,255,198,98,47,255,211,105,51,255,207,103,50,255,206,102,50,255,209,104,50,255,206,102,50,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,213,106,52,255,213,106,52,255,199,98,48,255,210,105,51,255,219,109,53,255,210,104,51,255,189,93,45,255,193,96,46,255,190,94,45,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,210,104,51,255,215,107,52,255,202,100,49,255,211,105,51,255,217,108,53,255,207,103,50,255,184,91,43,255,168,82,38,255,183,90,43,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,206,103,50,255,213,106,52,255,209,104,51,255,211,105,51,255,219,109,53,255,213,106,51,255,188,93,44,255,191,95,45,255,188,93,44,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,204,102,49,255,216,108,53,255,219,109,53,255,220,110,54,255,213,106,51,255,207,103,50,255,197,98,47,255,194,96,46,255,197,98,47,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,211,105,51,255,223,112,55,255,226,113,55,255,221,110,54,255,214,107,52,255,202,100,48,255,195,97,46,255,186,92,44,255,184,91,43,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,219,109,53,255,219,109,53,255,230,115,56,255,225,112,55,255,212,106,51,255,200,99,48,255,182,90,43,255,167,82,38,255,165,80,38,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,229,114,56,255,225,112,55,255,223,112,55,255,220,110,54,255,209,104,51,255,192,95,46,255,174,86,41,255,145,70,32,255,144,70,32,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,219,109,53,255,224,112,55,255,216,108,52,255,206,103,50,255,188,93,44,255,169,83,39,255,150,73,34,255,148,72,33,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,202,100,49,255,203,101,49,255,212,105,51,255,200,99,48,255,198,98,47,255,191,94,45,255,175,86,41,255,152,74,34,255,147,71,32,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,168,82,39,255,187,92,44,255,194,96,46,255,195,96,46,255,200,99,48,255,198,98,47,255,190,94,45,255,168,82,39,255,153,74,34,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,154,75,34,255,164,80,37,255,170,83,39,255,179,88,42,255,188,93,44,255,185,91,43,255,182,90,43,255,178,88,42,255,177,87,41,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,131,63,28,255,137,66,30,255,138,66,30,255,148,72,33,255,163,79,37,255,169,83,39,255,178,88,42,255,182,90,43,255,184,91,43,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,124,59,26,255,131,63,28,255,121,57,25,255,139,67,30,255,147,71,33,255,154,75,35,255,172,84,40,255,183,90,43,255,192,95,46,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,149,72,33,255,148,72,33,255,169,83,39,255,168,82,38,255,176,87,41,255,180,88,42,255,173,85,40,255,176,86,41,255,176,87,41,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,179,88,42,255,186,92,44,255,201,100,48,255,194,96,46,255,191,95,45,255,189,93,45,255,181,89,42,255,172,85,40,255,159,77,36,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255,225,112,55,255],
@@ -93,6 +93,14 @@
93
93
  "1.25": [98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255,98,74,46,255,108,81,51,255,121,92,58,255,138,105,67,255,161,123,80,255,187,143,93,255,214,165,108,255,223,171,113,255,230,177,117,255,237,182,120,255,242,187,123,255,246,190,125,255,248,191,126,255,248,191,126,255,248,191,126,255,248,191,126,255]
94
94
  }
95
95
  },
96
+ "early-return.sl": {
97
+ "hash": "36371b89",
98
+ "source": "// A circular window that computes its plasma only inside (Specs/SL_NEXT.md 3a):\n// the early return puts the rest of main on the other side of one real branch,\n// and the texture read after it is in flow that differs per pixel, so every\n// backend samples it at level 0.\ntexture2D t;\nfloat4 main() {\n float2 p = uv - 0.5;\n if (length(p) > 0.45) return float4(0, 0, 0, 0);\n float v = fbm(p * 5 + time * 0.2, 4);\n float4 c = tex2D(t, uv);\n return float4(lerp(c.rgb, float3(v, v * 0.6, 1 - v), 0.5), 1);\n}\n",
99
+ "samples": {
100
+ "0": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,148,108,175,255,162,117,156,255,171,121,154,255,179,123,162,255,183,121,162,255,168,97,175,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,134,105,182,255,128,98,172,255,139,103,172,255,165,122,170,255,176,127,159,255,171,118,152,255,170,110,165,255,167,98,191,255,169,90,193,255,176,86,181,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,149,122,169,255,156,126,162,255,151,120,158,255,161,125,155,255,166,126,164,255,171,126,162,255,174,123,154,255,164,108,173,255,172,107,183,255,170,96,190,255,175,90,185,255,193,101,179,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,142,121,157,255,160,133,146,255,156,128,171,255,167,133,160,255,166,129,146,255,151,112,171,255,164,118,181,255,163,110,184,255,167,107,172,255,182,114,169,255,184,106,191,255,199,114,181,255,0,0,0,0,0,0,0,0,0,0,0,0,123,114,183,255,144,127,159,255,156,134,153,255,162,137,161,255,167,137,157,255,170,137,146,255,163,128,162,255,171,129,171,255,173,125,173,255,169,115,174,255,182,119,172,255,195,124,176,255,198,118,180,255,203,112,176,255,0,0,0,0,0,0,0,0,145,135,157,255,150,137,172,255,160,142,161,255,172,149,128,255,169,144,142,255,162,136,173,255,161,131,175,255,165,130,159,255,177,134,157,255,175,126,184,255,186,129,177,255,197,132,156,255,189,114,180,255,200,116,193,255,0,0,0,0,0,0,0,0,164,153,141,255,164,152,154,255,170,155,147,255,170,153,137,255,171,151,143,255,159,140,172,255,139,122,189,255,147,122,180,255,169,134,170,255,182,139,172,255,194,143,165,255,199,140,158,255,193,126,179,255,194,116,197,255,0,0,0,0,0,0,0,0,164,159,153,255,162,157,136,255,164,157,141,255,166,157,161,255,161,151,166,255,154,144,159,255,141,131,179,255,142,128,197,255,165,139,182,255,181,145,157,255,188,144,163,255,195,144,179,255,197,138,183,255,199,130,177,255,0,0,0,0,0,0,0,0,150,158,164,255,131,147,170,255,128,144,176,255,149,154,173,255,155,155,168,255,160,155,158,255,152,147,173,255,147,140,191,255,159,143,185,255,164,140,179,255,174,142,180,255,179,138,192,255,190,140,189,255,205,144,174,255,0,0,0,0,0,0,0,0,127,155,172,255,111,147,197,255,107,144,197,255,119,147,178,255,133,152,176,255,146,155,186,255,155,157,180,255,166,160,158,255,171,160,164,255,170,153,189,255,178,154,185,255,196,161,158,255,199,157,169,255,208,157,185,255,0,0,0,0,0,0,0,0,0,0,0,0,98,152,199,255,105,153,196,255,110,154,187,255,128,159,182,255,139,161,187,255,158,168,175,255,165,169,163,255,171,168,167,255,174,166,181,255,183,166,178,255,196,170,162,255,203,168,167,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,171,171,255,139,177,166,255,155,183,172,255,151,179,175,255,156,179,157,255,152,175,170,255,147,169,194,255,164,174,183,255,172,174,167,255,182,175,169,255,194,178,181,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,155,193,155,255,150,190,172,255,150,188,172,255,152,187,165,255,143,180,180,255,154,182,186,255,156,179,188,255,166,181,177,255,173,180,181,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,151,198,162,255,147,195,185,255,138,188,192,255,146,189,176,255,149,187,185,255,156,186,199,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
101
+ "1.25": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,149,110,174,255,161,116,157,255,166,116,160,255,172,116,170,255,152,88,191,255,162,90,180,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,125,98,187,255,138,106,165,255,156,118,157,255,167,123,168,255,170,122,166,255,176,123,146,255,162,101,173,255,167,99,191,255,166,85,196,255,192,108,163,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,139,115,176,255,130,106,182,255,135,107,172,255,157,121,159,255,173,132,157,255,171,126,162,255,164,114,165,255,161,104,177,255,162,96,192,255,164,88,195,255,178,94,182,255,193,102,178,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,158,133,141,255,155,129,152,255,159,129,169,255,167,133,160,255,160,124,153,255,166,125,157,255,158,112,186,255,166,114,181,255,166,106,172,255,166,96,184,255,183,105,192,255,190,101,191,255,0,0,0,0,0,0,0,0,0,0,0,0,134,121,177,255,153,133,152,255,157,135,152,255,163,137,160,255,165,136,159,255,146,118,170,255,158,123,168,255,155,115,185,255,156,109,188,255,172,117,171,255,180,117,174,255,189,118,182,255,202,123,175,255,200,108,180,255,0,0,0,0,0,0,0,0,146,135,157,255,151,137,171,255,162,143,159,255,166,144,137,255,166,142,146,255,157,132,177,255,165,135,170,255,170,134,154,255,164,123,171,255,172,123,187,255,187,130,175,255,187,122,169,255,191,116,178,255,200,115,194,255,0,0,0,0,0,0,0,0,152,145,154,255,156,147,162,255,169,154,148,255,169,152,139,255,160,144,156,255,154,137,175,255,154,133,178,255,167,138,162,255,170,135,168,255,176,134,179,255,193,142,167,255,185,127,175,255,192,125,179,255,197,119,194,255,0,0,0,0,0,0,0,0,163,158,154,255,170,162,125,255,169,160,135,255,167,157,161,255,156,148,170,255,140,135,171,255,133,127,184,255,159,139,185,255,179,149,169,255,184,148,153,255,194,150,154,255,190,139,186,255,180,120,201,255,193,123,184,255,0,0,0,0,0,0,0,0,159,163,155,255,157,161,148,255,157,160,152,255,155,158,167,255,155,155,168,255,138,143,176,255,133,135,187,255,151,142,188,255,172,152,173,255,174,148,169,255,185,151,168,255,188,146,184,255,191,141,188,255,202,142,177,255,0,0,0,0,0,0,0,0,129,156,170,255,119,150,193,255,137,157,180,255,146,160,158,255,155,163,158,255,151,159,182,255,144,151,188,255,151,151,172,255,158,151,177,255,167,151,191,255,175,151,188,255,183,151,173,255,197,155,171,255,211,159,182,255,0,0,0,0,0,0,0,0,0,0,0,0,95,151,201,255,105,153,196,255,118,156,183,255,135,162,177,255,147,165,181,255,158,168,174,255,169,171,159,255,169,167,169,255,171,164,184,255,186,168,175,255,192,167,167,255,199,165,172,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,105,165,182,255,116,167,182,255,127,170,192,255,139,174,183,255,146,174,166,255,155,176,168,255,165,178,180,255,163,173,184,255,173,174,166,255,189,179,161,255,195,178,180,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,193,156,255,152,191,170,255,151,189,172,255,147,185,170,255,140,179,182,255,156,184,183,255,162,182,183,255,172,184,171,255,184,186,170,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,146,196,166,255,139,192,190,255,140,189,190,255,145,189,177,255,154,189,180,255,162,189,195,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
102
+ }
103
+ },
96
104
  "ember.sl": {
97
105
  "hash": "9a55af34",
98
106
  "source": "// A fire, in one file: one texture, one loop, one function.\n//\n// Everything a Unity shader makes you write that is not the effect is absent.\n// No Properties block, no SubShader, no CGPROGRAM, no appdata or v2f, no\n// _Time.y. `uniform` declares the slot AND the name React binds against, and\n// `texture2D` does the same for a sampler.\n//\n// This program sits at exactly 8 of the VM's 8 registers, which is why it is\n// in the corpus: the VM refused a ninth live value. Compiled, there is no such\n// ceiling, and the same file draws the same in the editor, a player and a\n// browser, with no edit in between.\ntexture2D smoke;\n\nuniform float heat = 0.55;\nuniform float2 source = float2(0.5, 0.08);\n\n// Layered noise: one texture, three scales, drifting.\n//\n// The loop UNROLLS at build time. `i` is a number the parser substitutes, so\n// both backends see straight line code and neither needs a branch, which is\n// also why the bound has to be a constant. The function inlines, so calling it\n// costs exactly what writing the three lines out would.\nfloat plume(float2 p, float t) {\n float s = 0;\n for (int i = 0; i < 3; i++) {\n s = s + tex2D(smoke, p * (1 + i * 1.9) - t).r * (0.6 / (1 + i));\n }\n return s;\n}\n\nfloat4 main() {\n float2 p = uv - source;\n // A cone: narrow across, tall up, brightest at the source.\n float cone = saturate(1 - length(p * float2(3, 1.1)));\n float fuel = saturate(cone * (0.5 + heat) * (plume(p, time * 0.4) + 0.35));\n\n // Colours as written. They are mixed in sRGB and converted once, so the\n // ramp reads as evenly as its swatches do.\n return ramp(fuel, #00000000, #b53205cc, #ff8a20, #ffe7b0);\n}\n",
@@ -127,6 +135,15 @@
127
135
  "1.25": [0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,86,255,173,171,86,255,139,212,86,255,0,244,86,255,0,110,86,255,207,171,86,255,24,212,86,255,0,244,86,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,253,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,237,255,0,171,237,255,0,212,237,255,193,244,237,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,202,255,0,171,202,255,0,212,202,255,173,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,158,255,0,171,158,255,0,212,158,255,139,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,253,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,188,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,207,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,202,255,0,171,202,255,0,212,202,255,207,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,226,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,158,255,0,171,158,255,0,212,158,255,24,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,193,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,237,255,0,171,237,255,253,212,237,255,188,244,237,255,207,110,237,255,226,171,237,255,0,212,237,255,0,244,237,255,0,110,237,255,0,171,237,255,0,212,237,255,0,244,237,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,202,255,0,171,202,255,0,212,202,255,0,244,202,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,158,255,0,171,158,255,0,212,158,255,0,244,158,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255,0,110,86,255,0,171,86,255,0,212,86,255,0,244,86,255]
128
136
  }
129
137
  },
138
+ "int-ops.sl": {
139
+ "hash": "f15eab80",
140
+ "exact": true,
141
+ "source": "// Integer arithmetic and bits, per cell, drawn as 0 or 1 per channel so two\n// backends can only agree by computing the same whole numbers: truncating\n// division and remainder of negatives, zero divisors, conversions past the\n// int's range, wrapping, shifts past 31, and a uint hash.\nfloat4 main() {\n int cell = int(floor(uv.x * 8)) + 8 * int(floor(uv.y * 8));\n int a = cell - 32;\n int b = (cell % 5) - 2;\n uint h = uint(cell) * 747796405u + 2891336453u;\n h = ((h >> ((h >> 28u) + 4u)) ^ h) * 277803737u;\n h ^= h >> 22u;\n int big = int(float(cell) * 1e9) + 2147483647;\n bool odd = (a & 1) != 0;\n bool neg = a / 3 < 0 || a % 3 < 0;\n bool mid = a >= -8 && a <= 8;\n float r = ((b == 0 ? a / 1 : a / b) | (mid ? 1 : 0)) % 2 != 0 ? 1 : 0;\n float g = ((h & 0xffu) > 127u) != odd ? 1 : 0;\n float bl = float(((big >> 31) & 1) ^ int(neg) ^ ((~cell & ((1 << (cell + 30)) >> 1)) != 0 ? 1 : 0));\n return float4(r, g, bl, 1);\n}\n",
142
+ "samples": {
143
+ "0": [0,255,0,255,0,255,0,255,255,0,0,255,255,0,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,0,0,255,255,0,0,255,0,255,0,255,0,255,0,255,255,0,0,255,255,0,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,0,0,255,255,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,0,255,255,0,0,255,255,0,255,255,255,0,255,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,0,255,255,0,0,255,255,0,255,255,255,0,255,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,0,255,0,255,0,255,255,255,255,255,255,255,255,255,0,255,0,255,0,255,0,255,255,0,0,255,255,0,0,255,0,0,255,255,0,0,255,255,255,255,0,255,255,255,0,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,0,255,0,255,0,255,255,255,255,255,255,255,255,255,0,255,0,255,0,255,0,255,255,0,0,255,255,0,0,255,0,0,255,255,0,0,255,255,255,255,0,255,255,255,0,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255],
144
+ "1.25": [0,255,0,255,0,255,0,255,255,0,0,255,255,0,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,0,0,255,255,0,0,255,0,255,0,255,0,255,0,255,255,0,0,255,255,0,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,0,0,255,255,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,255,0,255,0,255,0,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,0,255,255,0,0,255,255,0,255,255,255,0,255,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,0,255,255,0,0,255,255,0,255,255,255,0,255,255,255,255,0,255,255,255,0,255,255,0,0,255,255,0,0,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,0,255,0,255,0,255,255,255,255,255,255,255,255,255,0,255,0,255,0,255,0,255,255,0,0,255,255,0,0,255,0,0,255,255,0,0,255,255,255,255,0,255,255,255,0,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,0,255,0,255,0,255,255,255,255,255,255,255,255,255,0,255,0,255,0,255,0,255,255,0,0,255,255,0,0,255,0,0,255,255,0,0,255,255,255,255,0,255,255,255,0,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255]
145
+ }
146
+ },
130
147
  "lod.sl": {
131
148
  "hash": "ac177cc0",
132
149
  "source": "// An anchor for tex2Dlod: four bands, left to right, each reading one mip level\n// of the goldens' texture. Level 0 is the image and levels 1 to 3 are each one\n// solid colour, so a band that read the wrong level shows it.\ntexture2D t;\nfloat4 main() { return tex2Dlod(t, uv, floor(uv.x * 4)); }\n",
@@ -143,6 +160,30 @@
143
160
  "1.25": [0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,18,0,12,255,109,37,94,255,119,74,117,255,94,95,115,255,47,79,82,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,151,20,122,255,127,35,106,255,116,48,103,255,93,63,93,255,73,86,96,255,67,92,97,255,43,125,112,255,15,121,101,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,139,58,123,255,118,45,103,255,99,41,88,255,111,48,99,255,96,74,101,255,74,82,91,255,71,93,96,255,49,94,84,255,51,115,97,255,65,150,120,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,109,92,122,255,101,71,103,255,85,51,83,255,115,50,103,255,142,48,121,255,153,86,145,255,106,129,143,255,68,127,117,255,64,109,95,255,72,113,95,255,82,125,102,255,76,109,87,255,0,0,0,255,0,0,0,255,0,0,0,255,5,10,12,255,82,94,106,255,74,76,88,255,95,79,103,255,163,74,146,255,3,0,2,255,0,0,0,255,0,0,0,255,3,61,50,255,90,164,134,255,88,123,104,255,90,117,100,255,123,141,119,255,0,0,0,255,0,0,0,255,0,0,0,255,29,101,94,255,64,103,103,255,77,92,99,255,88,113,121,255,2,1,2,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,77,100,81,255,113,123,109,255,91,103,90,255,117,112,104,255,33,29,26,255,0,0,0,255,0,0,0,255,21,138,117,255,57,103,93,255,63,114,101,255,55,163,145,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,145,147,122,255,118,125,101,255,108,111,91,255,86,66,68,255,0,0,0,255,0,0,0,255,42,142,115,255,61,116,96,255,67,107,91,255,83,175,143,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,143,132,120,255,97,96,85,255,123,115,102,255,79,72,61,255,0,0,0,255,0,0,0,255,48,104,82,255,68,118,97,255,74,115,96,255,107,139,117,255,54,60,50,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,116,128,116,255,111,118,106,255,115,103,104,255,123,118,106,255,13,13,9,255,0,0,0,255,0,0,0,255,0,0,0,255,104,137,112,255,81,98,84,255,99,103,95,255,157,138,134,255,101,64,81,255,0,0,0,255,0,0,0,255,39,80,116,255,89,107,116,255,92,101,94,255,88,98,90,255,141,149,127,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,108,120,101,255,105,108,97,255,105,94,95,255,117,96,104,255,118,77,109,255,115,56,122,255,81,49,120,255,63,68,106,255,63,71,94,255,63,75,81,255,92,108,107,255,50,57,51,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,146,127,120,255,121,96,102,255,112,85,100,255,97,65,90,255,88,50,101,255,65,44,85,255,67,58,104,255,49,64,90,255,66,89,107,255,63,86,92,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,110,75,87,255,141,85,119,255,108,58,104,255,81,39,91,255,72,38,102,255,53,47,106,255,34,69,127,255,10,34,51,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,28,6,26,255,59,10,68,255,39,2,61,255,1,1,9,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255]
144
161
  }
145
162
  },
163
+ "loop-break.sl": {
164
+ "hash": "e4d47563",
165
+ "source": "// A raymarched sphere that stops each ray where it hits (Specs/SL_NEXT.md 3b),\n// and a light that circles it: a real loop of at most 64 turns with a break.\nfloat4 main() {\n float2 p = (uv - 0.5) * float2(aspect, 1) * 2;\n float3 ro = float3(0, 0, -3);\n float3 rd = normalize(float3(p, 1.6));\n float t = 0;\n bool hit = false;\n for (int i = 0; i < 64; i++) {\n float d = length(ro + rd * t) - 1;\n if (d < 0.001) { hit = true; break; }\n t += d;\n if (t > 8) break;\n }\n if (!hit) return float4(0.05, 0.05, 0.08, 1);\n float3 n = normalize(ro + rd * t);\n float3 light = normalize(float3(cos(time), 0.6, sin(time)));\n float lit = max(dot(n, light), 0) * 0.9 + 0.1;\n return float4(lit, lit * 0.8, lit * 0.6, 1);\n}\n",
166
+ "samples": {
167
+ "0": [63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,176,159,140,255,201,182,160,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,120,108,94,255,153,138,121,255,179,162,142,255,202,183,161,255,228,206,181,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,92,82,71,255,132,119,104,255,161,146,128,255,186,168,147,255,209,189,166,255,236,214,188,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,110,99,86,255,144,130,113,255,170,154,135,255,195,176,155,255,219,198,174,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,124,112,98,255,155,140,122,255,181,163,143,255,206,186,164,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,101,91,79,255,138,124,109,255,167,151,132,255,194,175,154,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,118,106,93,255,152,137,120,255,182,164,144,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,92,82,72,255,135,122,106,255,172,156,136,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,114,103,90,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255],
168
+ "1.25": [63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,106,96,83,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,89,80,69,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255,63,63,80,255]
169
+ }
170
+ },
171
+ "loop-cap.sl": {
172
+ "hash": "9e8ae25d",
173
+ "source": "// The turn limit that guarantees every loop stops (Specs/SL_NEXT.md 3b): a\n// loop that never ends by itself leaves after 1024 turns on every backend, so\n// its count is exact; a loop of continues and a return from inside a loop\n// share the frame.\nfloat4 main() {\n int n = 0;\n while (true) { n++; }\n int odd = 0;\n for (int i = 0; i < int(uv.x * 40); i++) {\n if (i % 2 == 0) continue;\n odd++;\n }\n float r = n == 1024 ? 1 : 0;\n float g = float(odd) / 20;\n for (int j = 0; j < 100; j++) {\n if (float(j) > uv.y * 100) return float4(r, g, float(j) / 100, 1);\n }\n return float4(r, g, 1, 1);\n}\n",
174
+ "samples": {
175
+ "0": [255,0,252,255,255,89,252,255,255,108,252,255,255,124,252,255,255,137,252,255,255,160,252,255,255,170,252,255,255,179,252,255,255,188,252,255,255,203,252,255,255,211,252,255,255,218,252,255,255,225,252,255,255,237,252,255,255,243,252,255,255,249,252,255,255,0,243,255,255,89,243,255,255,108,243,255,255,124,243,255,255,137,243,255,255,160,243,255,255,170,243,255,255,179,243,255,255,188,243,255,255,203,243,255,255,211,243,255,255,218,243,255,255,225,243,255,255,237,243,255,255,243,243,255,255,249,243,255,255,0,236,255,255,89,236,255,255,108,236,255,255,124,236,255,255,137,236,255,255,160,236,255,255,170,236,255,255,179,236,255,255,188,236,255,255,203,236,255,255,211,236,255,255,218,236,255,255,225,236,255,255,237,236,255,255,243,236,255,255,249,236,255,255,0,229,255,255,89,229,255,255,108,229,255,255,124,229,255,255,137,229,255,255,160,229,255,255,170,229,255,255,179,229,255,255,188,229,255,255,203,229,255,255,211,229,255,255,218,229,255,255,225,229,255,255,237,229,255,255,243,229,255,255,249,229,255,255,0,221,255,255,89,221,255,255,108,221,255,255,124,221,255,255,137,221,255,255,160,221,255,255,170,221,255,255,179,221,255,255,188,221,255,255,203,221,255,255,211,221,255,255,218,221,255,255,225,221,255,255,237,221,255,255,243,221,255,255,249,221,255,255,0,211,255,255,89,211,255,255,108,211,255,255,124,211,255,255,137,211,255,255,160,211,255,255,170,211,255,255,179,211,255,255,188,211,255,255,203,211,255,255,211,211,255,255,218,211,255,255,225,211,255,255,237,211,255,255,243,211,255,255,249,211,255,255,0,202,255,255,89,202,255,255,108,202,255,255,124,202,255,255,137,202,255,255,160,202,255,255,170,202,255,255,179,202,255,255,188,202,255,255,203,202,255,255,211,202,255,255,218,202,255,255,225,202,255,255,237,202,255,255,243,202,255,255,249,202,255,255,0,192,255,255,89,192,255,255,108,192,255,255,124,192,255,255,137,192,255,255,160,192,255,255,170,192,255,255,179,192,255,255,188,192,255,255,203,192,255,255,211,192,255,255,218,192,255,255,225,192,255,255,237,192,255,255,243,192,255,255,249,192,255,255,0,182,255,255,89,182,255,255,108,182,255,255,124,182,255,255,137,182,255,255,160,182,255,255,170,182,255,255,179,182,255,255,188,182,255,255,203,182,255,255,211,182,255,255,218,182,255,255,225,182,255,255,237,182,255,255,243,182,255,255,249,182,255,255,0,170,255,255,89,170,255,255,108,170,255,255,124,170,255,255,137,170,255,255,160,170,255,255,170,170,255,255,179,170,255,255,188,170,255,255,203,170,255,255,211,170,255,255,218,170,255,255,225,170,255,255,237,170,255,255,243,170,255,255,249,170,255,255,0,158,255,255,89,158,255,255,108,158,255,255,124,158,255,255,137,158,255,255,160,158,255,255,170,158,255,255,179,158,255,255,188,158,255,255,203,158,255,255,211,158,255,255,218,158,255,255,225,158,255,255,237,158,255,255,243,158,255,255,249,158,255,255,0,144,255,255,89,144,255,255,108,144,255,255,124,144,255,255,137,144,255,255,160,144,255,255,170,144,255,255,179,144,255,255,188,144,255,255,203,144,255,255,211,144,255,255,218,144,255,255,225,144,255,255,237,144,255,255,243,144,255,255,249,144,255,255,0,129,255,255,89,129,255,255,108,129,255,255,124,129,255,255,137,129,255,255,160,129,255,255,170,129,255,255,179,129,255,255,188,129,255,255,203,129,255,255,211,129,255,255,218,129,255,255,225,129,255,255,237,129,255,255,243,129,255,255,249,129,255,255,0,108,255,255,89,108,255,255,108,108,255,255,124,108,255,255,137,108,255,255,160,108,255,255,170,108,255,255,179,108,255,255,188,108,255,255,203,108,255,255,211,108,255,255,218,108,255,255,225,108,255,255,237,108,255,255,243,108,255,255,249,108,255,255,0,85,255,255,89,85,255,255,108,85,255,255,124,85,255,255,137,85,255,255,160,85,255,255,170,85,255,255,179,85,255,255,188,85,255,255,203,85,255,255,211,85,255,255,218,85,255,255,225,85,255,255,237,85,255,255,243,85,255,255,249,85,255,255,0,48,255,255,89,48,255,255,108,48,255,255,124,48,255,255,137,48,255,255,160,48,255,255,170,48,255,255,179,48,255,255,188,48,255,255,203,48,255,255,211,48,255,255,218,48,255,255,225,48,255,255,237,48,255,255,243,48,255,255,249,48,255],
176
+ "1.25": [255,0,252,255,255,89,252,255,255,108,252,255,255,124,252,255,255,137,252,255,255,160,252,255,255,170,252,255,255,179,252,255,255,188,252,255,255,203,252,255,255,211,252,255,255,218,252,255,255,225,252,255,255,237,252,255,255,243,252,255,255,249,252,255,255,0,243,255,255,89,243,255,255,108,243,255,255,124,243,255,255,137,243,255,255,160,243,255,255,170,243,255,255,179,243,255,255,188,243,255,255,203,243,255,255,211,243,255,255,218,243,255,255,225,243,255,255,237,243,255,255,243,243,255,255,249,243,255,255,0,236,255,255,89,236,255,255,108,236,255,255,124,236,255,255,137,236,255,255,160,236,255,255,170,236,255,255,179,236,255,255,188,236,255,255,203,236,255,255,211,236,255,255,218,236,255,255,225,236,255,255,237,236,255,255,243,236,255,255,249,236,255,255,0,229,255,255,89,229,255,255,108,229,255,255,124,229,255,255,137,229,255,255,160,229,255,255,170,229,255,255,179,229,255,255,188,229,255,255,203,229,255,255,211,229,255,255,218,229,255,255,225,229,255,255,237,229,255,255,243,229,255,255,249,229,255,255,0,221,255,255,89,221,255,255,108,221,255,255,124,221,255,255,137,221,255,255,160,221,255,255,170,221,255,255,179,221,255,255,188,221,255,255,203,221,255,255,211,221,255,255,218,221,255,255,225,221,255,255,237,221,255,255,243,221,255,255,249,221,255,255,0,211,255,255,89,211,255,255,108,211,255,255,124,211,255,255,137,211,255,255,160,211,255,255,170,211,255,255,179,211,255,255,188,211,255,255,203,211,255,255,211,211,255,255,218,211,255,255,225,211,255,255,237,211,255,255,243,211,255,255,249,211,255,255,0,202,255,255,89,202,255,255,108,202,255,255,124,202,255,255,137,202,255,255,160,202,255,255,170,202,255,255,179,202,255,255,188,202,255,255,203,202,255,255,211,202,255,255,218,202,255,255,225,202,255,255,237,202,255,255,243,202,255,255,249,202,255,255,0,192,255,255,89,192,255,255,108,192,255,255,124,192,255,255,137,192,255,255,160,192,255,255,170,192,255,255,179,192,255,255,188,192,255,255,203,192,255,255,211,192,255,255,218,192,255,255,225,192,255,255,237,192,255,255,243,192,255,255,249,192,255,255,0,182,255,255,89,182,255,255,108,182,255,255,124,182,255,255,137,182,255,255,160,182,255,255,170,182,255,255,179,182,255,255,188,182,255,255,203,182,255,255,211,182,255,255,218,182,255,255,225,182,255,255,237,182,255,255,243,182,255,255,249,182,255,255,0,170,255,255,89,170,255,255,108,170,255,255,124,170,255,255,137,170,255,255,160,170,255,255,170,170,255,255,179,170,255,255,188,170,255,255,203,170,255,255,211,170,255,255,218,170,255,255,225,170,255,255,237,170,255,255,243,170,255,255,249,170,255,255,0,158,255,255,89,158,255,255,108,158,255,255,124,158,255,255,137,158,255,255,160,158,255,255,170,158,255,255,179,158,255,255,188,158,255,255,203,158,255,255,211,158,255,255,218,158,255,255,225,158,255,255,237,158,255,255,243,158,255,255,249,158,255,255,0,144,255,255,89,144,255,255,108,144,255,255,124,144,255,255,137,144,255,255,160,144,255,255,170,144,255,255,179,144,255,255,188,144,255,255,203,144,255,255,211,144,255,255,218,144,255,255,225,144,255,255,237,144,255,255,243,144,255,255,249,144,255,255,0,129,255,255,89,129,255,255,108,129,255,255,124,129,255,255,137,129,255,255,160,129,255,255,170,129,255,255,179,129,255,255,188,129,255,255,203,129,255,255,211,129,255,255,218,129,255,255,225,129,255,255,237,129,255,255,243,129,255,255,249,129,255,255,0,108,255,255,89,108,255,255,108,108,255,255,124,108,255,255,137,108,255,255,160,108,255,255,170,108,255,255,179,108,255,255,188,108,255,255,203,108,255,255,211,108,255,255,218,108,255,255,225,108,255,255,237,108,255,255,243,108,255,255,249,108,255,255,0,85,255,255,89,85,255,255,108,85,255,255,124,85,255,255,137,85,255,255,160,85,255,255,170,85,255,255,179,85,255,255,188,85,255,255,203,85,255,255,211,85,255,255,218,85,255,255,225,85,255,255,237,85,255,255,243,85,255,255,249,85,255,255,0,48,255,255,89,48,255,255,108,48,255,255,124,48,255,255,137,48,255,255,160,48,255,255,170,48,255,255,179,48,255,255,188,48,255,255,203,48,255,255,211,48,255,255,218,48,255,255,225,48,255,255,237,48,255,255,243,48,255,255,249,48,255]
177
+ }
178
+ },
179
+ "loop-uniform.sl": {
180
+ "hash": "2f4c28c0",
181
+ "source": "// A Mandelbrot set whose iteration count is a uniform (Specs/SL_NEXT.md 3b):\n// a real loop, capped at the Range's max, that leaves by break as each point escapes.\n[Range(16, 256)] uniform float iterations = 96;\nfloat4 main() {\n float2 c = (uv - float2(0.7, 0.5)) * float2(3, 2.4);\n float2 z = 0;\n int n = 0;\n for (int i = 0; i < int(iterations); i++) {\n if (dot(z, z) > 4) break;\n z = float2(z.x * z.x - z.y * z.y, 2 * z.x * z.y) + c;\n n++;\n }\n float t = float(n) / iterations;\n return float4(t, sqrt(t), t * t, 1);\n}\n",
182
+ "samples": {
183
+ "0": [26,90,0,255,26,90,0,255,40,106,2,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,58,125,6,255,49,117,3,255,40,106,2,255,40,106,2,255,40,106,2,255,26,90,0,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,117,174,49,255,64,131,9,255,58,125,6,255,49,117,3,255,40,106,2,255,40,106,2,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,86,150,23,255,255,255,255,255,76,142,16,255,64,131,9,255,49,117,3,255,49,117,3,255,40,106,2,255,26,90,0,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,71,137,13,255,91,154,27,255,255,255,255,255,255,255,255,255,103,163,37,255,76,142,16,255,64,131,9,255,49,117,3,255,40,106,2,255,26,90,0,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,64,131,9,255,71,137,13,255,86,150,23,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,71,137,13,255,49,117,3,255,49,117,3,255,26,90,0,255,49,117,3,255,58,125,6,255,64,131,9,255,91,154,27,255,117,174,49,255,81,146,20,255,204,228,163,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,99,160,34,255,49,117,3,255,49,117,3,255,40,106,2,255,58,125,6,255,64,131,9,255,71,137,13,255,95,157,30,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,76,142,16,255,58,125,6,255,49,117,3,255,58,125,6,255,76,142,16,255,71,137,13,255,99,160,34,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,71,137,13,255,58,125,6,255,49,117,3,255,58,125,6,255,58,125,6,255,71,137,13,255,91,154,27,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,71,137,13,255,58,125,6,255,49,117,3,255,40,106,2,255,58,125,6,255,58,125,6,255,64,131,9,255,91,154,27,255,255,255,255,255,147,194,82,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,81,146,20,255,58,125,6,255,49,117,3,255,26,90,0,255,49,117,3,255,58,125,6,255,58,125,6,255,81,146,20,255,81,146,20,255,76,142,16,255,107,166,40,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,129,182,62,255,49,117,3,255,49,117,3,255,26,90,0,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,64,131,9,255,64,131,9,255,81,146,20,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,64,131,9,255,49,117,3,255,49,117,3,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,81,146,20,255,91,154,27,255,255,255,255,255,86,150,23,255,71,137,13,255,58,125,6,255,49,117,3,255,40,106,2,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,110,169,43,255,255,255,255,255,71,137,13,255,58,125,6,255,49,117,3,255,49,117,3,255,40,106,2,255,26,90,0,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,91,154,27,255,58,125,6,255,58,125,6,255,49,117,3,255,40,106,2,255,40,106,2,255,26,90,0,255,26,90,0,255,40,106,2,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,64,131,9,255,49,117,3,255,40,106,2,255,40,106,2,255,40,106,2,255,40,106,2,255],
184
+ "1.25": [26,90,0,255,26,90,0,255,40,106,2,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,58,125,6,255,49,117,3,255,40,106,2,255,40,106,2,255,40,106,2,255,26,90,0,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,117,174,49,255,64,131,9,255,58,125,6,255,49,117,3,255,40,106,2,255,40,106,2,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,86,150,23,255,255,255,255,255,76,142,16,255,64,131,9,255,49,117,3,255,49,117,3,255,40,106,2,255,26,90,0,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,71,137,13,255,91,154,27,255,255,255,255,255,255,255,255,255,103,163,37,255,76,142,16,255,64,131,9,255,49,117,3,255,40,106,2,255,26,90,0,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,64,131,9,255,71,137,13,255,86,150,23,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,71,137,13,255,49,117,3,255,49,117,3,255,26,90,0,255,49,117,3,255,58,125,6,255,64,131,9,255,91,154,27,255,117,174,49,255,81,146,20,255,204,228,163,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,99,160,34,255,49,117,3,255,49,117,3,255,40,106,2,255,58,125,6,255,64,131,9,255,71,137,13,255,95,157,30,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,76,142,16,255,58,125,6,255,49,117,3,255,58,125,6,255,76,142,16,255,71,137,13,255,99,160,34,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,71,137,13,255,58,125,6,255,49,117,3,255,58,125,6,255,58,125,6,255,71,137,13,255,91,154,27,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,71,137,13,255,58,125,6,255,49,117,3,255,40,106,2,255,58,125,6,255,58,125,6,255,64,131,9,255,91,154,27,255,255,255,255,255,147,194,82,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,81,146,20,255,58,125,6,255,49,117,3,255,26,90,0,255,49,117,3,255,58,125,6,255,58,125,6,255,81,146,20,255,81,146,20,255,76,142,16,255,107,166,40,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,129,182,62,255,49,117,3,255,49,117,3,255,26,90,0,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,64,131,9,255,64,131,9,255,81,146,20,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,64,131,9,255,49,117,3,255,49,117,3,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,81,146,20,255,91,154,27,255,255,255,255,255,86,150,23,255,71,137,13,255,58,125,6,255,49,117,3,255,40,106,2,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,110,169,43,255,255,255,255,255,71,137,13,255,58,125,6,255,49,117,3,255,49,117,3,255,40,106,2,255,26,90,0,255,26,90,0,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,58,125,6,255,64,131,9,255,91,154,27,255,58,125,6,255,58,125,6,255,49,117,3,255,40,106,2,255,40,106,2,255,26,90,0,255,26,90,0,255,40,106,2,255,40,106,2,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,49,117,3,255,58,125,6,255,64,131,9,255,49,117,3,255,40,106,2,255,40,106,2,255,40,106,2,255,40,106,2,255]
185
+ }
186
+ },
146
187
  "orient.sl": {
147
188
  "hash": "4838e4b8",
148
189
  "source": "// An anchor: red is uv.x, green is uv.y, so a golden's orientation and its\n// linear-to-sRGB store can be checked against arithmetic, not against itself.\nfloat4 main() { return float4(uv.x, uv.y, 0, 1); }\n",
@@ -186,6 +227,14 @@
186
227
  "1.25": [0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255]
187
228
  }
188
229
  },
230
+ "switch.sl": {
231
+ "hash": "1a535831",
232
+ "source": "// A switch over an int, as the if chain it means (Specs/SL_NEXT.md 3a): one\n// case per band, two labels stacked on one body, and a default.\n[Range(0, 3)] uniform int mode = 2;\nfloat4 main() {\n float t = 0;\n switch (int(uv.x * 5)) {\n case 0: t = uv.y; break;\n case 1: t = 1 - uv.y; break;\n case 2: case 3: t = length(uv - 0.5) * 1.4; break;\n default: t = frac(uv.y * 4); break;\n }\n float3 tint = float3(1, 1, 1);\n switch (mode) {\n case 0: tint = float3(1, 0.4, 0.2); break;\n case 2: tint = float3(0.2, 0.6, 1); break;\n default: break;\n }\n return float4(tint * t, 1);\n}\n",
233
+ "samples": {
234
+ "0": [121,200,251,255,121,200,251,255,121,200,251,255,22,42,56,255,22,42,56,255,22,42,56,255,101,168,212,255,101,167,210,255,101,167,210,255,102,169,212,255,103,172,216,255,106,176,220,255,109,180,226,255,114,189,237,255,114,189,237,255,114,189,237,255,118,194,243,255,118,194,243,255,118,194,243,255,39,70,90,255,39,70,90,255,39,70,90,255,95,158,199,255,94,157,197,255,94,157,197,255,95,159,200,255,97,162,204,255,100,167,210,255,104,172,216,255,97,161,202,255,97,161,202,255,97,161,202,255,114,188,236,255,114,188,236,255,114,188,236,255,51,88,113,255,51,88,113,255,51,88,113,255,88,147,185,255,87,145,183,255,87,145,183,255,88,148,186,255,91,152,191,255,95,158,198,255,99,164,206,255,74,125,158,255,74,125,158,255,74,125,158,255,110,181,228,255,110,181,228,255,110,181,228,255,60,103,131,255,60,103,131,255,60,103,131,255,80,135,170,255,78,132,167,255,79,132,167,255,81,136,171,255,84,141,178,255,89,148,187,255,94,156,197,255,37,67,86,255,37,67,86,255,37,67,86,255,105,175,219,255,105,175,219,255,105,175,219,255,68,116,146,255,68,116,146,255,68,116,146,255,71,121,153,255,69,117,148,255,69,118,149,255,72,123,155,255,77,130,165,255,83,139,176,255,89,149,188,255,114,189,237,255,114,189,237,255,114,189,237,255,101,168,211,255,101,168,211,255,101,168,211,255,75,127,160,255,75,127,160,255,75,127,160,255,62,106,134,255,58,100,127,255,58,101,128,255,63,108,137,255,70,119,151,255,78,131,166,255,85,143,180,255,97,161,202,255,97,161,202,255,97,161,202,255,96,160,201,255,96,160,201,255,96,160,201,255,81,137,172,255,81,137,172,255,81,137,172,255,52,90,115,255,44,77,99,255,45,80,102,255,54,94,120,255,64,110,139,255,74,125,157,255,82,138,174,255,74,125,158,255,74,125,158,255,74,125,158,255,91,152,191,255,91,152,191,255,91,152,191,255,87,146,184,255,87,146,184,255,87,146,184,255,44,77,99,255,24,46,61,255,30,55,71,255,48,84,107,255,61,104,132,255,71,121,153,255,81,135,171,255,37,67,86,255,37,67,86,255,37,67,86,255,86,143,181,255,86,143,181,255,86,143,181,255,92,154,194,255,92,154,194,255,92,154,194,255,45,80,102,255,30,55,71,255,33,61,79,255,49,85,109,255,61,105,133,255,72,122,154,255,81,136,171,255,114,189,237,255,114,189,237,255,114,189,237,255,80,134,169,255,80,134,169,255,80,134,169,255,97,162,204,255,97,162,204,255,97,162,204,255,54,94,120,255,48,84,107,255,49,85,109,255,57,97,124,255,66,112,142,255,75,126,159,255,83,139,175,255,97,161,202,255,97,161,202,255,97,161,202,255,73,124,157,255,73,124,157,255,73,124,157,255,102,169,213,255,102,169,213,255,102,169,213,255,64,110,139,255,61,104,132,255,61,105,133,255,66,112,142,255,72,122,154,255,79,133,168,255,86,144,182,255,74,125,158,255,74,125,158,255,74,125,158,255,66,113,143,255,66,113,143,255,66,113,143,255,106,176,221,255,106,176,221,255,106,176,221,255,74,125,157,255,71,121,153,255,72,122,154,255,75,126,159,255,79,133,168,255,84,142,179,255,90,151,190,255,37,67,86,255,37,67,86,255,37,67,86,255,58,100,127,255,58,100,127,255,58,100,127,255,111,183,230,255,111,183,230,255,111,183,230,255,82,138,174,255,81,135,171,255,81,136,171,255,83,139,175,255,86,144,182,255,90,151,190,255,95,158,199,255,114,189,237,255,114,189,237,255,114,189,237,255,48,84,107,255,48,84,107,255,48,84,107,255,115,189,238,255,115,189,238,255,115,189,238,255,90,150,189,255,88,148,186,255,89,148,187,255,90,151,190,255,93,155,195,255,96,160,201,255,100,166,209,255,97,161,202,255,97,161,202,255,97,161,202,255,35,64,83,255,35,64,83,255,35,64,83,255,119,195,245,255,119,195,245,255,119,195,245,255,97,161,202,255,96,159,200,255,96,160,201,255,97,161,203,255,99,165,207,255,102,169,212,255,105,174,219,255,74,125,158,255,74,125,158,255,74,125,158,255,15,32,42,255,15,32,42,255,15,32,42,255,122,201,252,255,122,201,252,255,122,201,252,255,103,171,215,255,102,170,213,255,102,170,214,255,103,171,215,255,105,174,219,255,107,178,223,255,110,182,229,255,37,67,86,255,37,67,86,255,37,67,86,255],
235
+ "1.25": [121,200,251,255,121,200,251,255,121,200,251,255,22,42,56,255,22,42,56,255,22,42,56,255,101,168,212,255,101,167,210,255,101,167,210,255,102,169,212,255,103,172,216,255,106,176,220,255,109,180,226,255,114,189,237,255,114,189,237,255,114,189,237,255,118,194,243,255,118,194,243,255,118,194,243,255,39,70,90,255,39,70,90,255,39,70,90,255,95,158,199,255,94,157,197,255,94,157,197,255,95,159,200,255,97,162,204,255,100,167,210,255,104,172,216,255,97,161,202,255,97,161,202,255,97,161,202,255,114,188,236,255,114,188,236,255,114,188,236,255,51,88,113,255,51,88,113,255,51,88,113,255,88,147,185,255,87,145,183,255,87,145,183,255,88,148,186,255,91,152,191,255,95,158,198,255,99,164,206,255,74,125,158,255,74,125,158,255,74,125,158,255,110,181,228,255,110,181,228,255,110,181,228,255,60,103,131,255,60,103,131,255,60,103,131,255,80,135,170,255,78,132,167,255,79,132,167,255,81,136,171,255,84,141,178,255,89,148,187,255,94,156,197,255,37,67,86,255,37,67,86,255,37,67,86,255,105,175,219,255,105,175,219,255,105,175,219,255,68,116,146,255,68,116,146,255,68,116,146,255,71,121,153,255,69,117,148,255,69,118,149,255,72,123,155,255,77,130,165,255,83,139,176,255,89,149,188,255,114,189,237,255,114,189,237,255,114,189,237,255,101,168,211,255,101,168,211,255,101,168,211,255,75,127,160,255,75,127,160,255,75,127,160,255,62,106,134,255,58,100,127,255,58,101,128,255,63,108,137,255,70,119,151,255,78,131,166,255,85,143,180,255,97,161,202,255,97,161,202,255,97,161,202,255,96,160,201,255,96,160,201,255,96,160,201,255,81,137,172,255,81,137,172,255,81,137,172,255,52,90,115,255,44,77,99,255,45,80,102,255,54,94,120,255,64,110,139,255,74,125,157,255,82,138,174,255,74,125,158,255,74,125,158,255,74,125,158,255,91,152,191,255,91,152,191,255,91,152,191,255,87,146,184,255,87,146,184,255,87,146,184,255,44,77,99,255,24,46,61,255,30,55,71,255,48,84,107,255,61,104,132,255,71,121,153,255,81,135,171,255,37,67,86,255,37,67,86,255,37,67,86,255,86,143,181,255,86,143,181,255,86,143,181,255,92,154,194,255,92,154,194,255,92,154,194,255,45,80,102,255,30,55,71,255,33,61,79,255,49,85,109,255,61,105,133,255,72,122,154,255,81,136,171,255,114,189,237,255,114,189,237,255,114,189,237,255,80,134,169,255,80,134,169,255,80,134,169,255,97,162,204,255,97,162,204,255,97,162,204,255,54,94,120,255,48,84,107,255,49,85,109,255,57,97,124,255,66,112,142,255,75,126,159,255,83,139,175,255,97,161,202,255,97,161,202,255,97,161,202,255,73,124,157,255,73,124,157,255,73,124,157,255,102,169,213,255,102,169,213,255,102,169,213,255,64,110,139,255,61,104,132,255,61,105,133,255,66,112,142,255,72,122,154,255,79,133,168,255,86,144,182,255,74,125,158,255,74,125,158,255,74,125,158,255,66,113,143,255,66,113,143,255,66,113,143,255,106,176,221,255,106,176,221,255,106,176,221,255,74,125,157,255,71,121,153,255,72,122,154,255,75,126,159,255,79,133,168,255,84,142,179,255,90,151,190,255,37,67,86,255,37,67,86,255,37,67,86,255,58,100,127,255,58,100,127,255,58,100,127,255,111,183,230,255,111,183,230,255,111,183,230,255,82,138,174,255,81,135,171,255,81,136,171,255,83,139,175,255,86,144,182,255,90,151,190,255,95,158,199,255,114,189,237,255,114,189,237,255,114,189,237,255,48,84,107,255,48,84,107,255,48,84,107,255,115,189,238,255,115,189,238,255,115,189,238,255,90,150,189,255,88,148,186,255,89,148,187,255,90,151,190,255,93,155,195,255,96,160,201,255,100,166,209,255,97,161,202,255,97,161,202,255,97,161,202,255,35,64,83,255,35,64,83,255,35,64,83,255,119,195,245,255,119,195,245,255,119,195,245,255,97,161,202,255,96,159,200,255,96,160,201,255,97,161,203,255,99,165,207,255,102,169,212,255,105,174,219,255,74,125,158,255,74,125,158,255,74,125,158,255,15,32,42,255,15,32,42,255,15,32,42,255,122,201,252,255,122,201,252,255,122,201,252,255,103,171,215,255,102,170,213,255,102,170,214,255,103,171,215,255,105,174,219,255,107,178,223,255,110,182,229,255,37,67,86,255,37,67,86,255,37,67,86,255]
236
+ }
237
+ },
189
238
  "texture.sl": {
190
239
  "hash": "0764a372",
191
240
  "source": "// An anchor: the texture itself, so its orientation and its sRGB decode can be\n// checked against the texture's own definition.\ntexture2D t;\nfloat4 main() { return tex2D(t, uv); }\n",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onejs-sl",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The OneJS shader language: a small typed language for per pixel programs, compiled to a portable IR and emitted as HLSL, WGSL or GLSL ES",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/body.ts CHANGED
@@ -21,10 +21,11 @@
21
21
  * gives common subexpression elimination for free.
22
22
  */
23
23
 
24
- import { SLError, TYPE, type InputName, type Program, type SLNode, type SLType } from "./ir"
24
+ import { INT_BOUNDS, SLError, TYPE, valueAt, type InputName, type NodeRef, type Program, type SLKind, type SLType, type ValueNode } from "./ir"
25
25
  import { libClosure, LIB_FUNCTIONS } from "./lib"
26
26
  import { LIB_HLSL } from "./lib/hlsl"
27
27
  import { SLOP } from "./ops"
28
+ import { inVaryingFlow, local, printBody, structure, type Syntax } from "./structure"
28
29
 
29
30
  export interface BodyTarget {
30
31
  /** An expression for each input, e.g. `{ uv: "SL_UV", time: "SL_TIME", ... }`. */
@@ -67,6 +68,12 @@ export interface BodyTarget {
67
68
  colour: "gamma" | "linear"
68
69
  /** Assign the result to this local instead of returning it. */
69
70
  result?: string
71
+ /**
72
+ * Put before every loop the body prints: `[loop]` for HLSL, so a compiler
73
+ * does not try to unroll a loop whose turns are capped only by a counter.
74
+ * Nothing for Metal, which has no such attribute.
75
+ */
76
+ loopAttribute?: string
70
77
  /** Put in front of every line. Default four spaces. */
71
78
  indent?: string
72
79
  }
@@ -85,6 +92,25 @@ export interface Body {
85
92
 
86
93
  const HLSL_TYPE: Record<SLType, string> = { 1: "float", 2: "float2", 3: "float3", 4: "float4" }
87
94
 
95
+ /** A value's HLSL type, which Metal spells the same through a host's defines. */
96
+ function typeName(n: { type: SLType; kind?: SLKind }): string {
97
+ if (n.kind === undefined) return HLSL_TYPE[n.type]
98
+ return n.type === 1 ? n.kind : `${n.kind}${n.type}`
99
+ }
100
+
101
+ /** An int, uint or bool constant as a literal. */
102
+ function kindLit(kind: SLKind, v: number): string {
103
+ if (kind === "bool") return v !== 0 ? "true" : "false"
104
+ if (kind === "uint") return `${v >>> 0}u`
105
+ return v < 0 ? `(${v})` : String(v)
106
+ }
107
+
108
+ /** The int range a float is held to on its way to an int, so every backend truncates the same. */
109
+ export const INT_LIMITS = {
110
+ int: INT_BOUNDS.int.map((n) => lit(n)),
111
+ uint: INT_BOUNDS.uint.map((n) => lit(n)),
112
+ } as const
113
+
88
114
  /** A literal that survives a float32 round trip and never reads as an int. */
89
115
  export function lit(n: number): string {
90
116
  if (!Number.isFinite(n)) throw new SLError(`cannot emit ${n} as a shader literal`)
@@ -100,9 +126,8 @@ const SWZ = "xyzw"
100
126
 
101
127
  export function emitBody(p: Program, target: BodyTarget): Body {
102
128
  const indent = target.indent ?? " "
103
- const lines: string[] = []
104
- const name = (ref: number) => `n${ref}`
105
- const emitted = new Set<number>()
129
+ const name = local
130
+ const shape = structure(p)
106
131
  const uniforms = new Set<number>()
107
132
  const textures = new Set<number>()
108
133
  const helpers = new Set<string>()
@@ -113,11 +138,13 @@ export function emitBody(p: Program, target: BodyTarget): Body {
113
138
  const c = p.nodes[ref]!
114
139
  return c.k === "const" ? c.v : null
115
140
  }
116
- const splat = (ref: number, w: SLType) => (p.nodes[ref]!.type === TYPE.FLOAT && w > 1 ? ctor(w, Array(w).fill(name(ref))) : name(ref))
141
+ const splat = (ref: number, w: SLType) => (valueAt(p.nodes, ref).type === TYPE.FLOAT && w > 1 ? ctor(w, Array(w).fill(name(ref))) : name(ref))
117
142
 
118
- const expr = (n: SLNode): string => {
143
+ const expr = (ref: NodeRef): string => {
144
+ const n = valueAt(p.nodes, ref)
119
145
  switch (n.k) {
120
146
  case "const":
147
+ if (n.kind !== undefined) return n.type === 1 ? kindLit(n.kind, n.v[0]!) : `${typeName(n)}(${n.v.map((v) => kindLit(n.kind!, v)).join(", ")})`
121
148
  return ctor(n.type, n.v.map(lit))
122
149
  case "input":
123
150
  return target.inputs[n.name]
@@ -130,14 +157,18 @@ export function emitBody(p: Program, target: BodyTarget): Body {
130
157
  }
131
158
  case "swizzle":
132
159
  // Metal has no swizzle of a scalar, so a scalar widens by constructor.
133
- if (p.nodes[n.src]!.type === TYPE.FLOAT) return ctor(n.type, n.chans.map(() => name(n.src)))
160
+ if (valueAt(p.nodes, n.src).type === TYPE.FLOAT) {
161
+ return n.type === 1 ? name(n.src) : `${typeName(n)}(${n.chans.map(() => name(n.src)).join(", ")})`
162
+ }
134
163
  return `${name(n.src)}.${n.chans.map((c) => SWZ[c]).join("")}`
135
164
  case "call":
136
- return call(n)
165
+ return call(n, ref)
166
+ default:
167
+ throw new SLError(`the HLSL emitter reached a ${n.k} as an expression`)
137
168
  }
138
169
  }
139
170
 
140
- const call = (n: Extract<SLNode, { k: "call" }>): string => {
171
+ const call = (n: Extract<ValueNode, { k: "call" }>, ref: NodeRef): string => {
141
172
  const a = n.args.map(name)
142
173
  const t = n.type
143
174
  // Every argument of an element wise intrinsic at the result's width,
@@ -146,10 +177,55 @@ export function emitBody(p: Program, target: BodyTarget): Body {
146
177
  // max(float, 0) is ambiguous, so the shared subset spells both out.
147
178
  const s = n.args.map((r) => splat(r, t))
148
179
  const k = (v: number, w: SLType) => ctor(w, Array(w).fill(lit(v)))
149
- const w0 = n.args.length > 0 ? p.nodes[n.args[0]!]!.type : TYPE.FLOAT
180
+ const w0 = n.args.length > 0 ? valueAt(p.nodes, n.args[0]!).type : TYPE.FLOAT
150
181
  const imm = n.imm ?? []
182
+ const argKind = n.args.length > 0 ? valueAt(p.nodes, n.args[0]!).kind : undefined
183
+ // IR 4: the ops that take ints, uints and bools, by the kinds involved.
184
+ if (n.kind !== undefined || argKind !== undefined) {
185
+ const zero = kindLit(n.kind ?? "int", 0)
186
+ switch (n.op) {
187
+ case SLOP.ADD: return `(${a[0]} + ${a[1]})`
188
+ case SLOP.SUB: return `(${a[0]} - ${a[1]})`
189
+ case SLOP.MUL: return `(${a[0]} * ${a[1]})`
190
+ // Truncating, and 0 for a zero divisor, which HLSL leaves undefined.
191
+ case SLOP.DIV: return `(${a[1]} == ${zero} ? ${zero} : ${a[0]} / ${a[1]})`
192
+ case SLOP.MOD: return `(${a[1]} == ${zero} ? ${zero} : ${a[0]} % ${a[1]})`
193
+ case SLOP.NEG: return `(-${a[0]})`
194
+ case SLOP.MIN: return `min(${a[0]}, ${a[1]})`
195
+ case SLOP.MAX: return `max(${a[0]}, ${a[1]})`
196
+ case SLOP.ABS: return `abs(${a[0]})`
197
+ case SLOP.CLAMP: return `clamp(${a[0]}, ${a[1]}, ${a[2]})`
198
+ }
199
+ }
151
200
  switch (n.op) {
152
- case SLOP.COMPOSE: return ctor(n.type, a)
201
+ case SLOP.COMPOSE: return n.kind === undefined ? ctor(n.type, a) : `${typeName(n)}(${a.join(", ")})`
202
+ case SLOP.CAST: {
203
+ const from = valueAt(p.nodes, n.args[0]!).kind
204
+ if (n.kind === undefined) return `${typeName(n)}(${a[0]})`
205
+ if (n.kind === "bool") return `(${a[0]} != ${from === undefined ? "0.0" : kindLit(from, 0)})`
206
+ if (from === undefined) {
207
+ const [lo, hi] = INT_LIMITS[n.kind]
208
+ return `${n.kind}(clamp(${a[0]}, ${lo}, ${hi}))`
209
+ }
210
+ return `${n.kind}(${a[0]})`
211
+ }
212
+ case SLOP.LT: return `(${a[0]} < ${a[1]})`
213
+ case SLOP.LE: return `(${a[0]} <= ${a[1]})`
214
+ case SLOP.GT: return `(${a[0]} > ${a[1]})`
215
+ case SLOP.GE: return `(${a[0]} >= ${a[1]})`
216
+ case SLOP.EQ: return `(${a[0]} == ${a[1]})`
217
+ case SLOP.NE: return `(${a[0]} != ${a[1]})`
218
+ case SLOP.AND: return `(${a[0]} && ${a[1]})`
219
+ case SLOP.OR: return `(${a[0]} || ${a[1]})`
220
+ case SLOP.NOT: return `(!${a[0]})`
221
+ case SLOP.BIT_AND: return `(${a[0]} & ${a[1]})`
222
+ case SLOP.BIT_OR: return `(${a[0]} | ${a[1]})`
223
+ case SLOP.BIT_XOR: return `(${a[0]} ^ ${a[1]})`
224
+ case SLOP.BIT_NOT: return `(~${a[0]})`
225
+ // The count modulo 32, which HLSL does itself and GLSL leaves undefined past 31.
226
+ case SLOP.SHL: return `(${a[0]} << (${a[1]} & ${kindLit(valueAt(p.nodes, n.args[1]!).kind ?? "int", 31)}))`
227
+ case SLOP.SHR: return `(${a[0]} >> (${a[1]} & ${kindLit(valueAt(p.nodes, n.args[1]!).kind ?? "int", 31)}))`
228
+ case SLOP.CHOOSE: return `(${a[0]} ? ${a[1]} : ${a[2]})`
153
229
 
154
230
  case SLOP.ADD: return `(${a[0]} + ${a[1]})`
155
231
  case SLOP.SUB: return `(${a[0]} - ${a[1]})`
@@ -223,7 +299,9 @@ export function emitBody(p: Program, target: BodyTarget): Body {
223
299
  case SLOP.SAMPLE: {
224
300
  const slot = Math.round(imm[0] ?? 0)
225
301
  textures.add(slot)
226
- return target.sample(slot, a[0]!)
302
+ // Where pixels part ways there are no neighbours to take a mip
303
+ // level from, so every backend samples level 0 there (`structure.ts`).
304
+ return inVaryingFlow(shape, ref) ? target.sampleLevel(slot, a[0]!, "0.0") : target.sample(slot, a[0]!)
227
305
  }
228
306
  case SLOP.SAMPLE_LOD: {
229
307
  const slot = Math.round(imm[0] ?? 0)
@@ -240,15 +318,20 @@ export function emitBody(p: Program, target: BodyTarget): Body {
240
318
  }
241
319
  }
242
320
 
243
- const walk = (ref: number): void => {
244
- if (emitted.has(ref)) return
245
- const n = p.nodes[ref]
246
- const deps = n.k === "swizzle" ? [n.src] : n.k === "call" ? n.args : []
247
- for (const d of deps) walk(d)
248
- emitted.add(ref)
249
- lines.push(`${indent}${HLSL_TYPE[n.type]} ${name(ref)} = ${expr(n)};`)
321
+ const typeOf = (ref: NodeRef) => typeName(valueAt(p.nodes, ref))
322
+ const syntax: Syntax = {
323
+ value: (ref, e) => `${typeOf(ref)} ${name(ref)} = ${e};`,
324
+ mutable: (n, like, init) => `${typeOf(like)} ${n}${init === undefined ? "" : ` = ${init}`};`,
325
+ counter: (n) => `int ${n} = 0;`,
326
+ assign: (n, v) => `${n} = ${v};`,
327
+ increment: (n) => `${n}++;`,
328
+ ifOpen: (c) => `if (${c}) {`,
329
+ elseOpen: "} else {",
330
+ close: "}",
331
+ loopOpen: `${target.loopAttribute === undefined ? "" : target.loopAttribute + " "}for (;;) {`,
332
+ breakUnless: (c, turns, max) => `if (!(${c}) || ${turns} >= ${max}) break;`,
250
333
  }
251
- walk(p.result)
334
+ const lines = printBody(p, shape, syntax, expr, indent)
252
335
  lines.push(target.result === undefined
253
336
  ? `${indent}return ${name(p.result)};`
254
337
  : `${indent}${target.result} = ${name(p.result)};`)
package/src/hlsl.ts CHANGED
@@ -153,6 +153,7 @@ function unityTarget(p: Program): BodyTarget {
153
153
  sampleLevel: (slot, uv, lod) => `tex2Dlod(_Tex${slot}, float4(${uv}, 0.0, ${lod}))`,
154
154
  colour: "linear",
155
155
  indent: " ",
156
+ loopAttribute: "[loop]",
156
157
  }
157
158
  }
158
159