three-gpu-pathtracer 0.0.24 → 0.0.25
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 +28 -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
package/README.md
CHANGED
|
@@ -6,88 +6,69 @@
|
|
|
6
6
|
[](https://twitter.com/garrettkjohnson)
|
|
7
7
|
[](https://github.com/sponsors/gkjohnson/)
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|
|
|
11
|
-
Path tracing project using [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) and
|
|
12
|
-
|
|
13
|
-
_More features and capabilities in progress!_
|
|
11
|
+
Path tracing project using [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) and WebGPU compute shaders to accelerate high quality, physically based rendering on the GPU.
|
|
14
12
|
|
|
15
13
|
# Examples
|
|
16
14
|
|
|
17
|
-
[GLB Drag and Drop Viewer](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/viewer.html)
|
|
18
|
-
|
|
19
15
|
**Setup**
|
|
20
16
|
|
|
21
|
-
[Basic glTF Setup Example](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
17
|
+
[Basic glTF Setup Example](https://gkjohnson.github.io/three-gpu-pathtracer/basic.html)
|
|
22
18
|
|
|
23
|
-
[Basic Primitive Geometry Example](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
19
|
+
[Basic Primitive Geometry Example](https://gkjohnson.github.io/three-gpu-pathtracer/primitives.html)
|
|
24
20
|
|
|
25
21
|
**Beauty Demos**
|
|
26
22
|
|
|
27
|
-
[Physically Based Materials](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
28
|
-
|
|
29
|
-
[Lego Models](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/lego.html)
|
|
23
|
+
[Physically Based Materials](https://gkjohnson.github.io/three-gpu-pathtracer/index.html)
|
|
30
24
|
|
|
31
|
-
[Interior Scene w/ Equirect Rendering](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
25
|
+
[Interior Scene w/ Equirect Rendering](https://gkjohnson.github.io/three-gpu-pathtracer/equirect.html)
|
|
32
26
|
|
|
33
|
-
[Depth of Field](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
27
|
+
[Depth of Field](https://gkjohnson.github.io/three-gpu-pathtracer/depthOfField.html)
|
|
34
28
|
|
|
35
|
-
[HDR Image](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
29
|
+
[HDR Image](https://gkjohnson.github.io/three-gpu-pathtracer/hdr.html)
|
|
36
30
|
|
|
37
31
|
**Features**
|
|
38
32
|
|
|
39
|
-
[
|
|
40
|
-
|
|
41
|
-
[Morph Target Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/skinnedMesh.html#morphtarget)
|
|
42
|
-
|
|
43
|
-
[Area Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/areaLight.html)
|
|
33
|
+
[Area Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/areaLight.html)
|
|
44
34
|
|
|
45
|
-
[Spot Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
35
|
+
[Spot Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/spotLights.html)
|
|
46
36
|
|
|
47
|
-
[
|
|
37
|
+
[Denoising and Upscaling](https://gkjohnson.github.io/three-gpu-pathtracer/denoise.html)
|
|
48
38
|
|
|
49
39
|
**Test Scenes**
|
|
50
40
|
|
|
51
|
-
[Material Test Orb](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
41
|
+
[Material Test Orb](https://gkjohnson.github.io/three-gpu-pathtracer/materialOrb.html)
|
|
52
42
|
|
|
53
|
-
[
|
|
54
|
-
|
|
55
|
-
[Model Viewer Fidelity Scene Comparisons](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/viewerTest.html)
|
|
56
|
-
|
|
57
|
-
[Physical Material Database](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialDatabase.html)
|
|
43
|
+
[Model Viewer Fidelity Scene Comparisons](https://gkjohnson.github.io/three-gpu-pathtracer/viewerTest.html)
|
|
58
44
|
|
|
59
45
|
**Tools**
|
|
60
46
|
|
|
61
|
-
[Animation Rendering](https://gkjohnson.github.io/three-gpu-pathtracer/
|
|
62
|
-
|
|
63
|
-
[Ambient Occlusion Material](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/aoRender.html)
|
|
47
|
+
[Animation Rendering](https://gkjohnson.github.io/three-gpu-pathtracer/renderVideo.html)
|
|
64
48
|
|
|
65
49
|
## Running examples locally
|
|
66
50
|
|
|
67
|
-
To run and modify the examples locally, make sure you have Node and NPM installed.
|
|
68
|
-
|
|
69
|
-
In order to install dependencies, you will need `make` and a C++ compiler available.
|
|
70
|
-
|
|
71
|
-
On Debian or Ubuntu, run `sudo apt install build-essential`. It should just work on MacOS.
|
|
51
|
+
To run and modify the examples locally, make sure you have Node and NPM installed. Check the supported versions in [the test configuration](./.github/workflows/node.js.yml).
|
|
72
52
|
|
|
73
53
|
- To install dependencies, run `npm install`
|
|
74
54
|
- To start the demos run `npm start`
|
|
75
|
-
- Visit `http://localhost:
|
|
55
|
+
- Visit `http://localhost:5173/<demo-name.html>`
|
|
76
56
|
|
|
77
57
|
# Use
|
|
78
58
|
|
|
79
59
|
**Basic Renderer**
|
|
80
60
|
|
|
81
61
|
```js
|
|
82
|
-
import * as THREE from 'three';
|
|
83
|
-
import {
|
|
62
|
+
import * as THREE from 'three/webgpu';
|
|
63
|
+
import { WebGPUPathTracer } from 'three-gpu-pathtracer/webgpu';
|
|
84
64
|
|
|
85
65
|
// init scene, camera, controls, etc
|
|
86
66
|
|
|
87
|
-
renderer = new THREE.
|
|
67
|
+
renderer = new THREE.WebGPURenderer();
|
|
88
68
|
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
69
|
+
await renderer.init();
|
|
89
70
|
|
|
90
|
-
pathTracer = new
|
|
71
|
+
pathTracer = new WebGPUPathTracer( renderer );
|
|
91
72
|
pathTracer.setScene( scene, camera );
|
|
92
73
|
|
|
93
74
|
animate();
|
|
@@ -102,544 +83,84 @@ function animate() {
|
|
|
102
83
|
|
|
103
84
|
**Blurred Environment Map**
|
|
104
85
|
|
|
105
|
-
Using a pre blurred
|
|
86
|
+
Using a pre blurred environment map can help improve frame convergence time at the cost of sharp environment reflections. If performance is a concern then multiple importance sampling can be disabled and a blurred environment map used.
|
|
106
87
|
|
|
107
88
|
```js
|
|
108
|
-
import { BlurredEnvMapGenerator } from 'three-gpu-pathtracer';
|
|
89
|
+
import { BlurredEnvMapGenerator } from 'three-gpu-pathtracer/webgpu';
|
|
109
90
|
|
|
110
91
|
// ...
|
|
111
92
|
|
|
112
|
-
const envMap = await new HDRLoader().
|
|
93
|
+
const envMap = await new HDRLoader().loadAsync( envMapUrl );
|
|
113
94
|
const generator = new BlurredEnvMapGenerator( renderer );
|
|
114
|
-
const blurredEnvMap = generator.generate( envMap, 0.35 );
|
|
115
|
-
|
|
116
|
-
// render!
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
# Exports
|
|
121
|
-
|
|
122
|
-
## WebGLPathTracer
|
|
123
|
-
|
|
124
|
-
### constructor
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
constructor( renderer : WebGLRenderer )
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### .bounces
|
|
131
|
-
|
|
132
|
-
```js
|
|
133
|
-
bounces = 10 : Number
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Max number of lights bounces to trace.
|
|
137
|
-
|
|
138
|
-
### .filterGlossyFactor
|
|
139
|
-
|
|
140
|
-
```js
|
|
141
|
-
filterGlossyFactor = 0 : Number
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Factor for alleviating bright pixels from rays that hit diffuse surfaces then specular surfaces. Setting this higher alleviates fireflies but will remove some specular caustics.
|
|
145
|
-
|
|
146
|
-
### .tiles
|
|
147
|
-
|
|
148
|
-
```js
|
|
149
|
-
tiles = ( 3, 3 ) : Vector2
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
Number of tiles on x and y to render to. Can be used to improve the responsiveness of a page while still rendering a high resolution target.
|
|
153
|
-
|
|
154
|
-
### .renderDelay
|
|
155
|
-
|
|
156
|
-
```js
|
|
157
|
-
renderDelay = 100 : Number
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Number of milliseconds to delay rendering samples after the path tracer has been reset.
|
|
161
|
-
|
|
162
|
-
### .fadeDuration
|
|
163
|
-
|
|
164
|
-
```js
|
|
165
|
-
fadeDuration = 500 : Number
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
How long to take to fade the fully path traced scene in in milliseconds wen rendering to the canvas.
|
|
169
|
-
|
|
170
|
-
### .minSamples
|
|
171
|
-
|
|
172
|
-
```js
|
|
173
|
-
minSamples = 5 : Number
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
How many samples to render before displaying to the canvas.
|
|
177
|
-
|
|
178
|
-
### .dynamicLowRes
|
|
179
|
-
|
|
180
|
-
```js
|
|
181
|
-
dynamicLowRes = false : Boolean
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Whether to render an extra low resolution of the scene while the full resolution renders. The scale is defined by `lowResScale`.
|
|
185
|
-
|
|
186
|
-
### .lowResScale
|
|
187
|
-
|
|
188
|
-
```js
|
|
189
|
-
lowResScale = 0.1 : Number
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
The scale to render the low resolution pass at.
|
|
193
|
-
|
|
194
|
-
### .synchronizeRenderSize
|
|
195
|
-
|
|
196
|
-
```js
|
|
197
|
-
synchronizeRenderSize = true : Boolean
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
Whether to automatically update the sie of the path traced buffer when the canvas size changes.
|
|
201
|
-
|
|
202
|
-
### .renderScale
|
|
203
|
-
|
|
204
|
-
```js
|
|
205
|
-
renderScale = 1 : Number
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
The scale to render the path traced image at. Only relevant if `synchronizeRenderSize` is true.
|
|
209
|
-
|
|
210
|
-
### .renderToCanvas
|
|
211
|
-
|
|
212
|
-
```js
|
|
213
|
-
renderToCanvas = true : Boolean
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
Whether to automatically render the path traced buffer to the canvas when `renderSample` is called.
|
|
217
|
-
|
|
218
|
-
### .rasterizeScene
|
|
219
|
-
|
|
220
|
-
```js
|
|
221
|
-
rasterizeScene = true : Boolean
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Whether to automatically rasterize the scene with the three.js renderer while the path traced buffer is rendering.
|
|
225
|
-
|
|
226
|
-
### .textureSize
|
|
227
|
-
|
|
228
|
-
```js
|
|
229
|
-
textureSize = ( 1024, 1024 ) : Vector2
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
The dimensions to expand or shrink all textures to so all scene textures can be packed into a single texture array.
|
|
233
|
-
|
|
234
|
-
### .samples
|
|
235
|
-
|
|
236
|
-
```js
|
|
237
|
-
readonly samples : Number
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
The number of samples that have been rendered.
|
|
241
|
-
|
|
242
|
-
### .target
|
|
243
|
-
|
|
244
|
-
```js
|
|
245
|
-
readonly target : WebGLRenderTarget
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
The path traced render target. This potentially changes every call to `renderSample`.
|
|
249
|
-
|
|
250
|
-
### .setScene
|
|
251
|
-
|
|
252
|
-
```js
|
|
253
|
-
setScene( scene : Scene, camera : Camera ) : void
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
Sets the scene and camera to render. Must be called again when the camera object changes, the geometry in the scene changes, or new materials are assigned.
|
|
257
|
-
|
|
258
|
-
While only changed data is updated it is still a relatively expensive function. Prefer to use the other "update" functions where possible.
|
|
259
|
-
|
|
260
|
-
### .setSceneAsync
|
|
261
|
-
|
|
262
|
-
```js
|
|
263
|
-
setSceneAsync(
|
|
264
|
-
scene : Scene,
|
|
265
|
-
camera : Camera,
|
|
266
|
-
options = {
|
|
267
|
-
onProgress = null : value => void,
|
|
268
|
-
} : Object
|
|
269
|
-
) : void
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
Asynchronous version of `setScene`. Requires calling `setBVHWorker` first.
|
|
273
|
-
|
|
274
|
-
### .updateCamera
|
|
275
|
-
|
|
276
|
-
```js
|
|
277
|
-
updateCamera() : void
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
Updates the camera parameters. Must be called if any of the parameters on the previously set camera change.
|
|
281
|
-
|
|
282
|
-
### .updateMaterials
|
|
283
|
-
|
|
284
|
-
```js
|
|
285
|
-
updateMaterials() : void
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Updates the material properties. Must be called when properties change for any materials already being used.
|
|
289
|
-
|
|
290
|
-
Note that materials used with WebGLPathTracer support the following additional properties:
|
|
291
|
-
|
|
292
|
-
```js
|
|
293
|
-
// Whether to render the object as completely transparent against the rest
|
|
294
|
-
// of the environment so other objects can be composited later
|
|
295
|
-
matte = false : Boolean;
|
|
296
|
-
|
|
297
|
-
// Whether the object should cast a shadow
|
|
298
|
-
castShadow = true : Boolean;
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
### .updateEnvironment
|
|
302
|
-
|
|
303
|
-
```js
|
|
304
|
-
updateEnvironment() : void
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
Updates lighting from the scene environment and background properties. Must be called if any associated scene settings change on the set scene object.
|
|
308
|
-
|
|
309
|
-
### .updateLights
|
|
310
|
-
|
|
311
|
-
```js
|
|
312
|
-
updateLights() : void
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
Updates lights used in path tracing. Must be called if any lights are added or removed or properties change.
|
|
316
|
-
|
|
317
|
-
### .renderSample
|
|
318
|
-
|
|
319
|
-
```js
|
|
320
|
-
renderSample() : void
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
Render a single sample to the path tracer target. If `renderToCanvas` is true then the image is rendered to the canvas.
|
|
324
|
-
|
|
325
|
-
### .reset
|
|
326
|
-
|
|
327
|
-
```js
|
|
328
|
-
reset() : void
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
Restart the rendering.
|
|
332
|
-
|
|
333
|
-
### .dispose
|
|
334
|
-
|
|
335
|
-
```js
|
|
336
|
-
dispose() : void
|
|
337
|
-
```
|
|
95
|
+
const blurredEnvMap = await generator.generate( envMap, 0.35 );
|
|
96
|
+
generator.dispose();
|
|
338
97
|
|
|
339
|
-
|
|
98
|
+
scene.environment = blurredEnvMap;
|
|
340
99
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
_extends THREE.PerspectiveCamera_
|
|
344
|
-
|
|
345
|
-
An extension of the three.js PerspectiveCamera with some other parameters associated with depth of field. These parameters otherwise do not affect the camera behavior are are for convenience of use with the PhysicalCameraUniform and pathtracer.
|
|
346
|
-
|
|
347
|
-
### .focusDistance
|
|
348
|
-
|
|
349
|
-
```js
|
|
350
|
-
focusDistance = 25 : Number
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
The distance from the camera in meters that everything is is perfect focus.
|
|
354
|
-
|
|
355
|
-
### .fStop
|
|
356
|
-
|
|
357
|
-
```js
|
|
358
|
-
fStop = 1.4 : Number
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
The fstop value of the camera. If this is changed then the `bokehSize` field is implicitly updated.
|
|
362
|
-
|
|
363
|
-
### .bokehSize
|
|
364
|
-
|
|
365
|
-
```js
|
|
366
|
-
bokehSize : Number
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
The bokeh size as derived from the fStop and focal length in millimeters. If this is set then the fStop is implicitly updated.
|
|
370
|
-
|
|
371
|
-
### .apertureBlades
|
|
372
|
-
|
|
373
|
-
```js
|
|
374
|
-
apertureBlades = 0 : Number
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
The number of sides / blades on the aperture.
|
|
378
|
-
|
|
379
|
-
### .apertureRotation
|
|
380
|
-
|
|
381
|
-
```js
|
|
382
|
-
apertureRotation = 0 : Number
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
The rotation of the aperture shape in radians.
|
|
386
|
-
|
|
387
|
-
### .anamorphicRatio
|
|
388
|
-
|
|
389
|
-
```js
|
|
390
|
-
anamorphicRatio = 1 : Number
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
The anamorphic ratio of the lens. A higher value will stretch the bokeh effect horizontally.
|
|
394
|
-
|
|
395
|
-
## EquirectCamera
|
|
396
|
-
|
|
397
|
-
_extends THREE.Camera_
|
|
398
|
-
|
|
399
|
-
A class indicating that the path tracer should render an equirectangular view. Does not work with three.js raster rendering.
|
|
400
|
-
|
|
401
|
-
## PhysicalSpotLight
|
|
402
|
-
|
|
403
|
-
_extends THREE.SpotLight_
|
|
404
|
-
|
|
405
|
-
### .radius
|
|
406
|
-
|
|
407
|
-
```js
|
|
408
|
-
radius = 0 : Number
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
The radius of the spotlight surface. Increase this value to add softness to shadows.
|
|
412
|
-
|
|
413
|
-
### .iesMap
|
|
414
|
-
|
|
415
|
-
```js
|
|
416
|
-
iesMap = null : Texture
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
The loaded IES texture describing directional light intensity. These can be loaded with the `IESLoader`.
|
|
420
|
-
|
|
421
|
-
Premade IES profiles can be downloaded from [ieslibrary.com]. And custom profiles can be generated using [CNDL](https://cndl.io/).
|
|
422
|
-
|
|
423
|
-
## ShapedAreaLight
|
|
424
|
-
|
|
425
|
-
_extends THREE.RectAreaLight_
|
|
426
|
-
|
|
427
|
-
### .isCircular
|
|
428
|
-
|
|
429
|
-
```js
|
|
430
|
-
isCircular = false : Boolean
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
Whether the area light should be rendered as a circle or a rectangle.
|
|
434
|
-
|
|
435
|
-
## IESLoader
|
|
436
|
-
|
|
437
|
-
_extends Loader_
|
|
438
|
-
|
|
439
|
-
Loader for loading and parsing IES profile data. Load and parse functions return a `DataTexture` with the profile contents.
|
|
440
|
-
|
|
441
|
-
## BlurredEnvMapGenerator
|
|
442
|
-
|
|
443
|
-
Utility for generating a PMREM blurred environment map that can be used with the path tracer.
|
|
444
|
-
|
|
445
|
-
### constructor
|
|
446
|
-
|
|
447
|
-
```js
|
|
448
|
-
constructor( renderer : WebGLRenderer )
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
### .generate
|
|
452
|
-
|
|
453
|
-
```js
|
|
454
|
-
generate( texture : Texture, blur : Number ) : DataTexture
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
Takes a texture to blur and the amount to blur it. Returns a new `DataTexture` that has been PMREM blurred environment map that can have distribution data generated for importance sampling.
|
|
458
|
-
|
|
459
|
-
### .dispose
|
|
460
|
-
|
|
461
|
-
```js
|
|
462
|
-
dispose() : void
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
Disposes of the temporary files and textures for generation.
|
|
466
|
-
|
|
467
|
-
## GradientEquirectTexture
|
|
468
|
-
|
|
469
|
-
### .exponent
|
|
470
|
-
|
|
471
|
-
```js
|
|
472
|
-
exponent = 2 : Number
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
### .topColor
|
|
476
|
-
|
|
477
|
-
```js
|
|
478
|
-
topColor = 0xffffff : Color
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
### .bottomColor
|
|
482
|
-
|
|
483
|
-
```js
|
|
484
|
-
bottomColor = 0x000000 : Color
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
### constructor
|
|
488
|
-
|
|
489
|
-
```js
|
|
490
|
-
constructor( resolution = 512 : Number )
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
### .update
|
|
494
|
-
|
|
495
|
-
```js
|
|
496
|
-
update() : void
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
## MaterialBase
|
|
500
|
-
|
|
501
|
-
_extends THREE.ShaderMaterial_
|
|
502
|
-
|
|
503
|
-
Convenience base class that adds additional functions and implicitly adds object definitions for all uniforms of the shader to the object.
|
|
504
|
-
|
|
505
|
-
### .setDefine
|
|
506
|
-
|
|
507
|
-
```js
|
|
508
|
-
setDefine( name : string, value = undefined : any ) : void
|
|
509
|
-
```
|
|
510
|
-
|
|
511
|
-
Sets the define of the given name to the provided value. If the value is set to null or undefined then it is deleted from the defines of the material. If the define changed from the previous value then `Material.needsUpdate` is set to `true`.
|
|
512
|
-
|
|
513
|
-
## FogVolumeMaterial
|
|
514
|
-
|
|
515
|
-
_extends MeshStandardMaterial_
|
|
516
|
-
|
|
517
|
-
A material used for rendering fog-like volumes within the scene. The `color`, `emissive`, and `emissiveIntensity` fields are all used in the render.
|
|
518
|
-
|
|
519
|
-
> *NOTE*
|
|
520
|
-
> Since fog models many particles throughout the scene and cause many extra bounces fog materials can dramatically impact render time.
|
|
521
|
-
|
|
522
|
-
### .density
|
|
523
|
-
|
|
524
|
-
The particulate density of the volume.
|
|
525
|
-
|
|
526
|
-
## DenoiseMaterial
|
|
527
|
-
|
|
528
|
-
_extends MaterialBase_
|
|
529
|
-
|
|
530
|
-
Denoise material based on [BrutPitt/glslSmartDeNoise](https://github.com/BrutPitt/glslSmartDeNoise) intended to be the final pass to the screen. Includes tonemapping and color space conversions.
|
|
531
|
-
|
|
532
|
-
**Uniforms**
|
|
533
|
-
|
|
534
|
-
```js
|
|
535
|
-
{
|
|
536
|
-
|
|
537
|
-
// sigma - sigma Standard Deviation
|
|
538
|
-
// kSigma - sigma coefficient
|
|
539
|
-
// kSigma * sigma = radius of the circular kernel
|
|
540
|
-
sigma = 5.0 : Number,
|
|
541
|
-
kSigma = 1.0 : Number,
|
|
542
|
-
|
|
543
|
-
// edge sharpening threshold
|
|
544
|
-
threshold = 0.03 : Number,
|
|
545
|
-
|
|
546
|
-
}
|
|
547
|
-
```
|
|
548
|
-
<!--
|
|
549
|
-
|
|
550
|
-
## CompatibilityDetector
|
|
551
|
-
|
|
552
|
-
Detects whether the path tracer can run on the current device by checking whether struct precision is reliable and the material shader will compile.
|
|
553
|
-
|
|
554
|
-
### constructor
|
|
555
|
-
|
|
556
|
-
```js
|
|
557
|
-
constructor( renderer : WebGLRenderer, material : Material )
|
|
558
|
-
```
|
|
559
|
-
|
|
560
|
-
Takes a WebGLRenderer to use and material to test again.
|
|
561
|
-
|
|
562
|
-
### .detect
|
|
100
|
+
// render!
|
|
563
101
|
|
|
564
|
-
```js
|
|
565
|
-
detect() : {
|
|
566
|
-
pass: Boolean,
|
|
567
|
-
message: String
|
|
568
|
-
}
|
|
569
102
|
```
|
|
570
103
|
|
|
571
|
-
|
|
104
|
+
# API
|
|
572
105
|
|
|
573
|
-
|
|
106
|
+
See [API.md](./src/webgpu/API.md) for the WebGPU API documentation.
|
|
574
107
|
|
|
575
108
|
# Gotchas
|
|
576
109
|
|
|
577
|
-
- The project requires
|
|
578
|
-
- All textures must use the same wrap and interpolation flags.
|
|
110
|
+
- The project requires WebGPU.
|
|
579
111
|
- SpotLights, DirectionalLights, and PointLights are only supported with MIS.
|
|
580
112
|
- Only MeshStandardMaterial and MeshPhysicalMaterial are supported.
|
|
581
|
-
- Instanced geometry and interleaved buffers are not supported.
|
|
582
113
|
- Emissive materials are supported but do not take advantage of MIS.
|
|
114
|
+
- "Upscaling" does not currently work with a transparent background.
|
|
583
115
|
|
|
584
116
|
# Screenshots
|
|
585
117
|
|
|
586
|
-

|
|
587
|
-
|
|
588
118
|
<p align="center">
|
|
589
|
-
<
|
|
119
|
+
<img src="./docs/rover.webp" />
|
|
590
120
|
</p>
|
|
591
121
|
|
|
592
|
-

|
|
593
|
-
|
|
594
|
-

|
|
595
|
-
|
|
596
122
|
<p align="center">
|
|
597
|
-
<
|
|
123
|
+
<img src="./docs/lit-stairway.webp" />
|
|
598
124
|
</p>
|
|
599
125
|
|
|
600
|
-

|
|
601
|
-
|
|
602
126
|
<p align="center">
|
|
603
|
-
<
|
|
127
|
+
<img src="./docs/kitchen.webp" />
|
|
604
128
|
</p>
|
|
605
129
|
|
|
606
|
-

|
|
607
|
-
|
|
608
|
-

|
|
609
|
-
|
|
610
130
|
<p align="center">
|
|
611
|
-
<
|
|
131
|
+
<img src="./docs/tropical-island.webp" />
|
|
612
132
|
</p>
|
|
613
133
|
|
|
614
|
-

|
|
615
|
-
|
|
616
134
|
<p align="center">
|
|
617
|
-
<
|
|
135
|
+
<img src="./docs/coffee-maker.webp" />
|
|
618
136
|
</p>
|
|
619
137
|
|
|
620
|
-
|
|
138
|
+
<p align="center">
|
|
139
|
+
<img src="./docs/porsche.webp" />
|
|
140
|
+
</p>
|
|
621
141
|
|
|
622
|
-
|
|
142
|
+
<p align="center">
|
|
143
|
+
<img src="./docs/insight.webp" />
|
|
144
|
+
</p>
|
|
623
145
|
|
|
624
146
|
<p align="center">
|
|
625
|
-
<
|
|
147
|
+
<img src="./docs/apollo-lego.webp" />
|
|
626
148
|
</p>
|
|
627
149
|
|
|
628
|
-
|
|
150
|
+
<p align="center">
|
|
151
|
+
<img src="./docs/stormtroopers.webp" />
|
|
152
|
+
</p>
|
|
629
153
|
|
|
630
154
|
<p align="center">
|
|
631
|
-
<
|
|
632
|
-
">AzTiZ</a></i>
|
|
155
|
+
<img src="./docs/tea-set.webp" />
|
|
633
156
|
</p>
|
|
634
157
|
|
|
635
|
-

|
|
636
158
|
<p align="center">
|
|
637
|
-
<
|
|
159
|
+
<img src="./docs/octopus-tea.webp" />
|
|
638
160
|
</p>
|
|
639
161
|
|
|
640
|
-

|
|
641
162
|
<p align="center">
|
|
642
|
-
<
|
|
163
|
+
<img src="./docs/sasha-ring.webp" />
|
|
643
164
|
</p>
|
|
644
165
|
|
|
645
166
|
### Resources
|
|
@@ -650,6 +171,8 @@ Returns `pass === true` if the path tracer can run. If it cannot run then a mess
|
|
|
650
171
|
|
|
651
172
|
[knightcrawler25/GLSL-PathTracer](https://github.com/knightcrawler25/GLSL-PathTracer/)
|
|
652
173
|
|
|
653
|
-
[
|
|
174
|
+
[blender/cycles](https://github.com/blender/cycles)
|
|
175
|
+
|
|
176
|
+
[AcademySoftwareFoundation/OpenPBR](https://github.com/AcademySoftwareFoundation/OpenPBR)
|
|
654
177
|
|
|
655
178
|
|