@@ -622,15 +622,15 @@ class ForwardRenderer {
622
622
directional . _normalOffsetBias ;
623
623
624
624
this . lightShadowMapId [ cnt ] . setValue ( lightRenderData . shadowBuffer ) ;
625
- this . lightShadowMatrixId [ cnt ] . setValue ( directional . _shadowMatrix . data ) ;
625
+ this . lightShadowMatrixId [ cnt ] . setValue ( lightRenderData . shadowMatrix . data ) ;
626
626
var params = directional . _rendererParams ;
627
627
params . length = 3 ;
628
628
params [ 0 ] = directional . _shadowResolution ;
629
629
params [ 1 ] = normalBias ;
630
630
params [ 2 ] = bias ;
631
631
this . lightShadowParamsId [ cnt ] . setValue ( params ) ;
632
632
if ( this . mainLight < 0 ) {
633
- this . lightShadowMatrixVsId [ cnt ] . setValue ( directional . _shadowMatrix . data ) ;
633
+ this . lightShadowMatrixVsId [ cnt ] . setValue ( lightRenderData . shadowMatrix . data ) ;
634
634
this . lightShadowParamsVsId [ cnt ] . setValue ( params ) ;
635
635
directional . _direction . normalize ( ) ;
636
636
this . lightDirVs [ cnt ] [ 0 ] = directional . _direction . x ;
@@ -730,6 +730,7 @@ class ForwardRenderer {
730
730
this . lightDir [ cnt ] [ 2 ] = spot . _direction . z ;
731
731
this . lightDirId [ cnt ] . setValue ( this . lightDir [ cnt ] ) ;
732
732
733
+ let cookieMatrix ;
733
734
if ( spot . castShadows ) {
734
735
var bias ;
735
736
if ( spot . _isVsm ) {
@@ -746,19 +747,22 @@ class ForwardRenderer {
746
747
const lightRenderData = spot . getRenderData ( null , 0 ) ;
747
748
this . lightShadowMapId [ cnt ] . setValue ( lightRenderData . shadowBuffer ) ;
748
749
749
- this . lightShadowMatrixId [ cnt ] . setValue ( spot . _shadowMatrix . data ) ;
750
+ this . lightShadowMatrixId [ cnt ] . setValue ( lightRenderData . shadowMatrix . data ) ;
750
751
var params = spot . _rendererParams ;
751
752
params . length = 4 ;
752
753
params [ 0 ] = spot . _shadowResolution ;
753
754
params [ 1 ] = normalBias ;
754
755
params [ 2 ] = bias ;
755
756
params [ 3 ] = 1.0 / spot . attenuationEnd ;
756
757
this . lightShadowParamsId [ cnt ] . setValue ( params ) ;
758
+
759
+ cookieMatrix = lightRenderData . shadowMatrix ;
757
760
}
761
+
758
762
if ( spot . _cookie ) {
759
763
this . lightCookieId [ cnt ] . setValue ( spot . _cookie ) ;
760
764
if ( ! spot . castShadows ) {
761
- const cookieCam = ShadowRenderer . getSpotCookieCamera ( ) ;
765
+ const cookieCam = ForwardRenderer . getSpotCookieCamera ( ) ;
762
766
cookieCam . fov = spot . _outerConeAngle * 2 ;
763
767
764
768
const cookieNode = cookieCam . _node ;
@@ -768,9 +772,11 @@ class ForwardRenderer {
768
772
769
773
shadowCamView . setTRS ( cookieNode . getPosition ( ) , cookieNode . getRotation ( ) , Vec3 . ONE ) . invert ( ) ;
770
774
shadowCamViewProj . mul2 ( cookieCam . projectionMatrix , shadowCamView ) ;
771
- spot . _shadowMatrix . mul2 ( ShadowRenderer . scaleShiftMatrix , shadowCamViewProj ) ;
775
+
776
+ cookieMatrix = spot . cookieMatrix ;
777
+ cookieMatrix . mul2 ( ShadowRenderer . scaleShiftMatrix , shadowCamViewProj ) ;
772
778
}
773
- this . lightShadowMatrixId [ cnt ] . setValue ( spot . _shadowMatrix . data ) ;
779
+ this . lightShadowMatrixId [ cnt ] . setValue ( cookieMatrix . data ) ;
774
780
this . lightCookieIntId [ cnt ] . setValue ( spot . cookieIntensity ) ;
775
781
if ( spot . _cookieTransform ) {
776
782
spot . _cookieTransformUniform [ 0 ] = spot . _cookieTransform . x ;
0 commit comments