rayzee 5.8.2 → 5.8.3

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": "5.8.2",
3
+ "version": "5.8.3",
4
4
  "type": "module",
5
5
  "description": "Real-time WebGPU path tracing engine built on Three.js",
6
6
  "main": "dist/rayzee.umd.js",
@@ -15,7 +15,7 @@ async function getInitUNetFromURL() {
15
15
  }
16
16
 
17
17
  import { createRenderTargetHelper } from '../Processor/createRenderTargetHelper.js';
18
- import { TONE_MAP_FNS, SRGB_GAMMA, applySaturation } from '../Processor/ToneMapCPU.js';
18
+ import { TONE_MAP_FNS, linearToSRGB, applySaturation } from '../Processor/ToneMapCPU.js';
19
19
 
20
20
  /** Reusable RGB output buffer (avoids per-pixel allocation). */
21
21
  const _tmOut = new Float32Array( 3 );
@@ -724,9 +724,9 @@ export class OIDNDenoiser extends EventDispatcher {
724
724
  }
725
725
 
726
726
  tmFn( er, eg, eb, 1.0, _tmOut );
727
- tileImageData.data[ i ] = _tmOut[ 0 ] ** SRGB_GAMMA * 255 | 0;
728
- tileImageData.data[ i + 1 ] = _tmOut[ 1 ] ** SRGB_GAMMA * 255 | 0;
729
- tileImageData.data[ i + 2 ] = _tmOut[ 2 ] ** SRGB_GAMMA * 255 | 0;
727
+ tileImageData.data[ i ] = linearToSRGB( _tmOut[ 0 ] ) * 255 + 0.5 | 0;
728
+ tileImageData.data[ i + 1 ] = linearToSRGB( _tmOut[ 1 ] ) * 255 + 0.5 | 0;
729
+ tileImageData.data[ i + 2 ] = linearToSRGB( _tmOut[ 2 ] ) * 255 + 0.5 | 0;
730
730
 
731
731
  if ( alpha ) {
732
732
 
@@ -815,9 +815,9 @@ export class OIDNDenoiser extends EventDispatcher {
815
815
  }
816
816
 
817
817
  tmFn( er, eg, eb, 1.0, _tmOut );
818
- imageData.data[ i ] = _tmOut[ 0 ] ** SRGB_GAMMA * 255 | 0;
819
- imageData.data[ i + 1 ] = _tmOut[ 1 ] ** SRGB_GAMMA * 255 | 0;
820
- imageData.data[ i + 2 ] = _tmOut[ 2 ] ** SRGB_GAMMA * 255 | 0;
818
+ imageData.data[ i ] = linearToSRGB( _tmOut[ 0 ] ) * 255 + 0.5 | 0;
819
+ imageData.data[ i + 1 ] = linearToSRGB( _tmOut[ 1 ] ) * 255 + 0.5 | 0;
820
+ imageData.data[ i + 2 ] = linearToSRGB( _tmOut[ 2 ] ) * 255 + 0.5 | 0;
821
821
  imageData.data[ i + 3 ] = alpha ? alpha[ i >> 2 ] : 255;
822
822
 
823
823
  }
@@ -151,9 +151,20 @@ export const TONE_MAP_FNS = new Map( [
151
151
  [ NeutralToneMapping, neutralToneMap ]
152
152
  ] );
153
153
 
154
- /** sRGB gamma (1/2.2) */
154
+ /** sRGB gamma (1/2.2) — fast pow approximation. Prefer `linearToSRGB` when matching Three.js's output. */
155
155
  export const SRGB_GAMMA = 1 / 2.2;
156
156
 
157
+ /**
158
+ * Proper sRGB OETF, matching Three.js `sRGBTransferOETF` (`1.055 * c^(1/2.4) - 0.055`
159
+ * with a `12.92 * c` linear segment below 0.0031308). Use this when the CPU readback
160
+ * needs to match the WebGPU output pass's sRGB encoding.
161
+ */
162
+ export function linearToSRGB( c ) {
163
+
164
+ return c <= 0.0031308 ? 12.92 * c : 1.055 * Math.pow( c, 1 / 2.4 ) - 0.055;
165
+
166
+ }
167
+
157
168
  /** Rec.709 luminance coefficients (same as Display / Common.js). */
158
169
  const LUM_R = 0.2126, LUM_G = 0.7152, LUM_B = 0.0722;
159
170