rayzee 5.3.7 → 5.4.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/README.md +85 -2
- package/dist/rayzee.es.js +1727 -1679
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +7 -7
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/Passes/AIUpscaler.js +30 -6
- package/src/Passes/OIDNDenoiser.js +57 -15
- package/src/PathTracerApp.js +153 -19
- package/src/Pipeline/RenderPipeline.js +10 -1
- package/src/Processor/ShaderBuilder.js +53 -5
- package/src/Stages/ASVGF.js +4 -4
- package/src/Stages/AdaptiveSampling.js +2 -2
- package/src/Stages/AutoExposure.js +42 -32
- package/src/Stages/BilateralFilter.js +2 -2
- package/src/Stages/Display.js +2 -1
- package/src/Stages/EdgeFilter.js +6 -3
- package/src/Stages/MotionVector.js +2 -2
- package/src/Stages/NormalDepth.js +1 -1
- package/src/Stages/PathTracer.js +1 -3
- package/src/Stages/SSRC.js +4 -4
- package/src/Stages/Variance.js +2 -2
- package/src/TSL/wgslGlobalVarsPatch.js +60 -0
- package/src/index.js +1 -1
- package/src/managers/LightManager.js +20 -0
- package/src/managers/UniformManager.js +19 -0
- package/src/managers/helpers/OutlineHelper.js +3 -1
- package/src/README.md +0 -284
- package/src/TSL/storageTexturePatch.js +0 -31
package/README.md
CHANGED
|
@@ -93,7 +93,8 @@ A single HTML file — no Node.js, no build step. Uses [ES module import maps](h
|
|
|
93
93
|
"three/webgpu": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.webgpu.js",
|
|
94
94
|
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.0/examples/jsm/",
|
|
95
95
|
"stats-gl": "https://cdn.jsdelivr.net/npm/stats-gl@4.0.2/dist/main.js",
|
|
96
|
-
"
|
|
96
|
+
"oidn-web": "https://cdn.jsdelivr.net/npm/oidn-web@0.3.5/dist/oidn.js",
|
|
97
|
+
"rayzee": "https://cdn.jsdelivr.net/npm/rayzee/dist/rayzee.es.js"
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
</script>
|
|
@@ -164,6 +165,56 @@ export default function Viewport({ modelUrl }) {
|
|
|
164
165
|
|
|
165
166
|
No special build config is needed — models and HDRs are loaded via URL at runtime.
|
|
166
167
|
|
|
168
|
+
### Integrating Alongside an Existing Three.js App
|
|
169
|
+
|
|
170
|
+
If your app already has a WebGL/WebGPU rasterized view and you want to add a path-traced mode on demand, run rayzee on its own **separate canvas** (WebGL and WebGPU can't share one) and toggle visibility.
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
import { PathTracerApp } from 'rayzee';
|
|
174
|
+
|
|
175
|
+
// 1. WebGPU detection
|
|
176
|
+
if (!navigator.gpu || !(await navigator.gpu.requestAdapter())) return;
|
|
177
|
+
|
|
178
|
+
// 2. Overlay canvas (hidden until toggled on)
|
|
179
|
+
const ptCanvas = document.createElement('canvas');
|
|
180
|
+
Object.assign(ptCanvas.style, { position: 'absolute', inset: 0, display: 'none' });
|
|
181
|
+
container.appendChild(ptCanvas);
|
|
182
|
+
|
|
183
|
+
let engine = null;
|
|
184
|
+
async function togglePathTrace(on) {
|
|
185
|
+
if (on && !engine) {
|
|
186
|
+
ptCanvas.width = container.clientWidth;
|
|
187
|
+
ptCanvas.height = container.clientHeight;
|
|
188
|
+
engine = new PathTracerApp(ptCanvas, { autoResize: false });
|
|
189
|
+
await engine.init();
|
|
190
|
+
await engine.loadEnvironment('/env.hdr'); // required for realistic lighting
|
|
191
|
+
await engine.loadObject3D(yourScene); // rayzee takes ownership — pass a clone if the host still renders it
|
|
192
|
+
engine.animate();
|
|
193
|
+
}
|
|
194
|
+
ptCanvas.style.display = on ? 'block' : 'none';
|
|
195
|
+
hostCanvas.style.display = on ? 'none' : 'block';
|
|
196
|
+
on ? engine?.resume() : engine?.pause(); // pause the inactive renderer to avoid GPU contention
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Key constraints:
|
|
201
|
+
|
|
202
|
+
- **`loadObject3D` takes ownership** of the passed `Object3D` (sets it as the active model, disposes the previous one). If your host app continues to render the same scene graph, pass `scene.clone(true)` — deep-cloning shares geometry/texture data, so memory cost is small. Clone once on first toggle, not on every switch.
|
|
203
|
+
- **Rayzee ignores `onBeforeCompile`.** It reads PBR material properties (albedo, roughness, metalness, …) directly into its own GPU buffers; custom shader injection on the host material has no effect on the path-traced view.
|
|
204
|
+
- **Always load an environment.** Path tracing without an env map produces a black background and no indirect lighting.
|
|
205
|
+
- **`three` is a peer dep on both sides.** Vite/webpack dedupe automatically. For script-tag setups, load one copy of `three` globally.
|
|
206
|
+
|
|
207
|
+
### Vite tip
|
|
208
|
+
|
|
209
|
+
When rayzee is installed from npm, its pre-built `dist/rayzee.es.js` uses worker and `import.meta.url` patterns that Vite's dep pre-bundler re-parses incorrectly. Exclude it:
|
|
210
|
+
|
|
211
|
+
```js
|
|
212
|
+
// vite.config.js
|
|
213
|
+
export default defineConfig({
|
|
214
|
+
optimizeDeps: { exclude: ['rayzee'] },
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
167
218
|
## API Reference
|
|
168
219
|
|
|
169
220
|
### PathTracerApp
|
|
@@ -533,6 +584,28 @@ OIDN provides high-quality AI denoising for final renders. It runs automatically
|
|
|
533
584
|
|
|
534
585
|
> **Note:** The neural network model is downloaded on first use. Subsequent runs use the browser cache. OIDN also works with `configureForMode('final-render')`, which enables it automatically alongside high-quality render settings.
|
|
535
586
|
|
|
587
|
+
### Enabling the AI Upscaler
|
|
588
|
+
|
|
589
|
+
The upscaler runs ONNX super-resolution models via `onnxruntime-web`. Unlike OIDN, `onnxruntime-web` is lazily fetched from a CDN inside a Web Worker — **no npm install or import map entry is needed**.
|
|
590
|
+
|
|
591
|
+
```js
|
|
592
|
+
engine.denoisingManager.setUpscalerEnabled(true);
|
|
593
|
+
engine.denoisingManager.setUpscalerQuality('fast'); // 'fast' | 'balanced' | 'quality'
|
|
594
|
+
engine.denoisingManager.setUpscalerScaleFactor(2); // 2 | 4
|
|
595
|
+
|
|
596
|
+
engine.addEventListener(EngineEvents.UPSCALING_START, () => console.log('Upscaling started'));
|
|
597
|
+
engine.addEventListener(EngineEvents.UPSCALING_PROGRESS, (e) => console.log('Upscaling', e));
|
|
598
|
+
engine.addEventListener(EngineEvents.UPSCALING_END, () => console.log('Upscaling complete'));
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
| Quality | Model | 2× size | 4× size |
|
|
602
|
+
|---|---|---|---|
|
|
603
|
+
| `'fast'` | SPAN | 1.6 MB | 1.6 MB |
|
|
604
|
+
| `'balanced'` | SRVGGNetCompact | 2.4 MB | 4.9 MB |
|
|
605
|
+
| `'quality'` | RRDBNet / MoSR | 67 MB | 16.5 MB |
|
|
606
|
+
|
|
607
|
+
**Chaining with OIDN:** Upscaling and OIDN **can** run together — on render completion, OIDN runs first, then its denoised output is fed into the upscaler. Enable both; no manual coordination required.
|
|
608
|
+
|
|
536
609
|
## Troubleshooting
|
|
537
610
|
|
|
538
611
|
**OIDN: `Cannot find module './tza'` (webpack)**
|
|
@@ -553,12 +626,22 @@ Then load it via a script tag or import map instead:
|
|
|
553
626
|
<script type="importmap">
|
|
554
627
|
{
|
|
555
628
|
"imports": {
|
|
556
|
-
"oidn-web": "https://cdn.jsdelivr.net/npm/oidn-web@0.3.
|
|
629
|
+
"oidn-web": "https://cdn.jsdelivr.net/npm/oidn-web@0.3.5/dist/oidn.js"
|
|
557
630
|
}
|
|
558
631
|
}
|
|
559
632
|
</script>
|
|
560
633
|
```
|
|
561
634
|
|
|
635
|
+
**OIDN: `TypeError: t.alea is not a function` or `Argument 'x' passed to 'conv2d' must be a Tensor ... got 'L'`**
|
|
636
|
+
You're loading `oidn-web` via `jsdelivr.net/npm/oidn-web/+esm` or `esm.sh/oidn-web`. Don't — use the **self-bundled** `/dist/oidn.js` path instead:
|
|
637
|
+
|
|
638
|
+
```diff
|
|
639
|
+
- "oidn-web": "https://cdn.jsdelivr.net/npm/oidn-web@0.3.5/+esm"
|
|
640
|
+
+ "oidn-web": "https://cdn.jsdelivr.net/npm/oidn-web@0.3.5/dist/oidn.js"
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
Why: `oidn-web` transitively depends on `@tensorflow/tfjs-core`, which does `import * as t from "seedrandom"` and calls `t.alea(...)`. jsDelivr's `/+esm` CJS→ESM shim of `seedrandom` emits only `export default` (no named exports), so `t.alea` is undefined. Swapping to `esm.sh` trades that for a different issue: deep-path imports produce multiple tfjs-core instances, so a Tensor made in one module fails `instanceof` checks in another (`got 'L'`). The `/dist/oidn.js` file in the npm package is a single pre-bundled ESM with all of tfjs inlined — no external imports, one tfjs instance, same exports. Use it.
|
|
644
|
+
|
|
562
645
|
**Black screen / "WebGPU not supported"**
|
|
563
646
|
Your browser may not support WebGPU. Use Chrome 113+, Edge 113+, Safari 18+, or Firefox 141+. Ensure you're on HTTPS or localhost.
|
|
564
647
|
|