three-gpu-pathtracer 0.0.26 → 0.0.27

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 CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/three-gpu-pathtracer.svg?style=flat-square)](https://www.npmjs.com/package/three-gpu-pathtracer)
4
4
  [![build](https://img.shields.io/github/actions/workflow/status/gkjohnson/three-gpu-pathtracer/node.js.yml?style=flat-square&label=build&branch=main)](https://github.com/gkjohnson/three-gpu-pathtracer/actions)
5
+ [![docs](https://img.shields.io/badge/docs-API-blue?style=flat-square)](https://gkjohnson.github.io/tools/docs/three-gpu-pathtracer/)
5
6
  [![github](https://flat.badgen.net/badge/icon/github?icon=github&label)](https://github.com/gkjohnson/three-gpu-pathtracer/)
6
7
  [![twitter](https://flat.badgen.net/badge/twitter/@garrettkjohnson/?icon&label)](https://twitter.com/garrettkjohnson)
7
8
  [![sponsors](https://img.shields.io/github/sponsors/gkjohnson?style=flat-square&color=1da1f2)](https://github.com/sponsors/gkjohnson/)
@@ -103,7 +104,9 @@ scene.environment = blurredEnvMap;
103
104
 
104
105
  # API
105
106
 
106
- See [API.md](./src/webgpu/API.md) for the WebGPU API documentation.
107
+ See the [docs site](https://gkjohnson.github.io/tools/docs/three-gpu-pathtracer/) for the WebGPU API documentation.
108
+
109
+ The same documentation is also available as markdown in [API.md](./src/webgpu/API.md).
107
110
 
108
111
  # Gotchas
109
112
 
@@ -2385,6 +2385,7 @@ class EquirectHdrInfoUniform {
2385
2385
  }
2386
2386
 
2387
2387
  const LIGHT_PIXELS = 6;
2388
+ const VISIBLE_TO_CAMERA_OFFSET = 11;
2388
2389
  const RECT_AREA_LIGHT = 0;
2389
2390
  const CIRC_AREA_LIGHT = 1;
2390
2391
  const SPOT_LIGHT = 2;
@@ -2465,7 +2466,7 @@ class LightsInfoUniformStruct {
2465
2466
 
2466
2467
  type = SPOT_LIGHT;
2467
2468
 
2468
- } else if ( l.isDirectionalLight ) {
2469
+ } else if ( l.isDirectionalLight || l.isSunLight ) {
2469
2470
 
2470
2471
  type = DIR_LIGHT;
2471
2472
 
@@ -2590,8 +2591,22 @@ class LightsInfoUniformStruct {
2590
2591
  floatArray[ baseIndex + ( index ++ ) ] = target.y;
2591
2592
  floatArray[ baseIndex + ( index ++ ) ] = target.z;
2592
2593
 
2594
+ } else if ( l.isSunLight ) {
2595
+
2596
+ // the sun has no target and shines from its position toward the origin
2597
+ target.setFromMatrixPosition( l.matrixWorld ).normalize();
2598
+
2599
+ // sample 3
2600
+ // u vector
2601
+ floatArray[ baseIndex + ( index ++ ) ] = target.x;
2602
+ floatArray[ baseIndex + ( index ++ ) ] = target.y;
2603
+ floatArray[ baseIndex + ( index ++ ) ] = target.z;
2604
+
2593
2605
  }
2594
2606
 
2607
+ // whether camera rays see the light
2608
+ floatArray[ baseIndex + VISIBLE_TO_CAMERA_OFFSET ] = l.visibleToCameraRays ? 1 : 0;
2609
+
2595
2610
  }
2596
2611
 
2597
2612
  this.count = lights.length;
@@ -2892,7 +2907,8 @@ function getLights( scene ) {
2892
2907
  c.isRectAreaLight ||
2893
2908
  c.isSpotLight ||
2894
2909
  c.isPointLight ||
2895
- c.isDirectionalLight
2910
+ c.isDirectionalLight ||
2911
+ c.isSunLight
2896
2912
  ) {
2897
2913
 
2898
2914
  lights.push( c );