ugly-game 0.14.32 → 0.14.34

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.
@@ -82,6 +82,10 @@ export const CROWD_MATERIAL_COUNT = 5;
82
82
  */
83
83
  export const REFRACTING_MATERIALS = new Set([
84
84
  CROWD_MATERIALS.glass,
85
+ // ⚠️ METAL TOO, since it became liquid. It reads the same scene copy along the REFLECTED ray
86
+ // instead of the refracted one — a mirror rather than a window — and a row left out of this set
87
+ // gets the 1×1 dummy bound and silently reflects nothing at all.
88
+ CROWD_MATERIALS.metal,
85
89
  ]);
86
90
  // ─────────────────────────────────────────────────────────────────────────────
87
91
  // PURE ARITHMETIC. Everything below this line down to the WGSL is a plain function over plain
@@ -920,7 +924,10 @@ const DETAIL_STRENGTH: f32 = 0.35;
920
924
  const ENV_SKY: f32 = 1.7;
921
925
  // And how much DARKER the faked ground is. Both ends are forced apart on purpose — see the note in fs
922
926
  // about an overcast scene where the ambient and the fog tint are the same colour.
923
- const ENV_GROUND: f32 = 0.3;
927
+ // ⚠️ 0.55, not 0.3. STAINLESS is not a dark metal — it sits around the middle of the range and gets
928
+ // its drama from what it reflects, not from going near-black where it faces away from the sky. At 0.3
929
+ // the shadowed sides crushed almost to black, which reads as gunmetal or cast iron.
930
+ const ENV_GROUND: f32 = 0.55;
924
931
  // ⚠️ A DELIBERATE MIP BIAS on the material texture only, and it is what lets a dense pattern actually
925
932
  // be seen. The gradient handed to textureSampleGrad is what picks the mip, so shrinking it selects a
926
933
  // SHARPER level than the footprint strictly warrants. Without it the grain hit a hard ceiling: 32
@@ -930,6 +937,9 @@ const ENV_GROUND: f32 = 0.3;
930
937
  // The cost is some shimmer on a distant character. That is the right trade here — the crowd drops to
931
938
  // coarser rungs with distance anyway, and an invisible material is a worse defect than a busy one.
932
939
  const MIP_SHARPEN: f32 = 0.55;
940
+ // How much of a mirror material is the REFLECTED WORLD rather than its own shaded surface. Mercury is
941
+ // almost entirely the former — that is the whole read.
942
+ const MIRROR_MIX: f32 = 0.88;
933
943
  // ⚠️ 1/MEAN (0.4615), NOT 1/p99, and getting that wrong is what made every desaturating material
934
944
  // look bad for three rounds. This gain feeds a MULTIPLICATIVE detail map, so what matters is that it
935
945
  // averages 1.0 - leaving the material's own colour and contrast alone while still modulating it.
@@ -964,7 +974,7 @@ const MIP_SHARPEN: f32 = 0.55;
964
974
  const MATS = array<vec4f, 15>(
965
975
  vec4f(0.00, 1.0, 0.00, 0.0), vec4f(0.00, -1.0, 1.000, 0.0), vec4f(0.00, 0.000, 0.0, 0.0),
966
976
  vec4f(0.35, 64.0, 0.50, 0.0), vec4f(0.60, -1.0, 1.000, 0.0), vec4f(0.00, 0.000, 0.0, 0.0),
967
- vec4f(0.90, 40.0, 0.80, 1.0), vec4f(1.00, 0.0, 0.120, 1.0), vec4f(0.00, 0.000, 0.0, 0.0),
977
+ vec4f(1.00, 220.0, 1.00, 1.0), vec4f(1.00, -1.0, 1.000, 0.0), vec4f(0.00, 0.000, 0.075, 0.0),
968
978
  vec4f(0.90, 256.0, 1.00, 0.0), vec4f(1.00, -1.0, 1.000, 0.0), vec4f(1.00, 0.045, 0.0, 0.0),
969
979
  vec4f(0.08, 16.0, 0.15, 0.0), vec4f(1.00, 1.0, 0.120, 1.0), vec4f(0.00, 0.000, 0.0, 0.0),
970
980
  );
@@ -1162,6 +1172,31 @@ fn cylindrical(layer: i32, p: vec3f, dx: vec3f, dy: vec3f) -> vec3f {
1162
1172
  var alpha = clamp(mix(i.tint.w, 1.0, c.x * rim), 0.0, 1.0);
1163
1173
  var outCol = lit;
1164
1174
 
1175
+ // ── SCREEN-SPACE REFLECTION — liquid metal ────────────────────────────────
1176
+ //
1177
+ // ⚠️ GATED ON c.z, which is zero on every row but metal, so nothing else reaches the sample. The
1178
+ // same scene copy glass already needed, read along the REFLECTED ray instead of the surface normal
1179
+ // and composited opaquely — mercury is a mirror, not a window.
1180
+ //
1181
+ // What makes liquid metal read as liquid is that almost all of what you see is the WORLD, not the
1182
+ // surface. So the reflection is mixed in near-fully and the shaded term survives only as a floor,
1183
+ // rather than the other way round.
1184
+ if (c.z > 0.0 && u.csm.w > 0.5) {
1185
+ let vp = vec2f(max(u.csm.y, 1.0), max(u.csm.z, 1.0));
1186
+ let here = i.pos.xy / vp;
1187
+ // The REFLECTED ray's heading on screen. Same normalize-then-scale discipline the refraction
1188
+ // path needed: a clip-space direction has no meaningful magnitude of its own.
1189
+ let rrRaw = (u.viewProj * vec4f(rdir, 0.0)).xy;
1190
+ let rrLen = length(rrRaw);
1191
+ let rr = select(vec2f(0.0), rrRaw / rrLen, rrLen > 1e-6);
1192
+ let ruv = clamp(here + vec2f(rr.x, -rr.y) * c.z, vec2f(0.0), vec2f(1.0));
1193
+ let mirror = textureSampleLevel(sceneTex, skinSamp, ruv, 0.0).rgb;
1194
+ // Tinted by the metal's own colour, and brightened at grazing angles — a mirror reflects nearly
1195
+ // everything head-on and effectively all of it at the rim.
1196
+ let refl = mirror * base * (1.0 + fres);
1197
+ outCol = mix(lit, refl, MIRROR_MIX) + spec;
1198
+ }
1199
+
1165
1200
  // ── REFRACTION ────────────────────────────────────────────────────────────
1166
1201
  //
1167
1202
  // ⚠️ GATED ON c.y, WHICH IS ZERO ON EVERY ROW BUT GLASS. Nothing else reaches the sample, so a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.14.32",
3
+ "version": "0.14.34",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {