three-gpu-pathtracer 0.0.9 → 0.0.10

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.
@@ -2082,12 +2082,11 @@ class RenderTarget2DArray extends WebGLArrayRenderTarget {
2082
2082
  function binarySearchFindClosestIndexOf( array, targetValue, offset = 0, count = array.length ) {
2083
2083
 
2084
2084
  let lower = 0;
2085
- let upper = count;
2085
+ let upper = count - 1;
2086
2086
  while ( lower < upper ) {
2087
2087
 
2088
2088
  const mid = ~ ~ ( 0.5 * upper + 0.5 * lower );
2089
2089
 
2090
-
2091
2090
  // check if the middle array value is above or below the target and shift
2092
2091
  // which half of the array we're looking at
2093
2092
  if ( array[ offset + mid ] < targetValue ) {
@@ -2294,12 +2293,13 @@ class EquirectHdrInfoUniform {
2294
2293
  const marginalDataArray = new Float32Array( height );
2295
2294
  const conditionalDataArray = new Float32Array( width * height );
2296
2295
 
2296
+ // we add a half texel offset so we're sampling the center of the pixel
2297
2297
  for ( let i = 0; i < height; i ++ ) {
2298
2298
 
2299
2299
  const dist = ( i + 1 ) / height;
2300
2300
  const row = binarySearchFindClosestIndexOf( cdfMarginal, dist );
2301
2301
 
2302
- marginalDataArray[ i ] = row / height;
2302
+ marginalDataArray[ i ] = ( row + 0.5 ) / height;
2303
2303
 
2304
2304
  }
2305
2305
 
@@ -2311,7 +2311,7 @@ class EquirectHdrInfoUniform {
2311
2311
  const dist = ( x + 1 ) / width;
2312
2312
  const col = binarySearchFindClosestIndexOf( cdfConditional, dist, y * width, width );
2313
2313
 
2314
- conditionalDataArray[ i ] = col / width;
2314
+ conditionalDataArray[ i ] = ( col + 0.5 ) / width;
2315
2315
 
2316
2316
  }
2317
2317
 
@@ -6234,7 +6234,7 @@ class PhysicalPathTracingMaterial extends MaterialBase {
6234
6234
  if ( material.clearcoatRoughnessMap != - 1 ) {
6235
6235
 
6236
6236
  vec3 uvPrime = material.clearcoatRoughnessMapTransform * vec3( uv, 1 );
6237
- clearcoat *= texture2D( textures, vec3( uvPrime.xy, material.clearcoatRoughnessMap ) ).g;
6237
+ clearcoatRoughness *= texture2D( textures, vec3( uvPrime.xy, material.clearcoatRoughnessMap ) ).g;
6238
6238
 
6239
6239
  }
6240
6240