three-gpu-pathtracer 0.0.25 → 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.
@@ -2387,6 +2387,7 @@
2387
2387
  }
2388
2388
 
2389
2389
  const LIGHT_PIXELS = 6;
2390
+ const VISIBLE_TO_CAMERA_OFFSET = 11;
2390
2391
  const RECT_AREA_LIGHT = 0;
2391
2392
  const CIRC_AREA_LIGHT = 1;
2392
2393
  const SPOT_LIGHT = 2;
@@ -2467,7 +2468,7 @@
2467
2468
 
2468
2469
  type = SPOT_LIGHT;
2469
2470
 
2470
- } else if ( l.isDirectionalLight ) {
2471
+ } else if ( l.isDirectionalLight || l.isSunLight ) {
2471
2472
 
2472
2473
  type = DIR_LIGHT;
2473
2474
 
@@ -2592,8 +2593,22 @@
2592
2593
  floatArray[ baseIndex + ( index ++ ) ] = target.y;
2593
2594
  floatArray[ baseIndex + ( index ++ ) ] = target.z;
2594
2595
 
2596
+ } else if ( l.isSunLight ) {
2597
+
2598
+ // the sun has no target and shines from its position toward the origin
2599
+ target.setFromMatrixPosition( l.matrixWorld ).normalize();
2600
+
2601
+ // sample 3
2602
+ // u vector
2603
+ floatArray[ baseIndex + ( index ++ ) ] = target.x;
2604
+ floatArray[ baseIndex + ( index ++ ) ] = target.y;
2605
+ floatArray[ baseIndex + ( index ++ ) ] = target.z;
2606
+
2595
2607
  }
2596
2608
 
2609
+ // whether camera rays see the light
2610
+ floatArray[ baseIndex + VISIBLE_TO_CAMERA_OFFSET ] = l.visibleToCameraRays ? 1 : 0;
2611
+
2597
2612
  }
2598
2613
 
2599
2614
  this.count = lights.length;
@@ -2894,7 +2909,8 @@
2894
2909
  c.isRectAreaLight ||
2895
2910
  c.isSpotLight ||
2896
2911
  c.isPointLight ||
2897
- c.isDirectionalLight
2912
+ c.isDirectionalLight ||
2913
+ c.isSunLight
2898
2914
  ) {
2899
2915
 
2900
2916
  lights.push( c );