reze-engine 0.60.4 → 0.61.0
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/_dbg-loader.mjs +1100 -0
- package/dist/engine.d.ts +121 -5
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +284 -19
- package/dist/graph/compile.d.ts.map +1 -1
- package/dist/graph/compile.js +4 -1
- package/dist/graph/registry.d.ts.map +1 -1
- package/dist/graph/registry.js +14 -2
- package/dist/graph/slots.d.ts +1 -1
- package/dist/graph/slots.d.ts.map +1 -1
- package/dist/graph/slots.js +19 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/physics-debug.d.ts +30 -0
- package/dist/physics-debug.d.ts.map +1 -0
- package/dist/physics-debug.js +526 -0
- package/dist/shaders/lights.d.ts.map +1 -1
- package/dist/shaders/lights.js +19 -0
- package/dist/shaders/materials/body.d.ts +2 -0
- package/dist/shaders/materials/body.d.ts.map +1 -0
- package/dist/shaders/materials/body.js +95 -0
- package/dist/shaders/materials/cloth_rough.d.ts +2 -0
- package/dist/shaders/materials/cloth_rough.d.ts.map +1 -0
- package/dist/shaders/materials/cloth_rough.js +69 -0
- package/dist/shaders/materials/cloth_smooth.d.ts +2 -0
- package/dist/shaders/materials/cloth_smooth.d.ts.map +1 -0
- package/dist/shaders/materials/cloth_smooth.js +61 -0
- package/dist/shaders/materials/common.d.ts.map +1 -1
- package/dist/shaders/materials/common.js +47 -0
- package/dist/shaders/materials/default.d.ts +2 -0
- package/dist/shaders/materials/default.d.ts.map +1 -0
- package/dist/shaders/materials/default.js +43 -0
- package/dist/shaders/materials/eye.d.ts +2 -0
- package/dist/shaders/materials/eye.d.ts.map +1 -0
- package/dist/shaders/materials/eye.js +60 -0
- package/dist/shaders/materials/face.d.ts +2 -0
- package/dist/shaders/materials/face.d.ts.map +1 -0
- package/dist/shaders/materials/face.js +95 -0
- package/dist/shaders/materials/hair.d.ts +2 -0
- package/dist/shaders/materials/hair.d.ts.map +1 -0
- package/dist/shaders/materials/hair.js +90 -0
- package/dist/shaders/materials/metal.d.ts +2 -0
- package/dist/shaders/materials/metal.d.ts.map +1 -0
- package/dist/shaders/materials/metal.js +77 -0
- package/dist/shaders/materials/mmd_classic.d.ts +2 -0
- package/dist/shaders/materials/mmd_classic.d.ts.map +1 -0
- package/dist/shaders/materials/mmd_classic.js +66 -0
- package/dist/shaders/materials/nodes.d.ts +1 -1
- package/dist/shaders/materials/nodes.d.ts.map +1 -1
- package/dist/shaders/materials/nodes.js +110 -23
- package/dist/shaders/materials/stockings.d.ts +2 -0
- package/dist/shaders/materials/stockings.d.ts.map +1 -0
- package/dist/shaders/materials/stockings.js +122 -0
- package/dist/shaders/passes/composite.d.ts +1 -1
- package/dist/shaders/passes/composite.d.ts.map +1 -1
- package/dist/shaders/passes/composite.js +34 -2
- package/dist/shaders/passes/physics-debug.d.ts +2 -0
- package/dist/shaders/passes/physics-debug.d.ts.map +1 -0
- package/dist/shaders/passes/physics-debug.js +69 -0
- package/dist/shaders/scene-tap.js +1 -1
- package/package.json +1 -1
- package/src/engine.ts +312 -19
- package/src/graph/compile.ts +4 -1
- package/src/graph/registry.ts +14 -2
- package/src/graph/slots.ts +20 -5
- package/src/index.ts +4 -0
- package/src/shaders/lights.ts +19 -0
- package/src/shaders/materials/common.ts +47 -0
- package/src/shaders/materials/nodes.ts +110 -23
- package/src/shaders/passes/composite.ts +34 -2
- package/src/shaders/scene-tap.ts +1 -1
- package/dist/graph/presets/pool_floor.d.ts +0 -3
- package/dist/graph/presets/pool_floor.d.ts.map +0 -1
- package/dist/graph/presets/pool_floor.js +0 -42
- package/dist/graph/presets/water.d.ts +0 -3
- package/dist/graph/presets/water.d.ts.map +0 -1
- package/dist/graph/presets/water.js +0 -31
- package/dist/physics/autofit.d.ts +0 -147
- package/dist/physics/autofit.d.ts.map +0 -1
- package/dist/physics/autofit.js +0 -501
- package/dist/shaders/passes/field-blit.d.ts +0 -26
- package/dist/shaders/passes/field-blit.d.ts.map +0 -1
- package/dist/shaders/passes/field-blit.js +0 -65
- package/dist/shaders/passes/ground-noise.d.ts +0 -7
- package/dist/shaders/passes/ground-noise.d.ts.map +0 -1
- package/dist/shaders/passes/ground-noise.js +0 -88
- package/dist/shaders/passes/sim.d.ts +0 -34
- package/dist/shaders/passes/sim.d.ts.map +0 -1
- package/dist/shaders/passes/sim.js +0 -169
- package/dist/shaders/score-api.d.ts +0 -10
- package/dist/shaders/score-api.d.ts.map +0 -1
- package/dist/shaders/score-api.js +0 -114
- package/dist/shaders/shadow-api.d.ts +0 -29
- package/dist/shaders/shadow-api.d.ts.map +0 -1
- package/dist/shaders/shadow-api.js +0 -112
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,GACd,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAIzC,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,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,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,GACd,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAI3F,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,SAAS,GACf,MAAM,WAAW,CAAA;AAElB;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACnF,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RezePhysics } from "./physics";
|
|
2
|
+
export declare class PhysicsDebugRenderer {
|
|
3
|
+
private device;
|
|
4
|
+
private bindGroup;
|
|
5
|
+
private wirePipelineSphere;
|
|
6
|
+
private wirePipelineBox;
|
|
7
|
+
private wirePipelineCapsule;
|
|
8
|
+
private wireSphereBuffer;
|
|
9
|
+
private wireBoxBuffer;
|
|
10
|
+
private wireCapsuleBuffer;
|
|
11
|
+
private wireSphereCount;
|
|
12
|
+
private wireBoxCount;
|
|
13
|
+
private wireCapsuleCount;
|
|
14
|
+
private solidPipelineSphere;
|
|
15
|
+
private solidPipelineBox;
|
|
16
|
+
private solidPipelineCapsule;
|
|
17
|
+
private solidSphereBuffer;
|
|
18
|
+
private solidBoxBuffer;
|
|
19
|
+
private solidCapsuleBuffer;
|
|
20
|
+
private solidSphereCount;
|
|
21
|
+
private solidBoxCount;
|
|
22
|
+
private solidCapsuleCount;
|
|
23
|
+
private instanceBuffer;
|
|
24
|
+
private instanceData;
|
|
25
|
+
private instanceCapacity;
|
|
26
|
+
constructor(device: GPUDevice, cameraUniformBuffer: GPUBuffer, presentationFormat: GPUTextureFormat);
|
|
27
|
+
render(pass: GPURenderPassEncoder, physics: RezePhysics): void;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=physics-debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics-debug.d.ts","sourceRoot":"","sources":["../src/physics-debug.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAmB5C,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,SAAS,CAAc;IAG/B,OAAO,CAAC,kBAAkB,CAAmB;IAC7C,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,mBAAmB,CAAmB;IAC9C,OAAO,CAAC,gBAAgB,CAAW;IACnC,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,iBAAiB,CAAW;IACpC,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,gBAAgB,CAAQ;IAIhC,OAAO,CAAC,mBAAmB,CAAmB;IAC9C,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,oBAAoB,CAAmB;IAC/C,OAAO,CAAC,iBAAiB,CAAW;IACpC,OAAO,CAAC,cAAc,CAAW;IACjC,OAAO,CAAC,kBAAkB,CAAW;IACrC,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,iBAAiB,CAAQ;IAEjC,OAAO,CAAC,cAAc,CAAW;IACjC,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,gBAAgB,CAAQ;gBAG9B,MAAM,EAAE,SAAS,EACjB,mBAAmB,EAAE,SAAS,EAC9B,kBAAkB,EAAE,gBAAgB;IA2HtC,MAAM,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAmI9D,OAAO,IAAI,IAAI;CAShB"}
|
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
// Debug overlay drawing every rigidbody as a wireframe + semitransparent solid
|
|
2
|
+
// primitive (sphere / box / capsule), color-coded by type:
|
|
3
|
+
// yellow = static (FollowBone)
|
|
4
|
+
// cyan = kinematic
|
|
5
|
+
// red = dynamic
|
|
6
|
+
//
|
|
7
|
+
// Rendered in its own swapchain pass AFTER composite (see Engine.renderPhysicsDebug),
|
|
8
|
+
// so it sits cleanly on top of the final tonemapped image. No depth, no MSAA,
|
|
9
|
+
// no MRT, no interaction with the HDR alpha gate — bodies are always fully
|
|
10
|
+
// visible regardless of camera angle, model occlusion, or stacking. Reads body
|
|
11
|
+
// transforms straight from RezePhysics' SoA store — zero per-frame allocations.
|
|
12
|
+
import { Mat4 } from "./math";
|
|
13
|
+
import { RigidbodyShape, RigidbodyType } from "./physics";
|
|
14
|
+
import { PHYSICS_DEBUG_SHADER_WGSL } from "./shaders/passes/physics-debug";
|
|
15
|
+
const STRIDE_BYTES = 96; // 4 mat4 cols + size+pad + color = 6 vec4
|
|
16
|
+
const STRIDE_FLOATS = STRIDE_BYTES / 4;
|
|
17
|
+
// Per-instance color.alpha is the WIREFRAME alpha (1.0 for crisp edges). Solid
|
|
18
|
+
// pipelines override the SOLID_ALPHA shader constant to ~0.20 so the fill stays
|
|
19
|
+
// gentle where many bodies overlap.
|
|
20
|
+
// Hues chosen so wire+solid both read against the typical pink/grey reze studio
|
|
21
|
+
// scene background. Red [1, 0.3, 0.3] sat too close to the pink bg's hue —
|
|
22
|
+
// solid fill (α≈0.2) blended into the bg and the wire didn't separate from it.
|
|
23
|
+
// Orange-red shifts ~30° on the hue wheel, giving real chroma against pink.
|
|
24
|
+
const COLOR_STATIC = [1.0, 0.85, 0.15, 1.0]; // yellow
|
|
25
|
+
const COLOR_KINEMATIC = [0.25, 0.7, 1.0, 1.0]; // cyan-blue
|
|
26
|
+
const COLOR_DYNAMIC = [1.0, 0.35, 0.0, 1.0]; // orange-red
|
|
27
|
+
const SOLID_ALPHA = 0.2;
|
|
28
|
+
export class PhysicsDebugRenderer {
|
|
29
|
+
constructor(device, cameraUniformBuffer, presentationFormat) {
|
|
30
|
+
this.device = device;
|
|
31
|
+
const wireSphere = buildSphereWireGeometry();
|
|
32
|
+
const wireBox = buildBoxWireGeometry();
|
|
33
|
+
const wireCapsule = buildCapsuleWireGeometry();
|
|
34
|
+
this.wireSphereCount = wireSphere.length / 4;
|
|
35
|
+
this.wireBoxCount = wireBox.length / 4;
|
|
36
|
+
this.wireCapsuleCount = wireCapsule.length / 4;
|
|
37
|
+
const solidSphere = buildSphereSolidGeometry();
|
|
38
|
+
const solidBox = buildBoxSolidGeometry();
|
|
39
|
+
const solidCapsule = buildCapsuleSolidGeometry();
|
|
40
|
+
this.solidSphereCount = solidSphere.length / 4;
|
|
41
|
+
this.solidBoxCount = solidBox.length / 4;
|
|
42
|
+
this.solidCapsuleCount = solidCapsule.length / 4;
|
|
43
|
+
const upload = (label, data) => {
|
|
44
|
+
const buf = device.createBuffer({
|
|
45
|
+
label,
|
|
46
|
+
size: data.byteLength,
|
|
47
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
48
|
+
});
|
|
49
|
+
device.queue.writeBuffer(buf, 0, data.buffer, data.byteOffset, data.byteLength);
|
|
50
|
+
return buf;
|
|
51
|
+
};
|
|
52
|
+
this.wireSphereBuffer = upload("physics-debug wire sphere", wireSphere);
|
|
53
|
+
this.wireBoxBuffer = upload("physics-debug wire box", wireBox);
|
|
54
|
+
this.wireCapsuleBuffer = upload("physics-debug wire capsule", wireCapsule);
|
|
55
|
+
this.solidSphereBuffer = upload("physics-debug solid sphere", solidSphere);
|
|
56
|
+
this.solidBoxBuffer = upload("physics-debug solid box", solidBox);
|
|
57
|
+
this.solidCapsuleBuffer = upload("physics-debug solid capsule", solidCapsule);
|
|
58
|
+
this.instanceCapacity = 512;
|
|
59
|
+
this.instanceData = new Float32Array(this.instanceCapacity * STRIDE_FLOATS);
|
|
60
|
+
this.instanceBuffer = device.createBuffer({
|
|
61
|
+
label: "physics-debug instances",
|
|
62
|
+
size: this.instanceCapacity * STRIDE_BYTES,
|
|
63
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
64
|
+
});
|
|
65
|
+
const bgl = device.createBindGroupLayout({
|
|
66
|
+
label: "physics-debug bgl",
|
|
67
|
+
entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }],
|
|
68
|
+
});
|
|
69
|
+
this.bindGroup = device.createBindGroup({
|
|
70
|
+
label: "physics-debug bg",
|
|
71
|
+
layout: bgl,
|
|
72
|
+
entries: [{ binding: 0, resource: { buffer: cameraUniformBuffer } }],
|
|
73
|
+
});
|
|
74
|
+
const pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [bgl] });
|
|
75
|
+
const shader = device.createShaderModule({
|
|
76
|
+
label: "physics-debug shader",
|
|
77
|
+
code: PHYSICS_DEBUG_SHADER_WGSL,
|
|
78
|
+
});
|
|
79
|
+
const vertexBuffers = [
|
|
80
|
+
{
|
|
81
|
+
arrayStride: 16,
|
|
82
|
+
attributes: [{ shaderLocation: 0, offset: 0, format: "float32x4" }],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
arrayStride: STRIDE_BYTES,
|
|
86
|
+
stepMode: "instance",
|
|
87
|
+
attributes: [
|
|
88
|
+
{ shaderLocation: 1, offset: 0, format: "float32x4" },
|
|
89
|
+
{ shaderLocation: 2, offset: 16, format: "float32x4" },
|
|
90
|
+
{ shaderLocation: 3, offset: 32, format: "float32x4" },
|
|
91
|
+
{ shaderLocation: 4, offset: 48, format: "float32x4" },
|
|
92
|
+
{ shaderLocation: 5, offset: 64, format: "float32x4" },
|
|
93
|
+
{ shaderLocation: 6, offset: 80, format: "float32x4" },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
const targets = [
|
|
98
|
+
{
|
|
99
|
+
format: presentationFormat,
|
|
100
|
+
blend: {
|
|
101
|
+
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
102
|
+
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
const buildPipeline = (label, kind, topology, solidAlpha) => device.createRenderPipeline({
|
|
107
|
+
label,
|
|
108
|
+
layout: pipelineLayout,
|
|
109
|
+
vertex: {
|
|
110
|
+
module: shader,
|
|
111
|
+
entryPoint: "vsMain",
|
|
112
|
+
buffers: vertexBuffers,
|
|
113
|
+
constants: { SHAPE_KIND: kind },
|
|
114
|
+
},
|
|
115
|
+
fragment: {
|
|
116
|
+
module: shader,
|
|
117
|
+
entryPoint: "fsMain",
|
|
118
|
+
targets,
|
|
119
|
+
constants: { SOLID_ALPHA: solidAlpha },
|
|
120
|
+
},
|
|
121
|
+
primitive: { topology, cullMode: "none" },
|
|
122
|
+
// No depth attachment, single multisample — pass renders straight to
|
|
123
|
+
// the swapchain after composite, so the overlay sits on top of the
|
|
124
|
+
// tonemapped scene without interacting with depth/stencil/MSAA.
|
|
125
|
+
multisample: { count: 1 },
|
|
126
|
+
});
|
|
127
|
+
this.wirePipelineSphere = buildPipeline("physics-debug wire sphere", 0, "line-list", 1.0);
|
|
128
|
+
this.wirePipelineBox = buildPipeline("physics-debug wire box", 1, "line-list", 1.0);
|
|
129
|
+
this.wirePipelineCapsule = buildPipeline("physics-debug wire capsule", 2, "line-list", 1.0);
|
|
130
|
+
this.solidPipelineSphere = buildPipeline("physics-debug solid sphere", 0, "triangle-list", SOLID_ALPHA);
|
|
131
|
+
this.solidPipelineBox = buildPipeline("physics-debug solid box", 1, "triangle-list", SOLID_ALPHA);
|
|
132
|
+
this.solidPipelineCapsule = buildPipeline("physics-debug solid capsule", 2, "triangle-list", SOLID_ALPHA);
|
|
133
|
+
}
|
|
134
|
+
render(pass, physics) {
|
|
135
|
+
const rigidbodies = physics.getRigidbodies();
|
|
136
|
+
const N = rigidbodies.length;
|
|
137
|
+
if (N === 0)
|
|
138
|
+
return;
|
|
139
|
+
const store = physics.getStore();
|
|
140
|
+
const positions = store.positions;
|
|
141
|
+
const orientations = store.orientations;
|
|
142
|
+
if (N > this.instanceCapacity) {
|
|
143
|
+
this.instanceCapacity = Math.max(N, this.instanceCapacity * 2);
|
|
144
|
+
this.instanceData = new Float32Array(this.instanceCapacity * STRIDE_FLOATS);
|
|
145
|
+
this.instanceBuffer.destroy();
|
|
146
|
+
this.instanceBuffer = this.device.createBuffer({
|
|
147
|
+
label: "physics-debug instances",
|
|
148
|
+
size: this.instanceCapacity * STRIDE_BYTES,
|
|
149
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// Two passes: count per-shape, then fill packed by shape so we can issue
|
|
153
|
+
// 3 instanced draws with vertex-buffer offsets.
|
|
154
|
+
let sphereCount = 0;
|
|
155
|
+
let boxCount = 0;
|
|
156
|
+
let capsuleCount = 0;
|
|
157
|
+
for (let i = 0; i < N; i++) {
|
|
158
|
+
const s = rigidbodies[i].shape;
|
|
159
|
+
if (s === RigidbodyShape.Sphere)
|
|
160
|
+
sphereCount++;
|
|
161
|
+
else if (s === RigidbodyShape.Box)
|
|
162
|
+
boxCount++;
|
|
163
|
+
else
|
|
164
|
+
capsuleCount++;
|
|
165
|
+
}
|
|
166
|
+
const sphereOffset = 0;
|
|
167
|
+
const boxOffset = sphereCount;
|
|
168
|
+
const capsuleOffset = sphereCount + boxCount;
|
|
169
|
+
const data = this.instanceData;
|
|
170
|
+
let sIdx = sphereOffset;
|
|
171
|
+
let bIdx = boxOffset;
|
|
172
|
+
let cIdx = capsuleOffset;
|
|
173
|
+
for (let i = 0; i < N; i++) {
|
|
174
|
+
const rb = rigidbodies[i];
|
|
175
|
+
const i3 = i * 3;
|
|
176
|
+
const i4 = i * 4;
|
|
177
|
+
let slot;
|
|
178
|
+
if (rb.shape === RigidbodyShape.Sphere)
|
|
179
|
+
slot = sIdx++;
|
|
180
|
+
else if (rb.shape === RigidbodyShape.Box)
|
|
181
|
+
slot = bIdx++;
|
|
182
|
+
else
|
|
183
|
+
slot = cIdx++;
|
|
184
|
+
const dst = slot * STRIDE_FLOATS;
|
|
185
|
+
// Model matrix: rotation from quat into [dst..dst+15], then translation.
|
|
186
|
+
Mat4.fromQuatInto(orientations[i4 + 0], orientations[i4 + 1], orientations[i4 + 2], orientations[i4 + 3], data, dst);
|
|
187
|
+
data[dst + 12] = positions[i3 + 0];
|
|
188
|
+
data[dst + 13] = positions[i3 + 1];
|
|
189
|
+
data[dst + 14] = positions[i3 + 2];
|
|
190
|
+
// size + pad
|
|
191
|
+
data[dst + 16] = rb.size.x;
|
|
192
|
+
data[dst + 17] = rb.size.y;
|
|
193
|
+
data[dst + 18] = rb.size.z;
|
|
194
|
+
data[dst + 19] = 0;
|
|
195
|
+
const c = rb.type === RigidbodyType.Static
|
|
196
|
+
? COLOR_STATIC
|
|
197
|
+
: rb.type === RigidbodyType.Kinematic
|
|
198
|
+
? COLOR_KINEMATIC
|
|
199
|
+
: COLOR_DYNAMIC;
|
|
200
|
+
data[dst + 20] = c[0];
|
|
201
|
+
data[dst + 21] = c[1];
|
|
202
|
+
data[dst + 22] = c[2];
|
|
203
|
+
data[dst + 23] = c[3];
|
|
204
|
+
}
|
|
205
|
+
this.device.queue.writeBuffer(this.instanceBuffer, 0, data.buffer, data.byteOffset, N * STRIDE_BYTES);
|
|
206
|
+
pass.setBindGroup(0, this.bindGroup);
|
|
207
|
+
// Solid fills first (gentle ~20% alpha for shape ID), wireframe edges on top
|
|
208
|
+
// (95% alpha for crisp silhouette).
|
|
209
|
+
if (sphereCount > 0) {
|
|
210
|
+
const off = sphereOffset * STRIDE_BYTES;
|
|
211
|
+
const size = sphereCount * STRIDE_BYTES;
|
|
212
|
+
pass.setPipeline(this.solidPipelineSphere);
|
|
213
|
+
pass.setVertexBuffer(0, this.solidSphereBuffer);
|
|
214
|
+
pass.setVertexBuffer(1, this.instanceBuffer, off, size);
|
|
215
|
+
pass.draw(this.solidSphereCount, sphereCount);
|
|
216
|
+
pass.setPipeline(this.wirePipelineSphere);
|
|
217
|
+
pass.setVertexBuffer(0, this.wireSphereBuffer);
|
|
218
|
+
pass.setVertexBuffer(1, this.instanceBuffer, off, size);
|
|
219
|
+
pass.draw(this.wireSphereCount, sphereCount);
|
|
220
|
+
}
|
|
221
|
+
if (boxCount > 0) {
|
|
222
|
+
const off = boxOffset * STRIDE_BYTES;
|
|
223
|
+
const size = boxCount * STRIDE_BYTES;
|
|
224
|
+
pass.setPipeline(this.solidPipelineBox);
|
|
225
|
+
pass.setVertexBuffer(0, this.solidBoxBuffer);
|
|
226
|
+
pass.setVertexBuffer(1, this.instanceBuffer, off, size);
|
|
227
|
+
pass.draw(this.solidBoxCount, boxCount);
|
|
228
|
+
pass.setPipeline(this.wirePipelineBox);
|
|
229
|
+
pass.setVertexBuffer(0, this.wireBoxBuffer);
|
|
230
|
+
pass.setVertexBuffer(1, this.instanceBuffer, off, size);
|
|
231
|
+
pass.draw(this.wireBoxCount, boxCount);
|
|
232
|
+
}
|
|
233
|
+
if (capsuleCount > 0) {
|
|
234
|
+
const off = capsuleOffset * STRIDE_BYTES;
|
|
235
|
+
const size = capsuleCount * STRIDE_BYTES;
|
|
236
|
+
pass.setPipeline(this.solidPipelineCapsule);
|
|
237
|
+
pass.setVertexBuffer(0, this.solidCapsuleBuffer);
|
|
238
|
+
pass.setVertexBuffer(1, this.instanceBuffer, off, size);
|
|
239
|
+
pass.draw(this.solidCapsuleCount, capsuleCount);
|
|
240
|
+
pass.setPipeline(this.wirePipelineCapsule);
|
|
241
|
+
pass.setVertexBuffer(0, this.wireCapsuleBuffer);
|
|
242
|
+
pass.setVertexBuffer(1, this.instanceBuffer, off, size);
|
|
243
|
+
pass.draw(this.wireCapsuleCount, capsuleCount);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
destroy() {
|
|
247
|
+
this.wireSphereBuffer.destroy();
|
|
248
|
+
this.wireBoxBuffer.destroy();
|
|
249
|
+
this.wireCapsuleBuffer.destroy();
|
|
250
|
+
this.solidSphereBuffer.destroy();
|
|
251
|
+
this.solidBoxBuffer.destroy();
|
|
252
|
+
this.solidCapsuleBuffer.destroy();
|
|
253
|
+
this.instanceBuffer.destroy();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// ── Geometry builders ─────────────────────────────────────────────────────────
|
|
257
|
+
// Each vertex is vec4(unitPos.xyz, axialAnchor) packed as 4 floats.
|
|
258
|
+
function buildSphereWireGeometry() {
|
|
259
|
+
const segs = 32;
|
|
260
|
+
const out = new Float32Array(3 * segs * 2 * 4); // 3 great circles
|
|
261
|
+
let p = 0;
|
|
262
|
+
for (let plane = 0; plane < 3; plane++) {
|
|
263
|
+
for (let i = 0; i < segs; i++) {
|
|
264
|
+
const a0 = (i / segs) * Math.PI * 2;
|
|
265
|
+
const a1 = ((i + 1) / segs) * Math.PI * 2;
|
|
266
|
+
const c0 = Math.cos(a0), s0 = Math.sin(a0);
|
|
267
|
+
const c1 = Math.cos(a1), s1 = Math.sin(a1);
|
|
268
|
+
let p0x = 0, p0y = 0, p0z = 0;
|
|
269
|
+
let p1x = 0, p1y = 0, p1z = 0;
|
|
270
|
+
if (plane === 0) {
|
|
271
|
+
p0x = c0;
|
|
272
|
+
p0y = s0;
|
|
273
|
+
p1x = c1;
|
|
274
|
+
p1y = s1;
|
|
275
|
+
}
|
|
276
|
+
else if (plane === 1) {
|
|
277
|
+
p0x = c0;
|
|
278
|
+
p0z = s0;
|
|
279
|
+
p1x = c1;
|
|
280
|
+
p1z = s1;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
p0y = c0;
|
|
284
|
+
p0z = s0;
|
|
285
|
+
p1y = c1;
|
|
286
|
+
p1z = s1;
|
|
287
|
+
}
|
|
288
|
+
out[p++] = p0x;
|
|
289
|
+
out[p++] = p0y;
|
|
290
|
+
out[p++] = p0z;
|
|
291
|
+
out[p++] = 0;
|
|
292
|
+
out[p++] = p1x;
|
|
293
|
+
out[p++] = p1y;
|
|
294
|
+
out[p++] = p1z;
|
|
295
|
+
out[p++] = 0;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
function buildBoxWireGeometry() {
|
|
301
|
+
const edges = [
|
|
302
|
+
// 4 along X
|
|
303
|
+
[-1, -1, -1, +1, -1, -1], [-1, -1, +1, +1, -1, +1],
|
|
304
|
+
[-1, +1, -1, +1, +1, -1], [-1, +1, +1, +1, +1, +1],
|
|
305
|
+
// 4 along Y
|
|
306
|
+
[-1, -1, -1, -1, +1, -1], [+1, -1, -1, +1, +1, -1],
|
|
307
|
+
[-1, -1, +1, -1, +1, +1], [+1, -1, +1, +1, +1, +1],
|
|
308
|
+
// 4 along Z
|
|
309
|
+
[-1, -1, -1, -1, -1, +1], [+1, -1, -1, +1, -1, +1],
|
|
310
|
+
[-1, +1, -1, -1, +1, +1], [+1, +1, -1, +1, +1, +1],
|
|
311
|
+
];
|
|
312
|
+
const out = new Float32Array(edges.length * 2 * 4);
|
|
313
|
+
let p = 0;
|
|
314
|
+
for (const e of edges) {
|
|
315
|
+
out[p++] = e[0];
|
|
316
|
+
out[p++] = e[1];
|
|
317
|
+
out[p++] = e[2];
|
|
318
|
+
out[p++] = 0;
|
|
319
|
+
out[p++] = e[3];
|
|
320
|
+
out[p++] = e[4];
|
|
321
|
+
out[p++] = e[5];
|
|
322
|
+
out[p++] = 0;
|
|
323
|
+
}
|
|
324
|
+
return out;
|
|
325
|
+
}
|
|
326
|
+
function buildCapsuleWireGeometry() {
|
|
327
|
+
const ringSegs = 32;
|
|
328
|
+
const arcSegs = 16;
|
|
329
|
+
// 2 cap rings + 4 hemisphere arcs + 4 cylinder verticals
|
|
330
|
+
const lineCount = ringSegs * 2 + arcSegs * 4 + 4;
|
|
331
|
+
const out = new Float32Array(lineCount * 2 * 4);
|
|
332
|
+
let p = 0;
|
|
333
|
+
const push = (x, y, z, axial) => {
|
|
334
|
+
out[p++] = x;
|
|
335
|
+
out[p++] = y;
|
|
336
|
+
out[p++] = z;
|
|
337
|
+
out[p++] = axial;
|
|
338
|
+
};
|
|
339
|
+
// Top ring (axial=+1) in XZ plane
|
|
340
|
+
for (let i = 0; i < ringSegs; i++) {
|
|
341
|
+
const a0 = (i / ringSegs) * Math.PI * 2;
|
|
342
|
+
const a1 = ((i + 1) / ringSegs) * Math.PI * 2;
|
|
343
|
+
push(Math.cos(a0), 0, Math.sin(a0), +1);
|
|
344
|
+
push(Math.cos(a1), 0, Math.sin(a1), +1);
|
|
345
|
+
}
|
|
346
|
+
// Bottom ring (axial=-1)
|
|
347
|
+
for (let i = 0; i < ringSegs; i++) {
|
|
348
|
+
const a0 = (i / ringSegs) * Math.PI * 2;
|
|
349
|
+
const a1 = ((i + 1) / ringSegs) * Math.PI * 2;
|
|
350
|
+
push(Math.cos(a0), 0, Math.sin(a0), -1);
|
|
351
|
+
push(Math.cos(a1), 0, Math.sin(a1), -1);
|
|
352
|
+
}
|
|
353
|
+
// Top cap arcs in XY and YZ planes (θ ∈ [0, π], pos = (cosθ, sinθ, 0) etc.)
|
|
354
|
+
for (let i = 0; i < arcSegs; i++) {
|
|
355
|
+
const t0 = (i / arcSegs) * Math.PI;
|
|
356
|
+
const t1 = ((i + 1) / arcSegs) * Math.PI;
|
|
357
|
+
push(Math.cos(t0), Math.sin(t0), 0, +1);
|
|
358
|
+
push(Math.cos(t1), Math.sin(t1), 0, +1);
|
|
359
|
+
}
|
|
360
|
+
for (let i = 0; i < arcSegs; i++) {
|
|
361
|
+
const t0 = (i / arcSegs) * Math.PI;
|
|
362
|
+
const t1 = ((i + 1) / arcSegs) * Math.PI;
|
|
363
|
+
push(0, Math.sin(t0), Math.cos(t0), +1);
|
|
364
|
+
push(0, Math.sin(t1), Math.cos(t1), +1);
|
|
365
|
+
}
|
|
366
|
+
// Bottom cap arcs
|
|
367
|
+
for (let i = 0; i < arcSegs; i++) {
|
|
368
|
+
const t0 = (i / arcSegs) * Math.PI;
|
|
369
|
+
const t1 = ((i + 1) / arcSegs) * Math.PI;
|
|
370
|
+
push(Math.cos(t0), -Math.sin(t0), 0, -1);
|
|
371
|
+
push(Math.cos(t1), -Math.sin(t1), 0, -1);
|
|
372
|
+
}
|
|
373
|
+
for (let i = 0; i < arcSegs; i++) {
|
|
374
|
+
const t0 = (i / arcSegs) * Math.PI;
|
|
375
|
+
const t1 = ((i + 1) / arcSegs) * Math.PI;
|
|
376
|
+
push(0, -Math.sin(t0), Math.cos(t0), -1);
|
|
377
|
+
push(0, -Math.sin(t1), Math.cos(t1), -1);
|
|
378
|
+
}
|
|
379
|
+
// 4 cylinder verticals: bottom rim (axial=-1) → top rim (+1) at fixed θ
|
|
380
|
+
push(+1, 0, 0, -1);
|
|
381
|
+
push(+1, 0, 0, +1);
|
|
382
|
+
push(-1, 0, 0, -1);
|
|
383
|
+
push(-1, 0, 0, +1);
|
|
384
|
+
push(0, 0, +1, -1);
|
|
385
|
+
push(0, 0, +1, +1);
|
|
386
|
+
push(0, 0, -1, -1);
|
|
387
|
+
push(0, 0, -1, +1);
|
|
388
|
+
return out;
|
|
389
|
+
}
|
|
390
|
+
// ── Solid (triangle-list) geometry builders ─────────────────────────────────
|
|
391
|
+
// Each vertex is vec4(unitPos.xyz, axialAnchor) — same layout as wireframe.
|
|
392
|
+
// UV sphere — stacks × slices quads, each split into 2 triangles. Polar quads
|
|
393
|
+
// degenerate to triangles, which the GPU silently drops.
|
|
394
|
+
function buildSphereSolidGeometry() {
|
|
395
|
+
const stacks = 12;
|
|
396
|
+
const slices = 18;
|
|
397
|
+
const out = new Float32Array(stacks * slices * 6 * 4);
|
|
398
|
+
let p = 0;
|
|
399
|
+
const vert = (phi, theta) => {
|
|
400
|
+
out[p++] = Math.cos(phi) * Math.cos(theta);
|
|
401
|
+
out[p++] = Math.sin(phi);
|
|
402
|
+
out[p++] = Math.cos(phi) * Math.sin(theta);
|
|
403
|
+
out[p++] = 0;
|
|
404
|
+
};
|
|
405
|
+
for (let s = 0; s < stacks; s++) {
|
|
406
|
+
const phi0 = -Math.PI / 2 + (s / stacks) * Math.PI;
|
|
407
|
+
const phi1 = -Math.PI / 2 + ((s + 1) / stacks) * Math.PI;
|
|
408
|
+
for (let l = 0; l < slices; l++) {
|
|
409
|
+
const th0 = (l / slices) * Math.PI * 2;
|
|
410
|
+
const th1 = ((l + 1) / slices) * Math.PI * 2;
|
|
411
|
+
vert(phi0, th0);
|
|
412
|
+
vert(phi1, th0);
|
|
413
|
+
vert(phi1, th1);
|
|
414
|
+
vert(phi0, th0);
|
|
415
|
+
vert(phi1, th1);
|
|
416
|
+
vert(phi0, th1);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return out;
|
|
420
|
+
}
|
|
421
|
+
// 6 cube faces × 2 triangles × 3 verts = 36 verts.
|
|
422
|
+
function buildBoxSolidGeometry() {
|
|
423
|
+
const faces = [
|
|
424
|
+
// +X face
|
|
425
|
+
[+1, -1, -1, +1, +1, -1, +1, +1, +1, +1, -1, +1],
|
|
426
|
+
// -X face
|
|
427
|
+
[-1, -1, -1, -1, -1, +1, -1, +1, +1, -1, +1, -1],
|
|
428
|
+
// +Y face
|
|
429
|
+
[-1, +1, -1, -1, +1, +1, +1, +1, +1, +1, +1, -1],
|
|
430
|
+
// -Y face
|
|
431
|
+
[-1, -1, -1, +1, -1, -1, +1, -1, +1, -1, -1, +1],
|
|
432
|
+
// +Z face
|
|
433
|
+
[-1, -1, +1, +1, -1, +1, +1, +1, +1, -1, +1, +1],
|
|
434
|
+
// -Z face
|
|
435
|
+
[-1, -1, -1, -1, +1, -1, +1, +1, -1, +1, -1, -1],
|
|
436
|
+
];
|
|
437
|
+
const out = new Float32Array(faces.length * 6 * 4);
|
|
438
|
+
let p = 0;
|
|
439
|
+
const v = (x, y, z) => {
|
|
440
|
+
out[p++] = x;
|
|
441
|
+
out[p++] = y;
|
|
442
|
+
out[p++] = z;
|
|
443
|
+
out[p++] = 0;
|
|
444
|
+
};
|
|
445
|
+
for (const f of faces) {
|
|
446
|
+
// f = [a, b, c, d] as 4 corners; emit tris (a,b,c) (a,c,d)
|
|
447
|
+
v(f[0], f[1], f[2]);
|
|
448
|
+
v(f[3], f[4], f[5]);
|
|
449
|
+
v(f[6], f[7], f[8]);
|
|
450
|
+
v(f[0], f[1], f[2]);
|
|
451
|
+
v(f[6], f[7], f[8]);
|
|
452
|
+
v(f[9], f[10], f[11]);
|
|
453
|
+
}
|
|
454
|
+
return out;
|
|
455
|
+
}
|
|
456
|
+
// Capsule: two hemispheres at axial=±1 + cylinder side connecting their equators.
|
|
457
|
+
// Vertex shader does: world.y = unit.y * radius + halfHeight * axial.
|
|
458
|
+
function buildCapsuleSolidGeometry() {
|
|
459
|
+
const slices = 18;
|
|
460
|
+
const capStacks = 6;
|
|
461
|
+
const cylTris = slices * 2; // 1 stack of quads → 2 tris/slice
|
|
462
|
+
const capTris = capStacks * slices * 2;
|
|
463
|
+
const totalVerts = (cylTris + capTris * 2) * 3;
|
|
464
|
+
const out = new Float32Array(totalVerts * 4);
|
|
465
|
+
let p = 0;
|
|
466
|
+
const v = (x, y, z, axial) => {
|
|
467
|
+
out[p++] = x;
|
|
468
|
+
out[p++] = y;
|
|
469
|
+
out[p++] = z;
|
|
470
|
+
out[p++] = axial;
|
|
471
|
+
};
|
|
472
|
+
// Cylinder side: two rings at axial=±1, both at unit y=0.
|
|
473
|
+
for (let l = 0; l < slices; l++) {
|
|
474
|
+
const th0 = (l / slices) * Math.PI * 2;
|
|
475
|
+
const th1 = ((l + 1) / slices) * Math.PI * 2;
|
|
476
|
+
const c0 = Math.cos(th0), s0 = Math.sin(th0);
|
|
477
|
+
const c1 = Math.cos(th1), s1 = Math.sin(th1);
|
|
478
|
+
// bottom-left, top-left, top-right
|
|
479
|
+
v(c0, 0, s0, -1);
|
|
480
|
+
v(c0, 0, s0, +1);
|
|
481
|
+
v(c1, 0, s1, +1);
|
|
482
|
+
// bottom-left, top-right, bottom-right
|
|
483
|
+
v(c0, 0, s0, -1);
|
|
484
|
+
v(c1, 0, s1, +1);
|
|
485
|
+
v(c1, 0, s1, -1);
|
|
486
|
+
}
|
|
487
|
+
// Top hemisphere (axial=+1): φ ∈ [0, π/2], pos = (cosφ cosθ, sinφ, cosφ sinθ).
|
|
488
|
+
for (let s = 0; s < capStacks; s++) {
|
|
489
|
+
const ph0 = (s / capStacks) * (Math.PI / 2);
|
|
490
|
+
const ph1 = ((s + 1) / capStacks) * (Math.PI / 2);
|
|
491
|
+
for (let l = 0; l < slices; l++) {
|
|
492
|
+
const th0 = (l / slices) * Math.PI * 2;
|
|
493
|
+
const th1 = ((l + 1) / slices) * Math.PI * 2;
|
|
494
|
+
const a = (ph, th) => [
|
|
495
|
+
Math.cos(ph) * Math.cos(th), Math.sin(ph), Math.cos(ph) * Math.sin(th),
|
|
496
|
+
];
|
|
497
|
+
const p00 = a(ph0, th0), p10 = a(ph1, th0), p11 = a(ph1, th1), p01 = a(ph0, th1);
|
|
498
|
+
v(p00[0], p00[1], p00[2], +1);
|
|
499
|
+
v(p10[0], p10[1], p10[2], +1);
|
|
500
|
+
v(p11[0], p11[1], p11[2], +1);
|
|
501
|
+
v(p00[0], p00[1], p00[2], +1);
|
|
502
|
+
v(p11[0], p11[1], p11[2], +1);
|
|
503
|
+
v(p01[0], p01[1], p01[2], +1);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
// Bottom hemisphere (axial=-1): same but y = -sinφ.
|
|
507
|
+
for (let s = 0; s < capStacks; s++) {
|
|
508
|
+
const ph0 = (s / capStacks) * (Math.PI / 2);
|
|
509
|
+
const ph1 = ((s + 1) / capStacks) * (Math.PI / 2);
|
|
510
|
+
for (let l = 0; l < slices; l++) {
|
|
511
|
+
const th0 = (l / slices) * Math.PI * 2;
|
|
512
|
+
const th1 = ((l + 1) / slices) * Math.PI * 2;
|
|
513
|
+
const a = (ph, th) => [
|
|
514
|
+
Math.cos(ph) * Math.cos(th), -Math.sin(ph), Math.cos(ph) * Math.sin(th),
|
|
515
|
+
];
|
|
516
|
+
const p00 = a(ph0, th0), p10 = a(ph1, th0), p11 = a(ph1, th1), p01 = a(ph0, th1);
|
|
517
|
+
v(p00[0], p00[1], p00[2], -1);
|
|
518
|
+
v(p11[0], p11[1], p11[2], -1);
|
|
519
|
+
v(p10[0], p10[1], p10[2], -1);
|
|
520
|
+
v(p00[0], p00[1], p00[2], -1);
|
|
521
|
+
v(p01[0], p01[1], p01[2], -1);
|
|
522
|
+
v(p11[0], p11[1], p11[2], -1);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return out;
|
|
526
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lights.d.ts","sourceRoot":"","sources":["../../src/shaders/lights.ts"],"names":[],"mappings":"AAoDA;uDACuD;AACvD,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,+CAA+C;AAC/C,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9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A;AAElF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,qJAQhC,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,QAA4B,CAAA;AAE3D,8CAA8C;AAC9C,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAC5B,UAAU,SAAK,GACd,MAAM,CAoGR;AAED,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CA2JhE"}
|
package/dist/shaders/lights.js
CHANGED
|
@@ -350,6 +350,25 @@ fn rzLightsDiffuse(p: vec3f, n: vec3f) -> vec3f {
|
|
|
350
350
|
return _rzLightsIrradiance(p, n) * (1.0 / 3.141592653589793);
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
// ONE WALK PER FRAGMENT. A principled closure walks the lamps for its specular
|
|
354
|
+
// anyway, and every lamp's reach, falloff and cone are the same numbers the
|
|
355
|
+
// diffuse layer needs — so that walk computes both, against the normal the
|
|
356
|
+
// material prelude recorded here, and leaves the diffuse for the epilogue.
|
|
357
|
+
// Walking the grid twice was ~60% of a lit stage's frame.
|
|
358
|
+
var<private> _rzLampN: vec3f;
|
|
359
|
+
var<private> _rzLampDiffuse: vec3f;
|
|
360
|
+
var<private> _rzLampDiffuseSet: bool = false;
|
|
361
|
+
// Set by a closure that shaded the lamps' diffuse itself (a Unity-mode
|
|
362
|
+
// principled, which tints it by its own base) — the epilogue then adds none.
|
|
363
|
+
var<private> _rzLampDiffuseTaken: bool = false;
|
|
364
|
+
|
|
365
|
+
/** rzLightsDiffuse(p, _rzLampN), taken from a principled walk when one ran. */
|
|
366
|
+
fn rzLightsDiffuseOnce(p: vec3f, n: vec3f) -> vec3f {
|
|
367
|
+
if (_rzLampDiffuseTaken) { return vec3f(0.0); }
|
|
368
|
+
if (_rzLampDiffuseSet) { return _rzLampDiffuse; }
|
|
369
|
+
return rzLightsDiffuse(p, n);
|
|
370
|
+
}
|
|
371
|
+
|
|
353
372
|
fn _rzLightsIrradiance(p: vec3f, n: vec3f) -> vec3f {
|
|
354
373
|
var acc = vec3f(0.0);
|
|
355
374
|
let count = rzLightCount();
|