rayzee 8.6.0 → 8.6.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/README.md +1 -53
- package/dist/{DLSSNeural-BhBCBgKf.js → NeuralRetouch-CYOJ21Wn.js} +31 -31
- package/dist/{DLSSSuperRes-BCA7F_k5.js → NeuralSuperRes-Dc6jRYke.js} +23 -23
- package/dist/{ToneMapGPU-BzcLheoR.js → ToneMapGPU-BVE852iN.js} +2 -2
- package/dist/rayzee.es.js +49 -39
- package/dist/rayzee.umd.js +5 -5
- package/package.json +1 -1
- package/src/AssetConfig.js +6 -5
- package/src/Passes/OIDNDenoiser.js +13 -5
- package/src/index.js +3 -3
- package/src/managers/DenoisingManager.js +60 -44
- package/src/{dlss/DLSSNeural.js → neural/NeuralRetouch.js} +42 -41
- package/src/{dlss/DLSSSuperRes.js → neural/NeuralSuperRes.js} +27 -26
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Neural super resolution — final-render output scaling.
|
|
3
3
|
*
|
|
4
4
|
* Traces at half resolution, denoises, then runs one neural upscale to reach the
|
|
5
5
|
* requested output size. On a 1.89M-triangle interior at 32 spp this matched a
|
|
@@ -35,7 +35,7 @@ import { getAssetConfig } from '../AssetConfig.js';
|
|
|
35
35
|
/** The network is a fixed 2x per axis. */
|
|
36
36
|
export const SR_SCALE = 2;
|
|
37
37
|
|
|
38
|
-
const log = createLogger( '
|
|
38
|
+
const log = createLogger( 'neural' );
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Largest input side the runtime actually survives — 2048, i.e. 4096 output.
|
|
@@ -63,24 +63,25 @@ function loadRuntime() {
|
|
|
63
63
|
|
|
64
64
|
if ( _runtimePromise ) return _runtimePromise;
|
|
65
65
|
|
|
66
|
-
const {
|
|
67
|
-
|
|
66
|
+
const { neuralRuntimeUrl, neuralAssetBaseUrl } = getAssetConfig();
|
|
67
|
+
if ( ! neuralAssetBaseUrl ) return Promise.reject( new Error( 'No neural model location: set neuralAssetBaseUrl with configureAssets()' ) );
|
|
68
|
+
globalThis.__NEURAL_ASSET_BASE__ = neuralAssetBaseUrl;
|
|
68
69
|
|
|
69
70
|
_runtimePromise = new Promise( ( resolve, reject ) => {
|
|
70
71
|
|
|
71
|
-
if ( globalThis.
|
|
72
|
+
if ( globalThis.NeuralRuntime?.getNativeSR ) return resolve( globalThis.NeuralRuntime.getNativeSR() );
|
|
72
73
|
|
|
73
74
|
const el = document.createElement( 'script' );
|
|
74
|
-
el.src =
|
|
75
|
+
el.src = neuralRuntimeUrl;
|
|
75
76
|
el.onload = () => {
|
|
76
77
|
|
|
77
|
-
const factory = globalThis.
|
|
78
|
-
if ( ! factory ) return reject( new Error( '
|
|
78
|
+
const factory = globalThis.NeuralRuntime?.getNativeSR;
|
|
79
|
+
if ( ! factory ) return reject( new Error( 'Neural runtime loaded but exposed no super-resolution entry' ) );
|
|
79
80
|
resolve( factory() );
|
|
80
81
|
|
|
81
82
|
};
|
|
82
83
|
|
|
83
|
-
el.onerror = () => reject( new Error( `Failed to load the
|
|
84
|
+
el.onerror = () => reject( new Error( `Failed to load the neural runtime from ${neuralRuntimeUrl}` ) );
|
|
84
85
|
document.head.appendChild( el );
|
|
85
86
|
|
|
86
87
|
} );
|
|
@@ -126,20 +127,20 @@ function ensureReader( device, width, height ) {
|
|
|
126
127
|
width,
|
|
127
128
|
height,
|
|
128
129
|
storage: device.createBuffer( {
|
|
129
|
-
label: 'rayzee:
|
|
130
|
+
label: 'rayzee:neural-sr-pack',
|
|
130
131
|
size: bytes,
|
|
131
132
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
|
|
132
133
|
} ),
|
|
133
134
|
map: device.createBuffer( {
|
|
134
|
-
label: 'rayzee:
|
|
135
|
+
label: 'rayzee:neural-sr-pack-map',
|
|
135
136
|
size: bytes,
|
|
136
137
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
137
138
|
} ),
|
|
138
139
|
pipeline: device.createComputePipeline( {
|
|
139
|
-
label: 'rayzee:
|
|
140
|
+
label: 'rayzee:neural-sr-pack',
|
|
140
141
|
layout: 'auto',
|
|
141
142
|
compute: {
|
|
142
|
-
module: device.createShaderModule( { label: 'rayzee:
|
|
143
|
+
module: device.createShaderModule( { label: 'rayzee:neural-sr-pack', code: DENOISED_PACK_WGSL } ),
|
|
143
144
|
entryPoint: 'main',
|
|
144
145
|
},
|
|
145
146
|
} ),
|
|
@@ -171,7 +172,7 @@ export function releaseDenoisedReader() {
|
|
|
171
172
|
export async function readDenoisedHalf( denoiser ) {
|
|
172
173
|
|
|
173
174
|
const texture = denoiser?._outGPUTexture;
|
|
174
|
-
if ( ! texture ) throw new Error( '
|
|
175
|
+
if ( ! texture ) throw new Error( 'NeuralSuperRes: no denoised frame — enable OIDN and finish a render first' );
|
|
175
176
|
|
|
176
177
|
const device = denoiser.gpuDevice;
|
|
177
178
|
const { width, height } = denoiser._outTexSize;
|
|
@@ -184,7 +185,7 @@ export async function readDenoisedHalf( denoiser ) {
|
|
|
184
185
|
],
|
|
185
186
|
} );
|
|
186
187
|
|
|
187
|
-
const encoder = device.createCommandEncoder( { label: 'rayzee:
|
|
188
|
+
const encoder = device.createCommandEncoder( { label: 'rayzee:neural-sr-pack' } );
|
|
188
189
|
const pass = encoder.beginComputePass();
|
|
189
190
|
pass.setPipeline( reader.pipeline );
|
|
190
191
|
pass.setBindGroup( 0, group );
|
|
@@ -201,7 +202,7 @@ export async function readDenoisedHalf( denoiser ) {
|
|
|
201
202
|
|
|
202
203
|
}
|
|
203
204
|
|
|
204
|
-
export class
|
|
205
|
+
export class NeuralSuperRes {
|
|
205
206
|
|
|
206
207
|
constructor( sr, canvas ) {
|
|
207
208
|
|
|
@@ -255,14 +256,14 @@ export class DLSSSuperRes {
|
|
|
255
256
|
|
|
256
257
|
if ( ! Number.isInteger( width ) || ! Number.isInteger( height ) || width < 1 || height < 1 ) {
|
|
257
258
|
|
|
258
|
-
throw new Error( '
|
|
259
|
+
throw new Error( 'NeuralSuperRes.create: width and height must be positive integers' );
|
|
259
260
|
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
if ( width > SR_MAX_INPUT || height > SR_MAX_INPUT ) {
|
|
263
264
|
|
|
264
265
|
throw new Error(
|
|
265
|
-
`
|
|
266
|
+
`NeuralSuperRes.create: input capped at ${SR_MAX_INPUT}px per side (${SR_MAX_INPUT * SR_SCALE}px output), ` +
|
|
266
267
|
`got ${width}x${height}. Above that the runtime's history plane exceeds maxTextureDimension2D ` +
|
|
267
268
|
'and it fails later with an unrelated bind-group error.'
|
|
268
269
|
);
|
|
@@ -287,7 +288,7 @@ export class DLSSSuperRes {
|
|
|
287
288
|
|
|
288
289
|
}
|
|
289
290
|
|
|
290
|
-
const instance = new
|
|
291
|
+
const instance = new NeuralSuperRes( sr, canvas );
|
|
291
292
|
instance._allocate();
|
|
292
293
|
return instance;
|
|
293
294
|
|
|
@@ -306,13 +307,13 @@ export class DLSSSuperRes {
|
|
|
306
307
|
/** Runs the network once over a frame already in its own layout, as `readDenoisedHalf` returns. */
|
|
307
308
|
async _run( source ) {
|
|
308
309
|
|
|
309
|
-
if ( this.disposed ) throw new Error( '
|
|
310
|
+
if ( this.disposed ) throw new Error( 'NeuralSuperRes: disposed' );
|
|
310
311
|
|
|
311
312
|
const w = this.inputWidth;
|
|
312
313
|
const h = this.inputHeight;
|
|
313
314
|
if ( source.width !== w || source.height !== h ) {
|
|
314
315
|
|
|
315
|
-
throw new Error( `
|
|
316
|
+
throw new Error( `NeuralSuperRes: expected a ${w}x${h} source, got ${source.width}x${source.height}` );
|
|
316
317
|
|
|
317
318
|
}
|
|
318
319
|
|
|
@@ -320,7 +321,7 @@ export class DLSSSuperRes {
|
|
|
320
321
|
if ( ! source.half || source.half.length !== color.length ) {
|
|
321
322
|
|
|
322
323
|
throw new Error(
|
|
323
|
-
`
|
|
324
|
+
`NeuralSuperRes: expected ${color.length} packed halfs from readDenoisedHalf, got ${source.half?.length}`
|
|
324
325
|
);
|
|
325
326
|
|
|
326
327
|
}
|
|
@@ -364,7 +365,7 @@ export class DLSSSuperRes {
|
|
|
364
365
|
const { result, ms } = await this._run( source );
|
|
365
366
|
const { outputWidth, outputHeight } = this.geometry;
|
|
366
367
|
|
|
367
|
-
this._toneMapper ??= new PackedToneMapper( this.sr.device, 'rayzee:
|
|
368
|
+
this._toneMapper ??= new PackedToneMapper( this.sr.device, 'rayzee:neural-sr-tonemap' );
|
|
368
369
|
this._toneMapper.ensureSize( outputWidth, outputHeight );
|
|
369
370
|
|
|
370
371
|
const started = performance.now();
|
|
@@ -436,7 +437,7 @@ function waitForDenoise( app, samples, timeoutMs ) {
|
|
|
436
437
|
}, 200 );
|
|
437
438
|
|
|
438
439
|
const timer = setTimeout(
|
|
439
|
-
() => finish( false, new Error( '
|
|
440
|
+
() => finish( false, new Error( 'NeuralSuperRes: timed out waiting for the render to finish' ) ),
|
|
440
441
|
timeoutMs,
|
|
441
442
|
);
|
|
442
443
|
|
|
@@ -453,7 +454,7 @@ function waitForDenoise( app, samples, timeoutMs ) {
|
|
|
453
454
|
* @param {number} opts.outputWidth final width; must be even
|
|
454
455
|
* @param {number} opts.outputHeight final height; must be even
|
|
455
456
|
* @param {number} [opts.samples] samples to accumulate at half resolution
|
|
456
|
-
* @param {
|
|
457
|
+
* @param {NeuralSuperRes} [opts.upscaler] reuse an upscaler already built for this size
|
|
457
458
|
* @param {boolean} [opts.present] draw the result over the viewport
|
|
458
459
|
* @returns {Promise<{rgba8: Uint8ClampedArray, width: number, height: number, timings: object}>}
|
|
459
460
|
*/
|
|
@@ -495,7 +496,7 @@ export async function renderUpscaled( app, {
|
|
|
495
496
|
|
|
496
497
|
const t = performance.now();
|
|
497
498
|
onProgress( 'Loading the super-resolution model' );
|
|
498
|
-
sr = await
|
|
499
|
+
sr = await NeuralSuperRes.create( { width: inW, height: inH, onProgress } );
|
|
499
500
|
timings.load = performance.now() - t;
|
|
500
501
|
|
|
501
502
|
} else if ( sr.inputWidth !== inW || sr.inputHeight !== inH ) {
|