three-gpu-pathtracer 0.0.24 → 0.0.26
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 +53 -530
- package/build/index.module.js +262 -50
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +261 -48
- package/build/index.umd.cjs.map +1 -1
- package/package.json +29 -11
- package/src/core/WebGLPathTracer.js +8 -0
- package/src/core/utils/sceneUpdateUtils.js +8 -12
- package/src/detectors/PrecisionMaterial.js +9 -9
- package/src/index.js +1 -0
- package/src/objects/PhysicalSpotLight.js +2 -0
- package/src/shader/bsdf/bsdf_functions.glsl.js +0 -1
- package/src/textures/BlueNoiseTexture.js +6 -6
- package/src/textures/ProceduralEquirectTexture.js +8 -7
- package/src/textures/turquinMetal.png +0 -0
- package/src/uniforms/EquirectHdrInfoUniform.js +9 -4
- package/src/uniforms/FloatAttributeTextureArray.js +11 -11
- package/src/uniforms/MaterialsTexture.js +9 -9
- package/src/webgpu/API.md +762 -0
- package/src/webgpu/AtlasTexture.js +471 -0
- package/src/webgpu/BlurredEnvMapGenerator.js +129 -0
- package/src/webgpu/EquirectBackgroundInfo.js +97 -0
- package/src/webgpu/EquirectHdrInfoNode.js +151 -0
- package/src/webgpu/LightsInfoNode.js +224 -0
- package/src/webgpu/MegaKernelPathTracer.js +277 -0
- package/src/webgpu/PathTracerBackend.js +216 -0
- package/src/webgpu/TurquinTexture.js +169 -0
- package/src/webgpu/WaveFrontPathTracer.js +586 -0
- package/src/webgpu/WebGPUPathTracer.js +1302 -0
- package/src/webgpu/compute/ComputeKernel.js +92 -0
- package/src/webgpu/compute/CopyBufferKernel.js +40 -0
- package/src/webgpu/compute/PathTracerMegaKernel.js +470 -0
- package/src/webgpu/compute/SampleDebugKernel.js +51 -0
- package/src/webgpu/compute/TallySampleCountsKernel.js +111 -0
- package/src/webgpu/compute/ZeroOutBufferKernel.js +35 -0
- package/src/webgpu/compute/ZeroOutKernel.js +31 -0
- package/src/webgpu/compute/wavefront/LogicKernel.js +349 -0
- package/src/webgpu/compute/wavefront/MaterialKernel.js +371 -0
- package/src/webgpu/compute/wavefront/PopulatePixelIndicesKernel.js +72 -0
- package/src/webgpu/compute/wavefront/QueueLengthToDispatchKernel.js +38 -0
- package/src/webgpu/compute/wavefront/ResetSlotsKernel.js +66 -0
- package/src/webgpu/compute/wavefront/TraceRayKernel.js +71 -0
- package/src/webgpu/compute/wavefront/TraceShadowRayKernel.js +67 -0
- package/src/webgpu/compute/wavefront/structs.js +155 -0
- package/src/webgpu/constants.js +62 -0
- package/src/webgpu/denoise/OIDNDenoiser.js +431 -0
- package/src/webgpu/index.d.ts +176 -0
- package/src/webgpu/index.js +11 -0
- package/src/webgpu/materials/GltfCompliantMaterial.js +608 -0
- package/src/webgpu/materials/GraphMaterial.js +331 -0
- package/src/webgpu/materials/PathtracingMaterial.js +89 -0
- package/src/webgpu/materials/RenderToScreenMaterial.js +150 -0
- package/src/webgpu/materials/debug/AtlasDebugMaterial.js +41 -0
- package/src/webgpu/materials/debug/SampleDensityMaterial.js +61 -0
- package/src/webgpu/nodes/PathtracerBVHComputeData.js +1037 -0
- package/src/webgpu/nodes/debugBounds.wgsl.js +228 -0
- package/src/webgpu/nodes/eon.wgsl.js +262 -0
- package/src/webgpu/nodes/ggx.wgsl.js +190 -0
- package/src/webgpu/nodes/lights.wgsl.js +203 -0
- package/src/webgpu/nodes/material.wgsl.js +990 -0
- package/src/webgpu/nodes/rand/bluedither.wgsl.js +92 -0
- package/src/webgpu/nodes/rand/pcg.wgsl.js +81 -0
- package/src/webgpu/nodes/rand/sobol.wgsl.js +287 -0
- package/src/webgpu/nodes/random.wgsl.js +20 -0
- package/src/webgpu/nodes/reset.wgsl.js +21 -0
- package/src/webgpu/nodes/sampling.wgsl.js +193 -0
- package/src/webgpu/nodes/sheen.wgsl.js +148 -0
- package/src/webgpu/nodes/structs.wgsl.js +272 -0
- package/src/webgpu/nodes/utils.wgsl.js +366 -0
- package/src/webgpu/shims/ArrayCameraShim.js +74 -0
- package/src/webgpu/shims/EquirectCameraShim.js +37 -0
- package/src/webgpu/shims/PhysicalCameraShim.js +151 -0
- package/src/webgpu/upscale/FSRUpscaler.js +108 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Vector2 } from 'three/webgpu';
|
|
2
|
+
/** @import { Camera, Texture, WebGPURenderer } from 'three/webgpu' */
|
|
3
|
+
|
|
4
|
+
const _size = /*@__PURE__*/ new Vector2();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Upscales a path traced image to the drawing buffer size with FSR. Pass one to
|
|
8
|
+
* "WebGPUPathTracer.setUpscaler".
|
|
9
|
+
*
|
|
10
|
+
* The "Upscaler" class is passed in rather than imported so it does not become a dependency.
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* import { Upscaler } from '@pmndrs/upscaler';
|
|
14
|
+
* pathTracer.setUpscaler( new FSRUpscaler( { Upscaler } ) );
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class FSRUpscaler {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Every field below can also be assigned after construction.
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} options
|
|
23
|
+
* @param {Function} options.Upscaler - The `Upscaler` class from `@pmndrs/upscaler`.
|
|
24
|
+
* @param {number} [options.sharpness]
|
|
25
|
+
*/
|
|
26
|
+
constructor( options = {} ) {
|
|
27
|
+
|
|
28
|
+
const { Upscaler, sharpness = 1 } = options;
|
|
29
|
+
|
|
30
|
+
if ( ! Upscaler ) {
|
|
31
|
+
|
|
32
|
+
throw new Error( 'FSRUpscaler: the "Upscaler" class from "@pmndrs/upscaler" must be provided.' );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.Upscaler = Upscaler;
|
|
37
|
+
|
|
38
|
+
// edge sharpening applied after the upscale, in [0,1]
|
|
39
|
+
this.sharpness = sharpness;
|
|
40
|
+
|
|
41
|
+
this.renderer = null;
|
|
42
|
+
|
|
43
|
+
this._upscaler = null;
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {WebGPURenderer} renderer
|
|
49
|
+
*/
|
|
50
|
+
init( renderer ) {
|
|
51
|
+
|
|
52
|
+
this.renderer = renderer;
|
|
53
|
+
this._upscaler = new this.Upscaler( { renderer } );
|
|
54
|
+
this._upscaler.init();
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Upscales a texture to the renderer's drawing buffer size.
|
|
60
|
+
*
|
|
61
|
+
* @param {Texture} source
|
|
62
|
+
* @param {Camera} camera
|
|
63
|
+
* @returns {Texture}
|
|
64
|
+
*/
|
|
65
|
+
upscale( source, camera ) {
|
|
66
|
+
|
|
67
|
+
const { renderer, _upscaler: upscaler } = this;
|
|
68
|
+
|
|
69
|
+
// the upscaler reads the raw GPUTexture, which only exists once three has initialized it
|
|
70
|
+
renderer.initTexture( source );
|
|
71
|
+
|
|
72
|
+
renderer.getDrawingBufferSize( _size );
|
|
73
|
+
|
|
74
|
+
// "configure" reallocates the working textures, so only call it when something moved
|
|
75
|
+
const changed =
|
|
76
|
+
upscaler.displayWidth !== _size.x ||
|
|
77
|
+
upscaler.displayHeight !== _size.y ||
|
|
78
|
+
upscaler.renderWidth !== source.width ||
|
|
79
|
+
upscaler.renderHeight !== source.height;
|
|
80
|
+
|
|
81
|
+
if ( changed ) {
|
|
82
|
+
|
|
83
|
+
upscaler.configure( {
|
|
84
|
+
displayWidth: _size.x,
|
|
85
|
+
displayHeight: _size.y,
|
|
86
|
+
renderWidth: source.width,
|
|
87
|
+
renderHeight: source.height,
|
|
88
|
+
|
|
89
|
+
// the temporal paths need motion vectors the path tracer does not produce
|
|
90
|
+
path: 'spatial',
|
|
91
|
+
} );
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
upscaler.settings.sharpness = this.sharpness;
|
|
96
|
+
upscaler.dispatch( { color: source }, camera );
|
|
97
|
+
return upscaler.outputTexture;
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
dispose() {
|
|
102
|
+
|
|
103
|
+
this._upscaler.dispose();
|
|
104
|
+
this._upscaler = null;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|