three-gpu-pathtracer 0.0.26 → 0.0.28
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 +4 -2
- package/build/index.module.js +23 -5
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +22 -4
- package/build/index.umd.cjs.map +1 -1
- package/package.json +8 -8
- package/src/core/PathTracingSceneGenerator.js +1 -1
- package/src/core/utils/sceneUpdateUtils.js +2 -1
- package/src/uniforms/EquirectHdrInfoUniform.js +4 -2
- package/src/uniforms/LightsInfoUniformStruct.js +16 -1
- package/src/webgpu/API.md +167 -19
- package/src/webgpu/AtlasTexture.js +32 -12
- package/src/webgpu/EquirectHdrInfoNode.js +97 -46
- package/src/webgpu/LightsInfoNode.js +142 -4
- package/src/webgpu/MegaKernelPathTracer.js +11 -3
- package/src/webgpu/PathTracerBackend.js +174 -21
- package/src/webgpu/TurquinTexture.js +2 -0
- package/src/webgpu/WaveFrontPathTracer.js +169 -71
- package/src/webgpu/WebGPUPathTracer.js +637 -51
- package/src/webgpu/compute/ComputeKernel.js +18 -0
- package/src/webgpu/compute/PathTracerMegaKernel.js +253 -71
- package/src/webgpu/compute/TallySampleCountsKernel.js +10 -10
- package/src/webgpu/compute/UnpackAuxKernel.js +48 -0
- package/src/webgpu/compute/ZeroOutKernel.js +3 -1
- package/src/webgpu/compute/targets.js +55 -0
- package/src/webgpu/compute/wavefront/LogicKernel.js +136 -55
- package/src/webgpu/compute/wavefront/MaterialKernel.js +153 -66
- package/src/webgpu/compute/wavefront/MediumKernel.js +154 -0
- package/src/webgpu/compute/wavefront/PopulatePixelIndicesKernel.js +5 -5
- package/src/webgpu/compute/wavefront/QueueLengthToDispatchKernel.js +5 -5
- package/src/webgpu/compute/wavefront/QueueMediumWalksKernel.js +52 -0
- package/src/webgpu/compute/wavefront/ResetSlotsKernel.js +6 -6
- package/src/webgpu/compute/wavefront/TraceRayKernel.js +11 -9
- package/src/webgpu/compute/wavefront/TraceShadowRayKernel.js +18 -23
- package/src/webgpu/compute/wavefront/structs.js +63 -35
- package/src/webgpu/constants.js +2 -2
- package/src/webgpu/denoise/OIDNDenoiser.js +81 -78
- package/src/webgpu/index.d.ts +79 -6
- package/src/webgpu/materials/GltfCompliantMaterial.js +20 -6
- package/src/webgpu/materials/debug/AuxDebugMaterial.js +54 -0
- package/src/webgpu/nodes/PathtracerBVHComputeData.js +109 -17
- package/src/webgpu/nodes/aux.wgsl.js +61 -0
- package/src/webgpu/nodes/eon.wgsl.js +1 -1
- package/src/webgpu/nodes/lights.wgsl.js +21 -1
- package/src/webgpu/nodes/material.wgsl.js +2 -1
- package/src/webgpu/nodes/medium.wgsl.js +165 -0
- package/src/webgpu/nodes/random.wgsl.js +2 -0
- package/src/webgpu/nodes/sampling.wgsl.js +44 -3
- package/src/webgpu/nodes/structs.wgsl.js +8 -1
- package/src/webgpu/upscale/FSRUpscaler.js +3 -2
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/three-gpu-pathtracer)
|
|
4
4
|
[](https://github.com/gkjohnson/three-gpu-pathtracer/actions)
|
|
5
|
+
[](https://gkjohnson.github.io/tools/docs/three-gpu-pathtracer/)
|
|
5
6
|
[](https://github.com/gkjohnson/three-gpu-pathtracer/)
|
|
6
7
|
[](https://twitter.com/garrettkjohnson)
|
|
7
8
|
[](https://github.com/sponsors/gkjohnson/)
|
|
@@ -103,7 +104,9 @@ scene.environment = blurredEnvMap;
|
|
|
103
104
|
|
|
104
105
|
# API
|
|
105
106
|
|
|
106
|
-
See [
|
|
107
|
+
See the [docs site](https://gkjohnson.github.io/tools/docs/three-gpu-pathtracer/) for the WebGPU API documentation.
|
|
108
|
+
|
|
109
|
+
The same documentation is also available as markdown in [API.md](./src/webgpu/API.md).
|
|
107
110
|
|
|
108
111
|
# Gotchas
|
|
109
112
|
|
|
@@ -111,7 +114,6 @@ See [API.md](./src/webgpu/API.md) for the WebGPU API documentation.
|
|
|
111
114
|
- SpotLights, DirectionalLights, and PointLights are only supported with MIS.
|
|
112
115
|
- Only MeshStandardMaterial and MeshPhysicalMaterial are supported.
|
|
113
116
|
- Emissive materials are supported but do not take advantage of MIS.
|
|
114
|
-
- "Upscaling" does not currently work with a transparent background.
|
|
115
117
|
|
|
116
118
|
# Screenshots
|
|
117
119
|
|
package/build/index.module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BufferAttribute, BufferGeometry, Matrix4, Vector3, Vector4, Matrix3, MeshBasicMaterial, Mesh, ShaderMaterial, NoBlending, Vector2, WebGLRenderTarget, FloatType, RGBAFormat, NearestFilter, PerspectiveCamera, DataUtils, HalfFloatType,
|
|
1
|
+
import { BufferAttribute, BufferGeometry, Matrix4, Vector3, Vector4, Matrix3, MeshBasicMaterial, Mesh, ShaderMaterial, NoBlending, Vector2, WebGLRenderTarget, FloatType, RGBAFormat, NearestFilter, PerspectiveCamera, DataUtils, HalfFloatType, TextureSource, DataTexture, LinearFilter, RepeatWrapping, RedFormat, ClampToEdgeWrapping, Quaternion, DataArrayTexture, DoubleSide, BackSide, FrontSide, Color, WebGLArrayRenderTarget, UnsignedByteType, NoToneMapping, RGFormat, NormalBlending, Spherical, EquirectangularReflectionMapping, LinearMipMapLinearFilter, Clock, Scene, AdditiveBlending, Camera, SpotLight, RectAreaLight, PMREMGenerator, MeshStandardMaterial, TangentSpaceNormalMap } from 'three';
|
|
2
2
|
import { SAH, MeshBVH, FloatVertexAttributeTexture, MeshBVHUniformStruct, UIntVertexAttributeTexture, BVHShaderGLSL } from 'three-mesh-bvh';
|
|
3
3
|
import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js';
|
|
4
4
|
|
|
@@ -1410,7 +1410,7 @@ class PathTracingSceneGenerator {
|
|
|
1410
1410
|
// generate the geometry
|
|
1411
1411
|
const result = staticGeometryGenerator.generate( geometry );
|
|
1412
1412
|
const materials = result.materials;
|
|
1413
|
-
let needsMaterialIndexUpdate = result.changeType !== NO_CHANGE || this._materialUuids === null || this._materialUuids.length !== length;
|
|
1413
|
+
let needsMaterialIndexUpdate = result.changeType !== NO_CHANGE || this._materialUuids === null || this._materialUuids.length !== materials.length;
|
|
1414
1414
|
if ( ! needsMaterialIndexUpdate ) {
|
|
1415
1415
|
|
|
1416
1416
|
for ( let i = 0, length = materials.length; i < length; i ++ ) {
|
|
@@ -2110,7 +2110,7 @@ function colorToLuminance( r, g, b ) {
|
|
|
2110
2110
|
function preprocessEnvMap( envMap, targetType = HalfFloatType ) {
|
|
2111
2111
|
|
|
2112
2112
|
const map = envMap.clone();
|
|
2113
|
-
map.source = new
|
|
2113
|
+
map.source = new TextureSource( { ...map.image } );
|
|
2114
2114
|
const { width, height, data } = map.image;
|
|
2115
2115
|
|
|
2116
2116
|
// TODO: is there a simple way to avoid cloning and adjusting the env map data here?
|
|
@@ -2379,12 +2379,15 @@ class EquirectHdrInfoUniform {
|
|
|
2379
2379
|
|
|
2380
2380
|
this.totalSum = totalSumValue;
|
|
2381
2381
|
this.map = map;
|
|
2382
|
+
this.cdfMarginal = cdfMarginal;
|
|
2383
|
+
this.cdfConditional = cdfConditional;
|
|
2382
2384
|
|
|
2383
2385
|
}
|
|
2384
2386
|
|
|
2385
2387
|
}
|
|
2386
2388
|
|
|
2387
2389
|
const LIGHT_PIXELS = 6;
|
|
2390
|
+
const VISIBLE_TO_CAMERA_OFFSET = 11;
|
|
2388
2391
|
const RECT_AREA_LIGHT = 0;
|
|
2389
2392
|
const CIRC_AREA_LIGHT = 1;
|
|
2390
2393
|
const SPOT_LIGHT = 2;
|
|
@@ -2465,7 +2468,7 @@ class LightsInfoUniformStruct {
|
|
|
2465
2468
|
|
|
2466
2469
|
type = SPOT_LIGHT;
|
|
2467
2470
|
|
|
2468
|
-
} else if ( l.isDirectionalLight ) {
|
|
2471
|
+
} else if ( l.isDirectionalLight || l.isSunLight ) {
|
|
2469
2472
|
|
|
2470
2473
|
type = DIR_LIGHT;
|
|
2471
2474
|
|
|
@@ -2590,8 +2593,22 @@ class LightsInfoUniformStruct {
|
|
|
2590
2593
|
floatArray[ baseIndex + ( index ++ ) ] = target.y;
|
|
2591
2594
|
floatArray[ baseIndex + ( index ++ ) ] = target.z;
|
|
2592
2595
|
|
|
2596
|
+
} else if ( l.isSunLight ) {
|
|
2597
|
+
|
|
2598
|
+
// the sun has no target and shines from its position toward the origin
|
|
2599
|
+
target.setFromMatrixPosition( l.matrixWorld ).normalize();
|
|
2600
|
+
|
|
2601
|
+
// sample 3
|
|
2602
|
+
// u vector
|
|
2603
|
+
floatArray[ baseIndex + ( index ++ ) ] = target.x;
|
|
2604
|
+
floatArray[ baseIndex + ( index ++ ) ] = target.y;
|
|
2605
|
+
floatArray[ baseIndex + ( index ++ ) ] = target.z;
|
|
2606
|
+
|
|
2593
2607
|
}
|
|
2594
2608
|
|
|
2609
|
+
// whether camera rays see the light
|
|
2610
|
+
floatArray[ baseIndex + VISIBLE_TO_CAMERA_OFFSET ] = l.visibleToCameraRays ? 1 : 0;
|
|
2611
|
+
|
|
2595
2612
|
}
|
|
2596
2613
|
|
|
2597
2614
|
this.count = lights.length;
|
|
@@ -2892,7 +2909,8 @@ function getLights( scene ) {
|
|
|
2892
2909
|
c.isRectAreaLight ||
|
|
2893
2910
|
c.isSpotLight ||
|
|
2894
2911
|
c.isPointLight ||
|
|
2895
|
-
c.isDirectionalLight
|
|
2912
|
+
c.isDirectionalLight ||
|
|
2913
|
+
c.isSunLight
|
|
2896
2914
|
) {
|
|
2897
2915
|
|
|
2898
2916
|
lights.push( c );
|