ugly-game 0.14.19 → 0.14.20
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/dist/assets/gpuCrowd.js +64 -13
- package/package.json +1 -1
package/dist/assets/gpuCrowd.js
CHANGED
|
@@ -901,17 +901,22 @@ const LUMA_GAIN: f32 = 1.2428;
|
|
|
901
901
|
//
|
|
902
902
|
// exp and scale are written as 1 on the rows that do not use them: a WGSL const array has no empty
|
|
903
903
|
// cell, and pow(0, 0) is a value nobody should have to reason about.
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
vec4f(0.
|
|
908
|
-
vec4f(0.
|
|
909
|
-
vec4f(0.
|
|
904
|
+
// b.w is the PROJECTION MODE for the material texture: 0 = triplanar, 1 = cylindrical about the
|
|
905
|
+
// body's long axis. c.x is how far FRESNEL drives the output ALPHA - see the glass note in fs.
|
|
906
|
+
const MATS = array<vec4f, 15>(
|
|
907
|
+
vec4f(0.00, 1.0, 0.00, 0.0), vec4f(0.00, -1.0, 1.000, 0.0), vec4f(0.00, 0.0, 0.0, 0.0),
|
|
908
|
+
vec4f(0.35, 64.0, 0.50, 0.0), vec4f(0.60, -1.0, 1.000, 0.0), vec4f(0.00, 0.0, 0.0, 0.0),
|
|
909
|
+
vec4f(0.90, 128.0, 0.80, 1.0), vec4f(1.00, 0.0, 0.333, 0.0), vec4f(0.00, 0.0, 0.0, 0.0),
|
|
910
|
+
vec4f(0.90, 256.0, 1.00, 0.0), vec4f(1.00, -1.0, 1.000, 0.0), vec4f(1.00, 0.0, 0.0, 0.0),
|
|
911
|
+
vec4f(0.08, 16.0, 0.15, 0.0), vec4f(1.00, 1.0, 0.300, 1.0), vec4f(0.00, 0.0, 0.0, 0.0),
|
|
910
912
|
);
|
|
911
913
|
// ⚠️ Wood's tile scale is 0.22, not 0.5, and that was set by LOOKING. A shipped human stands ~16.6
|
|
912
914
|
// kit units, so 0.5 repeats the grain about eight times head to foot — fine enough that at any
|
|
913
915
|
// normal camera distance it averages into a flat tan and the character reads as bare skin. 0.22 is
|
|
914
|
-
// closer to four repeats, which is a plank rather than a veneer.
|
|
916
|
+
// closer to four repeats, which is a plank rather than a veneer. It then moved again to 0.30 when
|
|
917
|
+
// wood went CYLINDRICAL: the scale now multiplies a RADIUS rather than a linear coordinate, and a
|
|
918
|
+
// torso is only ~1.5 kit units thick, so the value that gave four bands across a body gave almost
|
|
919
|
+
// no variation at all across its radius and the rings disappeared.
|
|
915
920
|
fn luma(c: vec3f) -> f32 { return dot(c, vec3f(0.2126, 0.7152, 0.0722)); }
|
|
916
921
|
// TRIPLANAR: three samples of the same tiling map, blended by the bind-space normal.
|
|
917
922
|
//
|
|
@@ -937,9 +942,35 @@ fn triplanar(layer: i32, p: vec3f, dx: vec3f, dy: vec3f, n: vec3f) -> vec3f {
|
|
|
937
942
|
let z = textureSampleGrad(matTex, skinSamp, p.xy, layer, dx.xy, dy.xy).rgb;
|
|
938
943
|
return x * w.x + y * w.y + z * w.z;
|
|
939
944
|
}
|
|
945
|
+
// CYLINDRICAL, about the body's own long axis - the projection a thing CARVED FROM A LOG needs.
|
|
946
|
+
//
|
|
947
|
+
// ⚠️ Triplanar is wrong for wood, and it looked it. A 2D tile whose rings run along texture-V maps
|
|
948
|
+
// V to HEIGHT on a chest (the +Z plane wins there), so the rings came out as horizontal bands
|
|
949
|
+
// stacked up the torso - a figure made of discs - and then flipped direction on the arms, where the
|
|
950
|
+
// +X plane wins and V maps to depth instead. Direction that changes with which way a surface
|
|
951
|
+
// happens to face is the one thing a grain must never do.
|
|
952
|
+
//
|
|
953
|
+
// Radius from the axis drives the RINGS and height drives the FIBRE, so a growth ring is a shell
|
|
954
|
+
// around the trunk and the fibre runs the length of it, exactly as in the log the figure came from.
|
|
955
|
+
// Same bind-space trick the hair's uvs2 uses, and for the same reason.
|
|
956
|
+
fn cylindrical(layer: i32, p: vec3f, dx: vec3f, dy: vec3f) -> vec3f {
|
|
957
|
+
let r = length(p.xz);
|
|
958
|
+
// ⚠️ Gradients carried through by the chain rule rather than dropped. d(r)/dx is the radial
|
|
959
|
+
// direction dotted with the position derivative; without it this needs implicit derivatives and
|
|
960
|
+
// is back in the uniform-control-flow trap textureSampleGrad exists to avoid.
|
|
961
|
+
let radial = select(vec2f(1.0, 0.0), p.xz / max(r, 1e-6), r > 1e-6);
|
|
962
|
+
let drx = dot(dx.xz, radial);
|
|
963
|
+
let dry = dot(dy.xz, radial);
|
|
964
|
+
return textureSampleGrad(
|
|
965
|
+
matTex, skinSamp,
|
|
966
|
+
vec2f(p.y, r), layer,
|
|
967
|
+
vec2f(dx.y, drx), vec2f(dy.y, dry),
|
|
968
|
+
).rgb;
|
|
969
|
+
}
|
|
940
970
|
@fragment fn fs(i: VOut) -> @location(0) vec4f {
|
|
941
|
-
let a = MATS[i.mat *
|
|
942
|
-
let b = MATS[i.mat *
|
|
971
|
+
let a = MATS[i.mat * 3u];
|
|
972
|
+
let b = MATS[i.mat * 3u + 1u];
|
|
973
|
+
let c = MATS[i.mat * 3u + 2u];
|
|
943
974
|
let n = normalize(i.n);
|
|
944
975
|
let l = -normalize(u.sun.xyz);
|
|
945
976
|
let d = clamp(dot(n, l), 0.0, 1.0);
|
|
@@ -970,7 +1001,13 @@ fn triplanar(layer: i32, p: vec3f, dx: vec3f, dy: vec3f, n: vec3f) -> vec3f {
|
|
|
970
1001
|
let crl = length(cr);
|
|
971
1002
|
let bn = select(vec3f(0.0, 0.0, 1.0), cr / crl, crl > 1e-20);
|
|
972
1003
|
var matC = vec3f(1.0);
|
|
973
|
-
if (i32(b.y) >= 0) {
|
|
1004
|
+
if (i32(b.y) >= 0) {
|
|
1005
|
+
if (b.w > 0.5) {
|
|
1006
|
+
matC = cylindrical(i32(b.y), i.rest * b.z, rdx * b.z, rdy * b.z);
|
|
1007
|
+
} else {
|
|
1008
|
+
matC = triplanar(i32(b.y), i.rest * b.z, rdx * b.z, rdy * b.z, bn);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
974
1011
|
let base = detail * matC * i.tint.rgb;
|
|
975
1012
|
|
|
976
1013
|
let v = normalize(u.cam.xyz - i.world);
|
|
@@ -1004,9 +1041,23 @@ fn triplanar(layer: i32, p: vec3f, dx: vec3f, dy: vec3f, n: vec3f) -> vec3f {
|
|
|
1004
1041
|
|
|
1005
1042
|
let dist = length(i.world - u.cam.xyz);
|
|
1006
1043
|
let f = clamp(1.0 - exp(-dist * u.fog.w), 0.0, 1.0);
|
|
1007
|
-
//
|
|
1008
|
-
//
|
|
1009
|
-
|
|
1044
|
+
// ⚠️ GLASS GETS ITS ALPHA FROM FRESNEL, and a flat alpha is why the first cut read as a ghost
|
|
1045
|
+
// rather than as glass. A sheet of glass is nearly CLEAR face-on and nearly OPAQUE at a grazing
|
|
1046
|
+
// angle; that falloff is most of what the eye uses to recognise the material, and with a constant
|
|
1047
|
+
// 0.35 everywhere the body simply faded out evenly and disappeared into the grass.
|
|
1048
|
+
//
|
|
1049
|
+
// The raw Schlick term is reused rather than recomputed - fres above is already
|
|
1050
|
+
// fresnel x pow(1 - n.v, 5), so dividing out the strength recovers the geometric part.
|
|
1051
|
+
//
|
|
1052
|
+
// ⚠️ NOT refraction. Nothing here bends what is behind the body: this pass composites into the
|
|
1053
|
+
// scene colour with loadOp 'load' and never receives a sampleable copy of it, so there is nothing
|
|
1054
|
+
// to distort. A rim is what is reachable without that copy.
|
|
1055
|
+
//
|
|
1056
|
+
// c.x is 0 for every other row, so alpha is exactly tint.w for them - and material 0 is
|
|
1057
|
+
// untouched, which is the invariant the whole table is built around.
|
|
1058
|
+
let rim = select(0.0, fres / max(a.z, 1e-4), a.z > 0.0);
|
|
1059
|
+
let alpha = clamp(mix(i.tint.w, 1.0, c.x * rim), 0.0, 1.0);
|
|
1060
|
+
return vec4f(mix(lit, u.fog.xyz, f), alpha);
|
|
1010
1061
|
}`;
|
|
1011
1062
|
const INITIAL_MERGE_ENTRIES = 4096;
|
|
1012
1063
|
export class GpuCrowdRenderer {
|