onejs-sl 0.9.0 → 0.9.1
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 +9 -0
- package/README.md +1 -1
- package/goldens/goldens.json +10 -1
- package/package.json +1 -1
- package/src/body.ts +10 -4
- package/src/web.ts +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
`?:` now takes one side instead of blending the two, so a huge, infinite or NaN value on the side not taken no longer spoils the result. Every program keeps its hash; a host's generated shaders take the new text on their next build.
|
|
6
|
+
|
|
7
|
+
- `?:` chooses one side instead of blending the two, so a large, infinite or NaN value on the side not chosen no longer reaches the result
|
|
8
|
+
- A NaN condition picks the false side on every backend
|
|
9
|
+
- Every program keeps its hash; one with a `?:` on floats compiles to new shader text, which a host's generated shaders pick up on their next build
|
|
10
|
+
- The goldens anchor `select-extremes.sl` to arithmetic
|
|
11
|
+
|
|
3
12
|
## 0.9.0
|
|
4
13
|
|
|
5
14
|
A program can hold 64 uniforms and 8 textures, say how it samples a texture, and read a texture's size and its texels unfiltered. Every existing program keeps its hash and draws as it did; one that uses the new texture features is IR 6, which a host has to implement (below) to draw.
|
package/README.md
CHANGED
|
@@ -166,7 +166,7 @@ either side, on a texture sampled nearest between levels), `wrap-repeat.sl`
|
|
|
166
166
|
and `wrap-mirror.sl` (a program's own wrap over a texture the host binds
|
|
167
167
|
clamped, the filter's footprint wrapping with it), `filter-point.sl` (its own
|
|
168
168
|
point filter, to the byte, through `tex2D` and `tex2Dlod`) and `fetch.sl`
|
|
169
|
-
(`tex2Dfetch` held at the edges and `textureSize`, to the byte),
|
|
169
|
+
(`tex2Dfetch` held at the edges and `textureSize`, to the byte), `uniforms-64.sl` (every uniform slot arrives), and `select-extremes.sl` (`?:` chooses, so 1e9, an infinity or NaN on the side not chosen never reaches the one chosen). `sdf-values.sl`, `fbm-values.sl` and `ramp-values.sl` are black unless a
|
|
170
170
|
shape, a noise or a ramp draws differently with its parameters as values than
|
|
171
171
|
as constants.
|
|
172
172
|
A fixture that reads the previous frame, `frame` or `deltaTime` is stepped
|
package/goldens/goldens.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generatedBy": "onejs-sl goldens/run.mjs",
|
|
3
|
-
"package": "0.9.
|
|
3
|
+
"package": "0.9.1",
|
|
4
4
|
"ir": 6,
|
|
5
5
|
"target": "rgba8unorm-srgb: straight alpha, 8 bit, sRGB encoded, the stored bytes of a Linear OneJS game's element",
|
|
6
6
|
"size": [
|
|
@@ -306,6 +306,15 @@
|
|
|
306
306
|
"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]
|
|
307
307
|
}
|
|
308
308
|
},
|
|
309
|
+
"select-extremes.sl": {
|
|
310
|
+
"hash": "2258fc10",
|
|
311
|
+
"exact": true,
|
|
312
|
+
"source": "// An anchor: ?: chooses one side and never blends the two, so what it does not\n// choose, however large, infinite or invalid, cannot reach what it does. Each\n// channel is 1 where the chosen value came through exactly, so this draws\n// white. A ?: that blends computes f + (t - f) * s, which rounds 0.75 away\n// beside 1e9 and is NaN beside an infinity: not white there.\n//\n// The conditions are comparisons written in place, which is the float choice;\n// a bool local as the condition is a choice that never blended. Each value is\n// both drawn (added up to 1) and compared, so a GPU that folds one reading\n// still shows the other. How a blend fared, 15 Oct 2026: the 1e9 cases wrong\n// in SwiftShader and right on Apple's GPU, the infinity and NaN cases wrong on\n// both, on WebGL2 and WebGPU alike for an infinity and on WebGPU for NaN.\nfloat4 main() {\n bool right = uv.x > 0.5;\n bool top = uv.y > 0.5;\n // 0 everywhere, from a value the compiler cannot fold\n float zero = floor(uv.x * 0.5);\n\n // Red: a ray tracer's \"no hit\" distance beside a hit\n float t = uv.x > 0.5 ? 0.75 : 1e9;\n float r = min(saturate(t + 0.25), right && t == 0.75 || !right && t == 1e9 ? 1 : 0);\n\n // Green: the same as three components\n float3 v = uv.y > 0.5 ? float3(0.1, 0.2, 0.3) : float3(1e9, -1e9, 1e9);\n float3 vSum = saturate(abs(v) + float3(0.9, 0.8, 0.7));\n bool vSame = top && v.x == 0.1 && v.y == 0.2 && v.z == 0.3 || !top && v.x == 1e9 && v.y == -1e9 && v.z == 1e9;\n float g = min(min(vSum.x, vSum.y), min(vSum.z, vSame ? 1 : 0));\n\n // Blue: an infinity beside the chosen value. Only the finite side is\n // checked, since a GPU need not keep an infinity it chose.\n float i = uv.x > 0.5 ? 0.25 : 1 / zero;\n float b = right ? min(saturate(i + 0.75), i == 0.25 ? 1 : 0) : 1;\n\n // Alpha: NaN beside the chosen value, checked the same way\n float n = uv.y > 0.5 ? zero / zero : 0.5;\n float a = top ? 1 : min(saturate(n + 0.5), n == 0.5 ? 1 : 0);\n\n return float4(r, g, b, a);\n}\n",
|
|
313
|
+
"samples": {
|
|
314
|
+
"0": [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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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],
|
|
315
|
+
"1.25": [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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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]
|
|
316
|
+
}
|
|
317
|
+
},
|
|
309
318
|
"switch.sl": {
|
|
310
319
|
"hash": "1a535831",
|
|
311
320
|
"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",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onejs-sl",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
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
|
@@ -362,10 +362,16 @@ export function emitBody(p: Program, target: BodyTarget): Body {
|
|
|
362
362
|
case SLOP.MIX: return `lerp(${s[0]}, ${s[1]}, ${s[2]})`
|
|
363
363
|
case SLOP.STEP: return `step(${s[0]}, ${s[1]})`
|
|
364
364
|
case SLOP.SMOOTHSTEP: return `smoothstep(${s[0]}, ${s[1]}, ${s[2]})`
|
|
365
|
-
//
|
|
366
|
-
//
|
|
367
|
-
//
|
|
368
|
-
|
|
365
|
+
// A choice, never a blend: lerp(f, t, s) is f + (t - f) * s, which
|
|
366
|
+
// rounds t away beside 1e9 and is NaN beside an infinity. True from
|
|
367
|
+
// 0.5 up, as the web emitters read it. Spelled per component, so
|
|
368
|
+
// each ?: takes one bool: HLSL 2021 refuses a vector condition, and
|
|
369
|
+
// this subset compiles as Metal too.
|
|
370
|
+
case SLOP.SELECT: {
|
|
371
|
+
const part = (i: number, ch: number) => (valueAt(p.nodes, n.args[i]!).type === TYPE.FLOAT ? a[i] : `${a[i]}.${SWZ[ch]}`)
|
|
372
|
+
const pick = (ch: number) => `(${part(0, ch)} >= ${lit(0.5)} ? ${part(1, ch)} : ${part(2, ch)})`
|
|
373
|
+
return t === TYPE.FLOAT ? pick(0) : ctor(t, Array.from({ length: t }, (_, ch) => pick(ch)))
|
|
374
|
+
}
|
|
369
375
|
|
|
370
376
|
case SLOP.HSV2RGB: return `${helper("sl_hsv2rgb")}(${a[0]})`
|
|
371
377
|
case SLOP.NOISE: return `${helper("sl_valueNoise")}(${a[0]})`
|
package/src/web.ts
CHANGED
|
@@ -259,11 +259,15 @@ function emitWeb(p: Program, lang: WebLanguage): string {
|
|
|
259
259
|
case SLOP.MIX: return `mix(${s[0]}, ${s[1]}, ${s[2]})`
|
|
260
260
|
case SLOP.STEP: return `step(${s[0]}, ${s[1]})`
|
|
261
261
|
case SLOP.SMOOTHSTEP: smoothsteps.add(t); return `sl_smoothstep${t}(${s[0]}, ${s[1]}, ${s[2]})`
|
|
262
|
-
//
|
|
263
|
-
//
|
|
262
|
+
// A choice, never a blend. mix(f, t, s) is f + (t - f) * s, which
|
|
263
|
+
// rounds t away beside 1e9 and is NaN beside an infinity, so the
|
|
264
|
+
// side not chosen reached the one that was. The condition holds
|
|
265
|
+
// from 0.5 up, as the step it replaces did, and a NaN condition
|
|
266
|
+
// picks the false side, as the HLSL emitter's does. A bool vector
|
|
267
|
+
// makes GLSL's mix choose rather than blend.
|
|
264
268
|
case SLOP.SELECT: {
|
|
265
|
-
const
|
|
266
|
-
return `
|
|
269
|
+
const on = t === 1 ? `(${s[0]} >= ${lit(0.5)})` : W ? `(${s[0]} >= ${k(0.5, t)})` : `greaterThanEqual(${s[0]}, ${k(0.5, t)})`
|
|
270
|
+
return W ? `select(${s[2]}, ${s[1]}, ${on})` : t === 1 ? `(${on} ? ${s[1]} : ${s[2]})` : `mix(${s[2]}, ${s[1]}, ${on})`
|
|
267
271
|
}
|
|
268
272
|
|
|
269
273
|
case SLOP.HSV2RGB: return `${lib("sl_hsv2rgb")}(${a[0]})`
|