rayzee 6.1.0 → 6.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayzee",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "type": "module",
5
5
  "description": "Real-time WebGPU path tracing engine built on Three.js",
6
6
  "main": "dist/rayzee.umd.js",
@@ -74,6 +74,16 @@ export const computeNDCDepth = /*@__PURE__*/ wgslFn( `
74
74
  }
75
75
  ` );
76
76
 
77
+ // NaN/Inf detector for debug mode 11. x != x catches NaN; the abs threshold catches Inf.
78
+ const nanInfToRed = /*@__PURE__*/ wgslFn( `
79
+ fn nanInfToRed( c: vec3f ) -> vec3f {
80
+ let isNan = c.x != c.x || c.y != c.y || c.z != c.z;
81
+ let isInf = abs( c.x ) > 1e30f || abs( c.y ) > 1e30f || abs( c.z ) > 1e30f;
82
+ if ( isNan || isInf ) { return vec3f( 1.0f, 0.0f, 0.0f ); }
83
+ return vec3f( 0.0f );
84
+ }
85
+ ` );
86
+
77
87
  // Get required samples from adaptive sampling texture
78
88
  export const getRequiredSamples = Fn( ( [
79
89
  pixelCoord, resolution,
@@ -251,8 +261,8 @@ export const pathTracerMain = ( params ) => {
251
261
 
252
262
  const sampleColor = vec4( 0.0 ).toVar();
253
263
 
254
- // Debug or normal trace
255
- If( visMode.greaterThan( int( 0 ) ), () => {
264
+ // Debug or normal trace (mode 11 runs the full path tracer so we can sniff NaN at the end)
265
+ If( visMode.greaterThan( int( 0 ) ).and( visMode.notEqual( int( 11 ) ) ), () => {
256
266
 
257
267
  sampleColor.assign( TraceDebugMode(
258
268
  ray.origin, ray.direction,
@@ -344,7 +354,7 @@ export const pathTracerMain = ( params ) => {
344
354
  // Output alpha: accumulated per-sample alpha when transparent, otherwise 1.0
345
355
  const outputAlpha = select( transparentBackground, pixelAlpha, float( 1.0 ) ).toVar();
346
356
 
347
- If( enableAccumulation.and( cameraIsMoving.not() ).and( frame.greaterThan( uint( 0 ) ) ).and( hasPreviousAccumulated ), () => {
357
+ If( enableAccumulation.and( cameraIsMoving.not() ).and( frame.greaterThan( uint( 0 ) ) ).and( hasPreviousAccumulated ).and( visMode.notEqual( int( 11 ) ) ), () => {
348
358
 
349
359
  const prevAccumSample = texture( prevAccumTexture, prevUV, 0 ).toVar();
350
360
 
@@ -361,6 +371,13 @@ export const pathTracerMain = ( params ) => {
361
371
 
362
372
  } );
363
373
 
374
+ // NaN/Inf debug: red where the path tracer output isn't finite, black otherwise.
375
+ If( visMode.equal( int( 11 ) ), () => {
376
+
377
+ finalColor.assign( nanInfToRed( finalColor ) );
378
+
379
+ } );
380
+
364
381
  // Write outputs to StorageTextures
365
382
  textureStore( writeColorTex, uintCoord, vec4( finalColor.xyz, outputAlpha ) ).toWriteOnly();
366
383
  textureStore( writeNDTex, uintCoord, finalNormalDepth ).toWriteOnly();