rayzee 5.6.1 → 5.7.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 +3 -0
- package/dist/assets/CDFWorker-BFQUr3By.js +2 -0
- package/dist/assets/CDFWorker-BFQUr3By.js.map +1 -0
- package/dist/rayzee.es.js +2374 -2347
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +49 -43
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/EngineEvents.js +3 -0
- package/src/PathTracerApp.js +32 -11
- package/src/Processor/EquirectHDRInfo.js +76 -16
- package/src/Processor/ShaderBuilder.js +1 -0
- package/src/Processor/Workers/CDFWorker.js +72 -11
- package/src/RenderSettings.js +10 -8
- package/src/Stages/Compositor.js +101 -0
- package/src/Stages/NormalDepth.js +37 -20
- package/src/TSL/Common.js +9 -0
- package/src/TSL/Environment.js +15 -6
- package/src/TSL/LightsIndirect.js +1 -1
- package/src/TSL/LightsSampling.js +5 -4
- package/src/TSL/PathTracer.js +2 -2
- package/src/TSL/PathTracerCore.js +6 -5
- package/src/managers/DenoisingManager.js +8 -18
- package/src/managers/EnvironmentManager.js +17 -0
- package/src/managers/TransformManager.js +9 -0
- package/src/managers/UniformManager.js +1 -0
- package/dist/assets/CDFWorker-2MoynL4F.js +0 -2
- package/dist/assets/CDFWorker-2MoynL4F.js.map +0 -1
- package/src/Stages/Display.js +0 -120
package/README.md
CHANGED
|
@@ -244,6 +244,8 @@ engine.dispose() // Clean up all resources
|
|
|
244
244
|
engine.wake() // Resume render loop if idle
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
+
Constructing a new `PathTracerApp` on a canvas that already has an active instance auto-disposes the prior one — safe under React StrictMode and HMR even without explicit cleanup, though `engine.dispose()` remains the recommended teardown path.
|
|
248
|
+
|
|
247
249
|
#### Loading Assets
|
|
248
250
|
|
|
249
251
|
```js
|
|
@@ -472,6 +474,7 @@ engine.addEventListener(EngineEvents.RENDER_COMPLETE, (e) => {
|
|
|
472
474
|
| `AF_POINT_PLACED` | Focus point placed on screen |
|
|
473
475
|
| `ANIMATION_STARTED` / `ANIMATION_PAUSED` / `ANIMATION_STOPPED` / `ANIMATION_FINISHED` | Animation lifecycle |
|
|
474
476
|
| `VIDEO_RENDER_PROGRESS` / `VIDEO_RENDER_COMPLETE` | Video export progress |
|
|
477
|
+
| `DISPOSE` | Engine is being disposed (fires before teardown begins, so listeners can release their own references) |
|
|
475
478
|
|
|
476
479
|
### Advanced: Custom Pipeline Stages
|
|
477
480
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){function e(e,t,n,r){let i=n,a=n+r-1;for(;i<a;){let n=i+a>>1;e[n]<t?i=n+1:a=n}return i-n}function t(t,n,r){let i=n*r,a=new Float32Array(i),o=0;for(let e=0;e<r;e++){let i=Math.sin(Math.PI*(e+.5)/r);for(let r=0;r<n;r++){let s=e*n+r,c=t[4*s],l=t[4*s+1],u=t[4*s+2],d=(.2126*c+.7152*l+.0722*u)*i;a[s]=d,o+=d}}let s=o/i,c=0;for(let e=0;e<i;e++)a[e]=Math.max(0,a[e]-s),c+=a[e];let l=c>0,u=l?c:o,d=l?s:0;if(!l)for(let e=0;e<r;e++){let i=Math.sin(Math.PI*(e+.5)/r);for(let r=0;r<n;r++){let o=e*n+r,s=t[4*o],c=t[4*o+1],l=t[4*o+2];a[o]=(.2126*s+.7152*c+.0722*l)*i}}let f=new Float32Array(i),p=new Float32Array(r),m=0;for(let e=0;e<r;e++){let t=0;for(let r=0;r<n;r++){let i=e*n+r;t+=a[i],f[i]=t}if(t!==0)for(let r=e*n,i=e*n+n;r<i;r++)f[r]/=t;m+=t,p[e]=m}if(m!==0)for(let e=0,t=p.length;e<t;e++)p[e]/=m;let h=new Float32Array(r);for(let t=0;t<r;t++)h[t]=(e(p,(t+1)/r,0,r)+.5)/r;let g=new Float32Array(n*r);for(let t=0;t<r;t++)for(let r=0;r<n;r++){let i=t*n+r;g[i]=(e(f,(r+1)/n,t*n,n)+.5)/n}return{marginalData:h,conditionalData:g,totalSum:u,compensationDelta:d}}self.onmessage=function(e){let{floatData:n,width:r,height:i}=e.data;try{let e=t(n,r,i);self.postMessage({marginalData:e.marginalData,conditionalData:e.conditionalData,totalSum:e.totalSum,compensationDelta:e.compensationDelta,width:r,height:i},[e.marginalData.buffer,e.conditionalData.buffer])}catch(e){self.postMessage({error:e.message})}}})();
|
|
2
|
+
//# sourceMappingURL=CDFWorker-BFQUr3By.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CDFWorker-BFQUr3By.js","names":[],"sources":["../../src/Processor/Workers/CDFWorker.js"],"sourcesContent":["/**\n * Web Worker for computing environment map CDF (Cumulative Distribution Function)\n * for importance sampling. Pure math — no Three.js dependencies.\n *\n * Input: { floatData: Float32Array, width, height }\n * Output: { marginalData: Float32Array, conditionalData: Float32Array, totalSum, width, height }\n */\n\nfunction binarySearchFindClosestIndexOf( array, targetValue, offset, count ) {\n\n\tlet lower = offset;\n\tlet upper = offset + count - 1;\n\n\twhile ( lower < upper ) {\n\n\t\tconst mid = ( lower + upper ) >> 1;\n\n\t\tif ( array[ mid ] < targetValue ) {\n\n\t\t\tlower = mid + 1;\n\n\t\t} else {\n\n\t\t\tupper = mid;\n\n\t\t}\n\n\t}\n\n\treturn lower - offset;\n\n}\n\nfunction buildCDF( floatData, width, height ) {\n\n\tconst numPixels = width * height;\n\n\t// Pass 1: compute per-pixel luminance weighted by sin(theta) and raw total sum.\n\t// sin(theta) compensates for the equirectangular projection: pixels near the poles\n\t// cover less solid angle, so weighting by sin(theta) makes the CDF proportional to\n\t// luminance per solid angle rather than luminance per pixel.\n\tconst pixelWeights = new Float32Array( numPixels );\n\tlet rawTotalSum = 0.0;\n\n\tfor ( let y = 0; y < height; y ++ ) {\n\n\t\tconst sinTheta = Math.sin( Math.PI * ( y + 0.5 ) / height );\n\n\t\tfor ( let x = 0; x < width; x ++ ) {\n\n\t\t\tconst i = y * width + x;\n\t\t\tconst r = floatData[ 4 * i ];\n\t\t\tconst g = floatData[ 4 * i + 1 ];\n\t\t\tconst b = floatData[ 4 * i + 2 ];\n\n\t\t\t// Luminance (Rec. 709) weighted by solid angle factor\n\t\t\tconst w = ( 0.2126 * r + 0.7152 * g + 0.0722 * b ) * sinTheta;\n\t\t\tpixelWeights[ i ] = w;\n\t\t\trawTotalSum += w;\n\n\t\t}\n\n\t}\n\n\t// MIS Compensation (Karlík et al. 2019, Eq. 14)\n\t// With equal sample allocation (c_I = 0.5): delta = 2*(1 - 0.5)*meanWeight = meanWeight\n\t// Subtracting mean sharpens the env map PDF, reducing oversampling\n\t// of dim regions already well-covered by BSDF sampling.\n\tconst meanWeight = rawTotalSum / numPixels;\n\tlet compensatedTotalSum = 0.0;\n\n\tfor ( let i = 0; i < numPixels; i ++ ) {\n\n\t\tpixelWeights[ i ] = Math.max( 0, pixelWeights[ i ] - meanWeight );\n\t\tcompensatedTotalSum += pixelWeights[ i ];\n\n\t}\n\n\t// Fall back to raw weights if compensation zeroed everything (uniform env map)\n\tconst useCompensation = compensatedTotalSum > 0;\n\tconst totalSumValue = useCompensation ? compensatedTotalSum : rawTotalSum;\n\tconst compensationDelta = useCompensation ? meanWeight : 0;\n\n\tif ( ! useCompensation ) {\n\n\t\t// Restore raw sin-weighted luminance\n\t\tfor ( let y = 0; y < height; y ++ ) {\n\n\t\t\tconst sinTheta = Math.sin( Math.PI * ( y + 0.5 ) / height );\n\n\t\t\tfor ( let x = 0; x < width; x ++ ) {\n\n\t\t\t\tconst i = y * width + x;\n\t\t\t\tconst r = floatData[ 4 * i ];\n\t\t\t\tconst g = floatData[ 4 * i + 1 ];\n\t\t\t\tconst b = floatData[ 4 * i + 2 ];\n\t\t\t\tpixelWeights[ i ] = ( 0.2126 * r + 0.7152 * g + 0.0722 * b ) * sinTheta;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t// Pass 2: build conditional and marginal CDFs from (compensated) weights\n\tconst cdfConditional = new Float32Array( numPixels );\n\tconst cdfMarginal = new Float32Array( height );\n\n\tlet cumulativeWeightMarginal = 0.0;\n\n\tfor ( let y = 0; y < height; y ++ ) {\n\n\t\tlet cumulativeRowWeight = 0.0;\n\t\tfor ( let x = 0; x < width; x ++ ) {\n\n\t\t\tconst i = y * width + x;\n\t\t\tcumulativeRowWeight += pixelWeights[ i ];\n\t\t\tcdfConditional[ i ] = cumulativeRowWeight;\n\n\t\t}\n\n\t\t// Normalize row CDF to [0, 1]\n\t\tif ( cumulativeRowWeight !== 0 ) {\n\n\t\t\tfor ( let i = y * width, l = y * width + width; i < l; i ++ ) {\n\n\t\t\t\tcdfConditional[ i ] /= cumulativeRowWeight;\n\n\t\t\t}\n\n\t\t}\n\n\t\tcumulativeWeightMarginal += cumulativeRowWeight;\n\t\tcdfMarginal[ y ] = cumulativeWeightMarginal;\n\n\t}\n\n\t// Normalize marginal CDF to [0, 1]\n\tif ( cumulativeWeightMarginal !== 0 ) {\n\n\t\tfor ( let i = 0, l = cdfMarginal.length; i < l; i ++ ) {\n\n\t\t\tcdfMarginal[ i ] /= cumulativeWeightMarginal;\n\n\t\t}\n\n\t}\n\n\t// Invert marginal CDF\n\tconst marginalData = new Float32Array( height );\n\tfor ( let i = 0; i < height; i ++ ) {\n\n\t\tconst dist = ( i + 1 ) / height;\n\t\tconst row = binarySearchFindClosestIndexOf( cdfMarginal, dist, 0, height );\n\t\tmarginalData[ i ] = ( row + 0.5 ) / height;\n\n\t}\n\n\t// Invert conditional CDFs\n\tconst conditionalData = new Float32Array( width * height );\n\tfor ( let y = 0; y < height; y ++ ) {\n\n\t\tfor ( let x = 0; x < width; x ++ ) {\n\n\t\t\tconst i = y * width + x;\n\t\t\tconst dist = ( x + 1 ) / width;\n\t\t\tconst col = binarySearchFindClosestIndexOf( cdfConditional, dist, y * width, width );\n\t\t\tconditionalData[ i ] = ( col + 0.5 ) / width;\n\n\t\t}\n\n\t}\n\n\treturn { marginalData, conditionalData, totalSum: totalSumValue, compensationDelta };\n\n}\n\nself.onmessage = function ( e ) {\n\n\tconst { floatData, width, height } = e.data;\n\n\ttry {\n\n\t\tconst result = buildCDF( floatData, width, height );\n\n\t\t// Transfer arrays back zero-copy\n\t\tself.postMessage(\n\t\t\t{\n\t\t\t\tmarginalData: result.marginalData,\n\t\t\t\tconditionalData: result.conditionalData,\n\t\t\t\ttotalSum: result.totalSum,\n\t\t\t\tcompensationDelta: result.compensationDelta,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t},\n\t\t\t[ result.marginalData.buffer, result.conditionalData.buffer ]\n\t\t);\n\n\t} catch ( error ) {\n\n\t\tself.postMessage( { error: error.message } );\n\n\t}\n\n};\n"],"mappings":"YAQA,SAAS,EAAgC,EAAO,EAAa,EAAQ,EAAQ,CAE5E,IAAI,EAAQ,EACR,EAAQ,EAAS,EAAQ,EAE7B,KAAQ,EAAQ,GAAQ,CAEvB,IAAM,EAAQ,EAAQ,GAAW,EAE5B,EAAO,GAAQ,EAEnB,EAAQ,EAAM,EAId,EAAQ,EAMV,OAAO,EAAQ,EAIhB,SAAS,EAAU,EAAW,EAAO,EAAS,CAE7C,IAAM,EAAY,EAAQ,EAMpB,EAAe,IAAI,aAAc,EAAW,CAC9C,EAAc,EAElB,IAAM,IAAI,EAAI,EAAG,EAAI,EAAQ,IAAO,CAEnC,IAAM,EAAW,KAAK,IAAK,KAAK,IAAO,EAAI,IAAQ,EAAQ,CAE3D,IAAM,IAAI,EAAI,EAAG,EAAI,EAAO,IAAO,CAElC,IAAM,EAAI,EAAI,EAAQ,EAChB,EAAI,EAAW,EAAI,GACnB,EAAI,EAAW,EAAI,EAAI,GACvB,EAAI,EAAW,EAAI,EAAI,GAGvB,GAAM,MAAS,EAAI,MAAS,EAAI,MAAS,GAAM,EACrD,EAAc,GAAM,EACpB,GAAe,GAUjB,IAAM,EAAa,EAAc,EAC7B,EAAsB,EAE1B,IAAM,IAAI,EAAI,EAAG,EAAI,EAAW,IAE/B,EA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