rayzee 5.4.0 → 5.4.2
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/rayzee.es.js +2821 -2784
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +54 -54
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/PathTracerApp.js +1 -2
- package/src/Processor/AssetLoader.js +40 -18
- package/src/Processor/EquirectHDRInfo.js +38 -29
- package/src/Processor/GeometryExtractor.js +19 -2
- package/src/Processor/InstanceTable.js +16 -0
- package/src/Processor/SceneProcessor.js +22 -33
- package/src/Processor/ShaderBuilder.js +14 -17
- package/src/Processor/TLASBuilder.js +9 -4
- package/src/Stages/PathTracer.js +100 -43
- package/src/TSL/BVHTraversal.js +34 -74
- package/src/TSL/Clearcoat.js +1 -1
- package/src/TSL/Displacement.js +1 -1
- package/src/TSL/EmissiveSampling.js +17 -13
- package/src/TSL/Environment.js +12 -9
- package/src/TSL/LightBVHSampling.js +3 -2
- package/src/TSL/LightsCore.js +1 -1
- package/src/TSL/LightsDirect.js +14 -1
- package/src/TSL/LightsIndirect.js +0 -1
- package/src/TSL/LightsSampling.js +2 -2
- package/src/TSL/MaterialTransmission.js +1 -1
- package/src/TSL/PathTracer.js +4 -4
- package/src/TSL/PathTracerCore.js +6 -6
- package/src/TSL/Struct.js +1 -1
- package/src/TSL/TextureSampling.js +1 -1
- package/src/TSL/patches.js +145 -0
- package/src/index.js +1 -1
- package/src/managers/EnvironmentManager.js +32 -56
- package/src/managers/MaterialDataManager.js +93 -3
- package/src/managers/UniformManager.js +3 -0
- package/src/TSL/structProxy.js +0 -87
- package/src/TSL/wgslGlobalVarsPatch.js +0 -60
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Monkey-patch to disable WGSL global-variable promotion for compute shaders.
|
|
3
|
-
*
|
|
4
|
-
* Three.js r184 introduced `WGSLNodeBuilder.allowGlobalVariables = true` which
|
|
5
|
-
* emits `.toVar()` declarations at WGSL module scope as `var<private> name : T`
|
|
6
|
-
* instead of function-local `var name : T` inside `fn main()` (as r183 did).
|
|
7
|
-
*
|
|
8
|
-
* For shaders with hundreds of `.toVar()` calls inside loops (e.g. our BVH
|
|
9
|
-
* traversal + BRDF path tracer), `var<private>` increases GPU register pressure
|
|
10
|
-
* because the Dawn/Chromium WGSL compiler cannot aggressively register-allocate
|
|
11
|
-
* variables with a stable per-invocation memory address. We measured a ~8% fps
|
|
12
|
-
* regression (120 → 110) on the path tracer after upgrading r183 → r184 that
|
|
13
|
-
* traced entirely to GPU execution, not CPU.
|
|
14
|
-
*
|
|
15
|
-
* This patch wraps `WebGPUBackend.createNodeBuilder` so every newly constructed
|
|
16
|
-
* node builder reports `allowGlobalVariables = false`, restoring r183's
|
|
17
|
-
* function-scoped `var` emission inside `fn main()`. No behavior change —
|
|
18
|
-
* WGSL spec guarantees `var<private>` and function-local `var` are semantically
|
|
19
|
-
* equivalent for per-invocation storage; only the compiler's register-allocation
|
|
20
|
-
* latitude differs.
|
|
21
|
-
*
|
|
22
|
-
* Relevant upstream lines:
|
|
23
|
-
* - `node_modules/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.js:247`
|
|
24
|
-
* (`this.allowGlobalVariables = true`)
|
|
25
|
-
* - `...WGSLNodeBuilder.js:2458` (module-scope vars block)
|
|
26
|
-
* - `...WGSLNodeBuilder.js:2467` (function-body vars block)
|
|
27
|
-
*
|
|
28
|
-
* Revisit if upstream adds an official opt-out or fixes register pressure.
|
|
29
|
-
* Import this module once at app startup (side-effect only).
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
import { WebGPUBackend } from 'three/webgpu';
|
|
33
|
-
|
|
34
|
-
const _origCreateNodeBuilder = WebGPUBackend.prototype.createNodeBuilder;
|
|
35
|
-
|
|
36
|
-
// WGSLNodeBuilder's `allowGlobalVariables` switch is ONLY consumed by the
|
|
37
|
-
// compute-shader template (see `_getWGSLComputeCode`). The vertex/fragment
|
|
38
|
-
// templates always emit `shaderData.vars` at module scope and therefore
|
|
39
|
-
// REQUIRE `allowGlobalVariables=true` (emitting function-local `var` at
|
|
40
|
-
// module scope is invalid WGSL and crashes pipeline creation with
|
|
41
|
-
// "Invalid ShaderModule"). We install a per-instance accessor that returns
|
|
42
|
-
// `false` only when the builder is for a compute node (material === null)
|
|
43
|
-
// and `true` otherwise, so render pipelines keep r184 behavior untouched.
|
|
44
|
-
WebGPUBackend.prototype.createNodeBuilder = function ( object, renderer ) {
|
|
45
|
-
|
|
46
|
-
const builder = _origCreateNodeBuilder.call( this, object, renderer );
|
|
47
|
-
|
|
48
|
-
Object.defineProperty( builder, 'allowGlobalVariables', {
|
|
49
|
-
get() {
|
|
50
|
-
|
|
51
|
-
return this.material !== null;
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
set() { /* ignore — the value is derived from material presence */ },
|
|
55
|
-
configurable: true,
|
|
56
|
-
} );
|
|
57
|
-
|
|
58
|
-
return builder;
|
|
59
|
-
|
|
60
|
-
};
|