ugly-game 0.15.13 → 0.15.14

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.
Files changed (2) hide show
  1. package/dist/gpuShadow.js +36 -1
  2. package/package.json +1 -1
package/dist/gpuShadow.js CHANGED
@@ -1662,7 +1662,28 @@ fn faceVec(code: f32) -> vec3<f32> {
1662
1662
  // wedges once already.
1663
1663
  if (BEV_ROLE[vi] == ${ROLE_BASE}.0) {
1664
1664
  let gb = baseOwner(mask, sharp);
1665
- if (length(gb) > 0.5) { home = -gb; }
1665
+ if (length(gb) > 0.5) {
1666
+ home = -gb; // the TEXTURE is the flat surface's, which is what the patch is mostly made of
1667
+ // …but the NORMAL has to wrap with the geometry: it runs from the surface, over the fillet's
1668
+ // crest, onto the block's two walls. One flat normal across all of it is the same mistake the
1669
+ // band just made, on a patch that turns through 90°.
1670
+ let hb = -gb;
1671
+ let ipb = -sign(sharp) * (vec3(1.0, 1.0, 1.0) - abs(gb));
1672
+ var b1 = vec3(0.0, 0.0, 0.0);
1673
+ var b2 = vec3(0.0, 0.0, 0.0);
1674
+ if (abs(gb.x) > 0.5) { b1 = vec3(0.0, ipb.y, 0.0); b2 = vec3(0.0, 0.0, ipb.z); }
1675
+ else if (abs(gb.y) > 0.5) { b1 = vec3(ipb.x, 0.0, 0.0); b2 = vec3(0.0, 0.0, ipb.z); }
1676
+ else { b1 = vec3(ipb.x, 0.0, 0.0); b2 = vec3(0.0, ipb.y, 0.0); }
1677
+ var fa2 = b1;
1678
+ var fb2 = b2;
1679
+ if (dot(cross(b1, b2), hb) < 0.0) { fa2 = b2; fb2 = b1; }
1680
+ let ib = i32(BEV_AXIS[vi].x + 0.5);
1681
+ if (ib == 1) { shade = normalize(hb + fb2); } // the crest, fb side
1682
+ else if (ib == 2) { shade = fb2; } // on the block's wall
1683
+ else if (ib == 3) { shade = fa2; } // …and the other wall
1684
+ else if (ib == 4) { shade = normalize(hb + fa2); } // the crest, fa side
1685
+ else { shade = hb; } // the two feet, flat on the surface
1686
+ }
1666
1687
  }
1667
1688
  let local = bevelPos(mask, sharp, home, cam.eye.w, BEV_ROLE[vi], BEV_AXIS[vi], cam.csm.z);
1668
1689
  let world = inst.pos.xyz + qrot(inst.rot, local * inst.scl.xyz);
@@ -1680,6 +1701,20 @@ fn faceVec(code: f32) -> vec3<f32> {
1680
1701
  // curve through the groove. objN stays home, so the texture still belongs to the face it grew from.
1681
1702
  var shade = home;
1682
1703
  if (BEV_ROLE[vi] == ${ROLE_FMID}.0) { shade = normalize(home - BEV_AXIS[vi]); }
1704
+ // ⚠️ A BAND'S NORMAL SWEEPS ACROSS THE STRIP. That sweep is the only reason a flat 45° chamfer
1705
+ // reads as a cylinder — the geometry is a plane and the shading is a curve. It used to happen for
1706
+ // free, because the quad's two long edges carried different home faces; subdividing the band
1707
+ // gave every vertex the OWNING face so the texture would stay put, and with it every rounded edge
1708
+ // in the world went flat. Reported as "the shading is way off", and it was.
1709
+ //
1710
+ // Rotate from the owning face to the partner across the arc. At step 0 and BEVEL_SEG this is
1711
+ // exactly the two normals the old quad carried, so at one segment nothing changes.
1712
+ if (BEV_ROLE[vi] == ${ROLE_BAND}.0) {
1713
+ let pb = sign(BEV_AXIS[vi]);
1714
+ let stb = round(max(max(abs(BEV_AXIS[vi].x), abs(BEV_AXIS[vi].y)), abs(BEV_AXIS[vi].z))) - 1.0;
1715
+ let thb = (stb / ${BEVEL_SEG}.0) * 1.5707963267948966;
1716
+ shade = normalize(home * cos(thb) + pb * sin(thb));
1717
+ }
1683
1718
  // ⚠️ A SUBDIVIDED FACET SHADES AS THE SPHERE IT IS. Its vertices carry a face normal for the
1684
1719
  // TEXTURE, and at one segment those three normals sweeping across one triangle is what made a flat
1685
1720
  // chamfer corner read round. Once the patch is a real octant, the honest normal is the sphere's —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.15.13",
3
+ "version": "0.15.14",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {