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.
Files changed (83) hide show
  1. package/README.md +53 -528
  2. package/build/index.module.js +319 -66
  3. package/build/index.module.js.map +1 -1
  4. package/build/index.umd.cjs +318 -64
  5. package/build/index.umd.cjs.map +1 -1
  6. package/package.json +35 -18
  7. package/src/core/PathTracingSceneGenerator.js +21 -2
  8. package/src/core/WebGLPathTracer.js +16 -7
  9. package/src/core/utils/mergeGeometries.js +14 -1
  10. package/src/core/utils/sceneUpdateUtils.js +8 -12
  11. package/src/detectors/PrecisionMaterial.js +9 -9
  12. package/src/index.d.ts +2 -1
  13. package/src/index.js +1 -0
  14. package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +2 -1
  15. package/src/materials/pathtracing/glsl/attenuate_hit_function.glsl.js +2 -1
  16. package/src/materials/pathtracing/glsl/camera_util_functions.glsl.js +1 -1
  17. package/src/materials/pathtracing/glsl/get_surface_record_function.glsl.js +2 -1
  18. package/src/materials/surface/AmbientOcclusionMaterial.js +2 -0
  19. package/src/objects/PhysicalSpotLight.js +2 -0
  20. package/src/shader/bsdf/bsdf_functions.glsl.js +0 -1
  21. package/src/shader/bvh/inside_fog_volume_function.glsl.js +1 -1
  22. package/src/shader/structs/material_struct.glsl.js +3 -1
  23. package/src/textures/BlueNoiseTexture.js +6 -6
  24. package/src/textures/ProceduralEquirectTexture.js +8 -7
  25. package/src/textures/turquinMetal.png +0 -0
  26. package/src/uniforms/EquirectHdrInfoUniform.js +9 -4
  27. package/src/uniforms/FloatAttributeTextureArray.js +11 -11
  28. package/src/uniforms/MaterialsTexture.js +13 -10
  29. package/src/webgpu/API.md +762 -0
  30. package/src/webgpu/AtlasTexture.js +471 -0
  31. package/src/webgpu/BlurredEnvMapGenerator.js +129 -0
  32. package/src/webgpu/EquirectBackgroundInfo.js +97 -0
  33. package/src/webgpu/EquirectHdrInfoNode.js +151 -0
  34. package/src/webgpu/LightsInfoNode.js +224 -0
  35. package/src/webgpu/MegaKernelPathTracer.js +277 -0
  36. package/src/webgpu/PathTracerBackend.js +216 -0
  37. package/src/webgpu/TurquinTexture.js +169 -0
  38. package/src/webgpu/WaveFrontPathTracer.js +586 -0
  39. package/src/webgpu/WebGPUPathTracer.js +1302 -0
  40. package/src/webgpu/compute/ComputeKernel.js +92 -0
  41. package/src/webgpu/compute/CopyBufferKernel.js +40 -0
  42. package/src/webgpu/compute/PathTracerMegaKernel.js +470 -0
  43. package/src/webgpu/compute/SampleDebugKernel.js +51 -0
  44. package/src/webgpu/compute/TallySampleCountsKernel.js +111 -0
  45. package/src/webgpu/compute/ZeroOutBufferKernel.js +35 -0
  46. package/src/webgpu/compute/ZeroOutKernel.js +31 -0
  47. package/src/webgpu/compute/wavefront/LogicKernel.js +349 -0
  48. package/src/webgpu/compute/wavefront/MaterialKernel.js +371 -0
  49. package/src/webgpu/compute/wavefront/PopulatePixelIndicesKernel.js +72 -0
  50. package/src/webgpu/compute/wavefront/QueueLengthToDispatchKernel.js +38 -0
  51. package/src/webgpu/compute/wavefront/ResetSlotsKernel.js +66 -0
  52. package/src/webgpu/compute/wavefront/TraceRayKernel.js +71 -0
  53. package/src/webgpu/compute/wavefront/TraceShadowRayKernel.js +67 -0
  54. package/src/webgpu/compute/wavefront/structs.js +155 -0
  55. package/src/webgpu/constants.js +62 -0
  56. package/src/webgpu/denoise/OIDNDenoiser.js +431 -0
  57. package/src/webgpu/index.d.ts +176 -0
  58. package/src/webgpu/index.js +11 -0
  59. package/src/webgpu/materials/GltfCompliantMaterial.js +608 -0
  60. package/src/webgpu/materials/GraphMaterial.js +331 -0
  61. package/src/webgpu/materials/PathtracingMaterial.js +89 -0
  62. package/src/webgpu/materials/RenderToScreenMaterial.js +150 -0
  63. package/src/webgpu/materials/debug/AtlasDebugMaterial.js +41 -0
  64. package/src/webgpu/materials/debug/SampleDensityMaterial.js +61 -0
  65. package/src/webgpu/nodes/PathtracerBVHComputeData.js +1037 -0
  66. package/src/webgpu/nodes/debugBounds.wgsl.js +228 -0
  67. package/src/webgpu/nodes/eon.wgsl.js +262 -0
  68. package/src/webgpu/nodes/ggx.wgsl.js +190 -0
  69. package/src/webgpu/nodes/lights.wgsl.js +203 -0
  70. package/src/webgpu/nodes/material.wgsl.js +990 -0
  71. package/src/webgpu/nodes/rand/bluedither.wgsl.js +92 -0
  72. package/src/webgpu/nodes/rand/pcg.wgsl.js +81 -0
  73. package/src/webgpu/nodes/rand/sobol.wgsl.js +287 -0
  74. package/src/webgpu/nodes/random.wgsl.js +20 -0
  75. package/src/webgpu/nodes/reset.wgsl.js +21 -0
  76. package/src/webgpu/nodes/sampling.wgsl.js +193 -0
  77. package/src/webgpu/nodes/sheen.wgsl.js +148 -0
  78. package/src/webgpu/nodes/structs.wgsl.js +272 -0
  79. package/src/webgpu/nodes/utils.wgsl.js +366 -0
  80. package/src/webgpu/shims/ArrayCameraShim.js +74 -0
  81. package/src/webgpu/shims/EquirectCameraShim.js +37 -0
  82. package/src/webgpu/shims/PhysicalCameraShim.js +151 -0
  83. package/src/webgpu/upscale/FSRUpscaler.js +108 -0
package/README.md CHANGED
@@ -6,86 +6,69 @@
6
6
  [![twitter](https://flat.badgen.net/badge/twitter/@garrettkjohnson/?icon&label)](https://twitter.com/garrettkjohnson)
7
7
  [![sponsors](https://img.shields.io/github/sponsors/gkjohnson?style=flat-square&color=1da1f2)](https://github.com/sponsors/gkjohnson/)
8
8
 
9
- ![](https://user-images.githubusercontent.com/734200/162287477-96696b18-890b-4c1b-8a73-d662e577cc48.png)
9
+ ![](./docs/banner.webp)
10
10
 
11
- Path tracing project using [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) and WebGL 2 to accelerate high quality, physically based rendering on the GPU. Features include support for GGX surface model, material information, textures, normal maps, emission, environment maps, tiled rendering, and more!
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/example/bundle/basic.html)
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/example/bundle/primitives.html)
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/example/bundle/index.html)
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/example/bundle/interior.html)
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/example/bundle/depthOfField.html)
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/example/bundle/hdr.html)
29
+ [HDR Image](https://gkjohnson.github.io/three-gpu-pathtracer/hdr.html)
34
30
 
35
31
  **Features**
36
32
 
37
- [Skinned Geometry Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/skinnedMesh.html)
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
- [Area Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/areaLight.html)
35
+ [Spot Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/spotLights.html)
42
36
 
43
- [Spot Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/spotLights.html)
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/example/bundle/materialBall.html)
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/example/bundle/viewerTest.html)
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/example/bundle/renderVideo.html)
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. Check the supported versions in [the test configuration](./.github/workflows/node.js.yml).
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:1234/<demo-name.html>`
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 { WebGLPathTracer } from 'three-gpu-pathtracer';
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.WebGLRenderer();
67
+ renderer = new THREE.WebGPURenderer();
86
68
  renderer.toneMapping = THREE.ACESFilmicToneMapping;
69
+ await renderer.init();
87
70
 
88
- pathTracer = new WebGLPathTracer( renderer );
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 envioronment map can help improve frame convergence time at the cost of sharp environment reflections. If performance is concern then multiple importance sampling can be disabled and blurred environment map used.
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 RGBELoader().setDataType( THREE.FloatType ).loadAsync( envMapUrl );
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
- ## PhysicalCamera
98
+ scene.environment = blurredEnvMap;
340
99
 
341
- _extends THREE.PerspectiveCamera_
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
- Returns `pass === true` if the path tracer can run. If it cannot run then a message is returned indicating why.
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 use of WebGL2.
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
- ![](https://user-images.githubusercontent.com/734200/162584469-68e6df38-92da-4a13-b352-ca0bdea14548.png)
585
-
586
118
  <p align="center">
587
- <i>Sample materials</i>
119
+ <img src="./docs/rover.webp" />
588
120
  </p>
589
121
 
590
- ![](https://user-images.githubusercontent.com/734200/163835927-be75d2c0-f27b-4e4b-a3eb-2371043fa5e1.png)
591
-
592
- ![](https://user-images.githubusercontent.com/734200/163839431-ed75e64d-9ae4-4423-afca-55162a44873e.png)
593
-
594
122
  <p align="center">
595
- <i>"SD Macross City Standoff Diorama" scene by <a href="https://sketchfab.com/3d-models/sd-macross-city-standoff-diorama-b154220f7e7441799d6be2f7ff9658c7">tipatat</a></i>
123
+ <img src="./docs/lit-stairway.webp" />
596
124
  </p>
597
125
 
598
- ![](./docs/interior-scene-cropped.png)
599
-
600
126
  <p align="center">
601
- <i>"Interior Scene" model by <a href="https://sketchfab.com/3d-models/interior-scene-45ddbbc4c2dc4f8ca9ed99da9a78326a">Allay Design</a></i>
127
+ <img src="./docs/kitchen.webp" />
602
128
  </p>
603
129
 
604
- ![](https://user-images.githubusercontent.com/734200/161820794-df0da371-ee5c-4368-9e7b-5e7daf6cf3c7.png)
605
-
606
- ![](https://user-images.githubusercontent.com/734200/162550315-3cdabf40-3dea-4d7d-bcfc-eb543eea2d93.png)
607
-
608
130
  <p align="center">
609
- <i>Perseverance Rover, Ingenuity Helicopter models by <a href="https://mars.nasa.gov/resources/25042/mars-perseverance-rover-3d-model/">NASA / JPL-Caltech</a></i>
131
+ <img src="./docs/tropical-island.webp" />
610
132
  </p>
611
133
 
612
- ![](https://user-images.githubusercontent.com/734200/161877900-566652e4-c799-4940-bccb-0c8f4cea5387.png)
613
-
614
134
  <p align="center">
615
- <i>Gelatinous Cube model by <a href="https://sketchfab.com/3d-models/gelatinous-cube-e08385238f4d4b59b012233a9fbdca21">glenatron</a></i>
135
+ <img src="./docs/coffee-maker.webp" />
616
136
  </p>
617
137
 
618
- ![](https://user-images.githubusercontent.com/734200/161822206-c27bf594-d648-4735-868e-4baf4e414802.png)
138
+ <p align="center">
139
+ <img src="./docs/porsche.webp" />
140
+ </p>
619
141
 
620
- ![](https://user-images.githubusercontent.com/734200/161822214-eace4297-03c4-4adc-b472-efe29a862685.png)
142
+ <p align="center">
143
+ <img src="./docs/insight.webp" />
144
+ </p>
621
145
 
622
146
  <p align="center">
623
- <i>Lego models courtesy of the <a href="https://omr.ldraw.org/">LDraw Official Model Repository</a></i>
147
+ <img src="./docs/apollo-lego.webp" />
624
148
  </p>
625
149
 
626
- ![](https://user-images.githubusercontent.com/734200/161877196-7ae2769e-7e54-4694-9ca8-e8f5219d1c2d.png)
150
+ <p align="center">
151
+ <img src="./docs/stormtroopers.webp" />
152
+ </p>
627
153
 
628
154
  <p align="center">
629
- <i>Octopus Tea model by <a href="https://sketchfab.com/3d-models/cartoon-octopus-takes-a-tea-bath-107260cf0fd24202a67eb037a6c760a5
630
- ">AzTiZ</a></i>
155
+ <img src="./docs/tea-set.webp" />
631
156
  </p>
632
157
 
633
- ![](https://user-images.githubusercontent.com/734200/173212652-de6a83e5-dd2c-49b5-8ed7-484ff8969b5b.png)
634
158
  <p align="center">
635
- <i>Botanists Study model by <a href="https://sketchfab.com/3d-models/the-botanists-study-8b7b5743b1c848ed8ea58f5518c44e7e">riikkakilpelainen</a></i>
159
+ <img src="./docs/octopus-tea.webp" />
636
160
  </p>
637
161
 
638
- ![](https://user-images.githubusercontent.com/734200/173170459-849b9343-efe3-4635-8719-346511472965.png)
639
162
  <p align="center">
640
- <i>Japanese Bridge Garden model by <a href="https://sketchfab.com/3d-models/japanese-bridge-garden-d122e17593eb4012913cde927486d15a">kristenlee</a></i>
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
- [DassaultSystemes-Technology/dspbr-pt](https://github.com/DassaultSystemes-Technology/dspbr-pt)
174
+ [blender/cycles](https://github.com/blender/cycles)
175
+
176
+ [AcademySoftwareFoundation/OpenPBR](https://github.com/AcademySoftwareFoundation/OpenPBR)
652
177
 
653
178