three-gpu-pathtracer 0.0.18 → 0.0.19
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/build/index.module.js +15 -5
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +15 -5
- package/build/index.umd.cjs.map +1 -1
- package/package.json +2 -2
- package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +4 -1
- package/src/materials/pathtracing/glsl/directLightContribution.glsl.js +1 -1
- package/src/shader/sampling/equirectSampling.glsl.js +8 -1
- package/src/uniforms/LightsInfoUniformStruct.js +1 -1
- package/src/uniforms/MaterialsTexture.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-gpu-pathtracer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"main": "build/index.umd.cjs",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"rollup": "^2.70.0",
|
|
43
43
|
"simple-git": "^3.10.0",
|
|
44
44
|
"three": "^0.160.0",
|
|
45
|
-
"three-mesh-bvh": "0.7.
|
|
45
|
+
"three-mesh-bvh": "0.7.3",
|
|
46
46
|
"yargs": "^17.5.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -309,7 +309,10 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
|
|
|
309
309
|
// inverse environment rotation
|
|
310
310
|
envRotation3x3 = mat3( environmentRotation );
|
|
311
311
|
invEnvRotation3x3 = inverse( envRotation3x3 );
|
|
312
|
-
lightsDenom =
|
|
312
|
+
lightsDenom =
|
|
313
|
+
( environmentIntensity == 0.0 || envMapInfo.totalSum == 0.0 ) && lights.count != 0u ?
|
|
314
|
+
float( lights.count ) :
|
|
315
|
+
float( lights.count + 1u );
|
|
313
316
|
|
|
314
317
|
// final color
|
|
315
318
|
gl_FragColor = vec4( 0, 0, 0, 1 );
|
|
@@ -43,7 +43,7 @@ export const directLightContributionGLSL = /*glsl*/`
|
|
|
43
43
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
} else {
|
|
46
|
+
} else if ( envMapInfo.totalSum != 0.0 && environmentIntensity != 0.0 ) {
|
|
47
47
|
|
|
48
48
|
// find a sample in the environment map to include in the contribution
|
|
49
49
|
vec3 envColor, envDirection;
|
|
@@ -26,10 +26,17 @@ export const equirectSamplingGLSL = /* glsl */`
|
|
|
26
26
|
// samples the color given env map with CDF and returns the pdf of the direction
|
|
27
27
|
float sampleEquirect( vec3 direction, inout vec3 color ) {
|
|
28
28
|
|
|
29
|
+
float totalSum = envMapInfo.totalSum;
|
|
30
|
+
if ( totalSum == 0.0 ) {
|
|
31
|
+
|
|
32
|
+
color = vec3( 0.0 );
|
|
33
|
+
return 1.0;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
vec2 uv = equirectDirectionToUv( direction );
|
|
30
38
|
color = texture2D( envMapInfo.map, uv ).rgb;
|
|
31
39
|
|
|
32
|
-
float totalSum = envMapInfo.totalSum;
|
|
33
40
|
float lum = luminance( color );
|
|
34
41
|
ivec2 resolution = textureSize( envMapInfo.map, 0 );
|
|
35
42
|
float pdf = lum / totalSum;
|
|
@@ -186,7 +186,7 @@ export class MaterialsTexture extends DataTexture {
|
|
|
186
186
|
|
|
187
187
|
let index = 0;
|
|
188
188
|
const pixelCount = materials.length * MATERIAL_PIXELS;
|
|
189
|
-
const dimension = Math.ceil( Math.sqrt( pixelCount ) );
|
|
189
|
+
const dimension = Math.ceil( Math.sqrt( pixelCount ) ) || 1;
|
|
190
190
|
const { threeCompatibilityTransforms, image, features } = this;
|
|
191
191
|
|
|
192
192
|
// get the list of textures with unique sources
|