ugly-game 0.13.0 → 0.13.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/dist/assets/gpuProps.d.ts +13 -0
- package/dist/assets/gpuProps.js +4 -4
- package/package.json +9 -10
|
@@ -65,6 +65,19 @@ export interface PropDeform {
|
|
|
65
65
|
yaw?: number;
|
|
66
66
|
/** Multiplied into vertex colour; gives a within-species value spread. */
|
|
67
67
|
valueJitter?: number;
|
|
68
|
+
/**
|
|
69
|
+
* How much this instance responds to wind. 1 (the default) sways; 0 is rigid.
|
|
70
|
+
*
|
|
71
|
+
* Sway used to be a purely global uniform, which meant it reached EVERY prop — a boulder in a
|
|
72
|
+
* forest swayed exactly as readily as the trees around it. Measured on all-mine-sky's real
|
|
73
|
+
* placement across 313 windy worlds, the worst case was 48 cm of travel on a 3.8 m mineral ridge,
|
|
74
|
+
* which is not a subtlety. Whether a thing bends in the wind is a property of the THING, so it
|
|
75
|
+
* belongs per instance and not in the world uniform.
|
|
76
|
+
*
|
|
77
|
+
* Defaults to 1 so existing callers are unaffected — and callers that never set `windAmp` have no
|
|
78
|
+
* sway at all either way.
|
|
79
|
+
*/
|
|
80
|
+
sway?: number;
|
|
68
81
|
}
|
|
69
82
|
export interface PropInstance {
|
|
70
83
|
model: number;
|
package/dist/assets/gpuProps.js
CHANGED
|
@@ -19,7 +19,7 @@ struct U { mvp: mat4x4<f32>, lightVP: mat4x4<f32>, sun: vec4<f32>, sunCol: vec4<
|
|
|
19
19
|
// measured, that is the difference between a forest and a slideshow.
|
|
20
20
|
// d0 = (heightScale, girth, taper, 1/sourceHeight)
|
|
21
21
|
// d1 = (bend, bendDir, twist, droop)
|
|
22
|
-
// d2 = (yaw, valueJitter, 1/halfWidth,
|
|
22
|
+
// d2 = (yaw, valueJitter, 1/halfWidth, swayScale)
|
|
23
23
|
struct Inst { m: mat4x4<f32>, d0: vec4<f32>, d1: vec4<f32>, d2: vec4<f32> };
|
|
24
24
|
@group(0) @binding(1) var<storage,read> models: array<Inst>;
|
|
25
25
|
@group(2) @binding(0) var albedoTex: texture_2d<f32>;
|
|
@@ -96,7 +96,7 @@ fn deformNormal(n: vec3<f32>, py: f32, d0: vec4<f32>, d1: vec4<f32>, d2: vec4<f3
|
|
|
96
96
|
var world = (m * vec4(lp, 1.0)).xyz;
|
|
97
97
|
let upv = normalize((m * vec4(0.0, 1.0, 0.0, 0.0)).xyz);
|
|
98
98
|
let sc = length(m[0].xyz);
|
|
99
|
-
world = sway(lp, world, upv, sc);
|
|
99
|
+
world = sway(lp, world, upv, sc * inst.d2.w);
|
|
100
100
|
var o: VO; o.pos = u.mvp * vec4(world, 1.0); o.world = world; o.n = (m * vec4(ln, 0.0)).xyz;
|
|
101
101
|
o.c = col * inst.d2.y; o.l = lp; o.uv = uv; return o;
|
|
102
102
|
}
|
|
@@ -241,7 +241,7 @@ fn deformLocal(p: vec3<f32>, d0: vec4<f32>, d1: vec4<f32>, d2: vec4<f32>) -> vec
|
|
|
241
241
|
let h = max(dp.y, 0.0);
|
|
242
242
|
let stiff = pow(min(h * 0.22, 1.0), 1.6);
|
|
243
243
|
let ph = o.wind.w + dot(world.xz, vec2(0.13, 0.17));
|
|
244
|
-
let a = o.wind.z * stiff * length(m[0].xyz);
|
|
244
|
+
let a = o.wind.z * stiff * length(m[0].xyz) * inst.d2.w;
|
|
245
245
|
var wd = vec3(o.wind.x, 0.0, o.wind.y);
|
|
246
246
|
wd = normalize(wd - upv * dot(wd, upv));
|
|
247
247
|
world = world + wd * (a * (sin(ph) + 0.35 * sin(ph * 2.7 + h)));
|
|
@@ -682,7 +682,7 @@ function writeDeform(out, o, d, e) {
|
|
|
682
682
|
out[o + 8] = d?.yaw ?? 0;
|
|
683
683
|
out[o + 9] = d?.valueJitter ?? 1;
|
|
684
684
|
out[o + 10] = e.invHalfW;
|
|
685
|
-
out[o + 11] =
|
|
685
|
+
out[o + 11] = d?.sway ?? 1;
|
|
686
686
|
}
|
|
687
687
|
// column-major identity mat4, used for lightVP when shadow-receive is off
|
|
688
688
|
const IDENTITY4 = new Float32Array([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugly-game",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -15,14 +15,6 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"preinstall": "npx only-allow pnpm",
|
|
20
|
-
"build": "tsc -p tsconfig.json",
|
|
21
|
-
"lint": "ugly-app lint",
|
|
22
|
-
"lint:fix": "ugly-app lint --fix",
|
|
23
|
-
"pretty": "prettier --write .",
|
|
24
|
-
"prepublishOnly": "pnpm run pretty && ugly-app lint && tsc -p tsconfig.json"
|
|
25
|
-
},
|
|
26
18
|
"dependencies": {
|
|
27
19
|
"meshoptimizer": "^1.2.0"
|
|
28
20
|
},
|
|
@@ -35,5 +27,12 @@
|
|
|
35
27
|
"@webgpu/types": "^0.1.40",
|
|
36
28
|
"prettier": "^3.9.5",
|
|
37
29
|
"ugly-app": "^0.1.841"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"preinstall": "npx only-allow pnpm",
|
|
33
|
+
"build": "tsc -p tsconfig.json",
|
|
34
|
+
"lint": "ugly-app lint",
|
|
35
|
+
"lint:fix": "ugly-app lint --fix",
|
|
36
|
+
"pretty": "prettier --write ."
|
|
38
37
|
}
|
|
39
|
-
}
|
|
38
|
+
}
|