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

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

|
|
591
|
-
|
|
592
|
-

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

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

|
|
605
|
-
|
|
606
|
-

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

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

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

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