@@ -67,6 +67,8 @@ export class CampfireEnvironment extends RoomEnvironment{
67
67
68
68
this . materialList = { } ;
69
69
this . particleList = { } ;
70
+
71
+ this . campfireLight = null ;
70
72
71
73
72
74
this . pxlCamFOV = { 'PC' :60 , 'MOBILE' :80 } ;
@@ -76,7 +78,7 @@ export class CampfireEnvironment extends RoomEnvironment{
76
78
this . pxlCamFarClipping = 5000 ;
77
79
78
80
// this.fogColor=new Color(.3,.3,.3);
79
- this . fogColor = new Color ( .015 , .025 , .06 ) ;
81
+ this . fogColor = new Color ( .008 , .020 , .04 ) ;
80
82
this . fogExp = .0055 ;
81
83
this . fog = new FogExp2 ( this . fogColor , this . fogExp ) ;
82
84
@@ -152,6 +154,34 @@ export class CampfireEnvironment extends RoomEnvironment{
152
154
153
155
//let curFOV = this.pxlCamFOV[ this.mobile ? 'MOBILE' : 'PC' ];
154
156
//this.pxlEnv.pxlCamera.setStats( curFOV, this.pxlCamZoom, this.pxlCamAspect, this.pxlCamNearClipping );
157
+
158
+ if ( this . campfireLight ) {
159
+ // Flicker the campfire light color and intensity
160
+ let basePos = this . campfireLight . origPos . clone ( ) ;
161
+ let totalIntensity = this . campfireLight . origIntensity ;
162
+
163
+ let magnitude = 3.2 ; // Adjust the flicker magnitude
164
+
165
+ let timeOffset = this . msRunner . x * .3 ; // Adjust the flicker speed
166
+
167
+ let flickerNoise = Math . sin ( timeOffset +
168
+ this . campfireLight . position . x * 0.01 +
169
+ this . campfireLight . position . y * 0.01 +
170
+ this . campfireLight . position . z * 0.01 ) ;
171
+
172
+ this . campfireLight . position . set (
173
+ basePos . x + Math . sin ( timeOffset + flickerNoise ) * magnitude ,
174
+ basePos . y + Math . cos ( timeOffset + flickerNoise ) * 1.2 ,
175
+ basePos . z + Math . sin ( - timeOffset * 1.5 + flickerNoise * 0.5 ) * magnitude
176
+ ) ;
177
+ this . campfireLight . intensity = totalIntensity * (
178
+ Math . sin ( timeOffset * 3.5 + flickerNoise * 4.0
179
+ + this . campfireLight . position . x
180
+ + this . campfireLight . position . y
181
+ + this . campfireLight . position . z
182
+ ) * 0.1 + 1.0 ) ; // Flicker intensity
183
+ }
184
+
155
185
}
156
186
157
187
checkEyeBlink ( ) {
@@ -424,6 +454,17 @@ export class CampfireEnvironment extends RoomEnvironment{
424
454
pokinStick . material . lights = true ;
425
455
}
426
456
457
+
458
+ if ( this . lightList . hasOwnProperty ( "PointLight" ) && this . lightList [ "PointLight" ] . length > 0 ) {
459
+ this . lightList [ "PointLight" ] . forEach ( ( light ) => {
460
+ if ( light . name == "point_campFire_lit" ) {
461
+ this . campfireLight = light ;
462
+ this . campfireLight . origPos = light . position . clone ( ) ; // Save the original position of the campfire light
463
+ this . campfireLight . origIntensity = light . intensity ; // Save the original intensity of the campfire light
464
+ }
465
+ } ) ;
466
+ }
467
+
427
468
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
428
469
429
470
// Log replicator time!
@@ -560,7 +601,8 @@ export class CampfireEnvironment extends RoomEnvironment{
560
601
// Enable shadows for non-mobile devices
561
602
let shadowMapUniforms = this . mobile ? { } : UniformsLib [ "shadowmap" ] ;
562
603
let hasShadowSettings = {
563
- 'shadows' : this . mobile ? false : true ,
604
+ //'shadows' : this.mobile ? false : true,
605
+ 'shadows' : true ,
564
606
}
565
607
566
608
let envGroundUniforms = UniformsUtils . merge (
@@ -600,6 +642,10 @@ export class CampfireEnvironment extends RoomEnvironment{
600
642
'USE_MAP' : "" ,
601
643
} ;
602
644
645
+ let envGroundSettings = Object . assign ( { } , hasShadowSettings , {
646
+ 'shadowReach' : this . mobile ? 0.65 : 0.3 , // Shadow reach for non-mobile devices
647
+ } ) ;
648
+
603
649
let environmentGroundMat = this . pxlFile . pxlShaderBuilder ( envGroundUniforms , envGroundVert ( hasShadowSettings ) , envGroundFrag ( hasShadowSettings ) , defines ) ;
604
650
environmentGroundMat . lights = true ;
605
651
environmentGroundMat . transparent = false ;
@@ -706,16 +752,20 @@ export class CampfireEnvironment extends RoomEnvironment{
706
752
shadowMapUniforms ,
707
753
{
708
754
'noiseTexture' : { type :'t' , value : null } ,
755
+ 'intensity' : { type : "f" , value : 1.25 } ,
709
756
'fogColor' : { type : "c" , value : this . fogColor } ,
710
757
} ]
711
758
)
759
+
760
+ grassClusterUniforms . intensity . value = this . mobile ? 1.0 : 1.3 ; // Lower intensity for mobile devices
712
761
grassClusterUniforms . noiseTexture . value = this . pxlUtils . loadTexture ( this . assetPath + "Noise_UniformWebbing.jpg" , null , { 'encoding' :SRGBColorSpace } ) ;
713
762
714
763
715
764
let grassMat = this . pxlFile . pxlShaderBuilder ( grassClusterUniforms , grassClusterVert ( hasShadowSettings ) , grassClusterFrag ( hasShadowSettings ) ) ;
716
765
grassMat . side = FrontSide ;
717
766
grassMat . lights = true ;
718
767
grassMat . transparent = false ;
768
+
719
769
720
770
721
771
// -- -- --
@@ -738,6 +788,7 @@ export class CampfireEnvironment extends RoomEnvironment{
738
788
'fogColor' : { type : "c" , value : this . fogColor }
739
789
} ]
740
790
)
791
+ grassClusterUniforms . intensity . value = this . mobile ? 2.25 : 2.0 ; // Lower intensity for mobile devices
741
792
grassCardsAUniforms . noiseTexture . value = this . pxlUtils . loadTexture ( this . assetPath + "Noise_UniformWebbing.jpg" ) ;
742
793
grassCardsAUniforms . diffuse . value = this . pxlUtils . loadTexture ( this . assetPath + "grassCardsA_diffuse.webp" ) ;
743
794
grassCardsAUniforms . alphaMap . value = this . pxlUtils . loadTexture ( this . assetPath + "grassCardsA_alpha.jpg" ) ;
@@ -749,7 +800,7 @@ export class CampfireEnvironment extends RoomEnvironment{
749
800
'addCampfire' : true ,
750
801
'depthScalar' : 0.003 ,
751
802
'fogDepthScalar' : 0.8 ,
752
- 'shadows' : this . mobile ? false : true ,
803
+ 'shadows' : true ,
753
804
}
754
805
755
806
let grassCardsMat = this . pxlFile . pxlShaderBuilder ( grassCardsAUniforms , instPlantsVert ( hasShadowSettings ) , instPlantsFrag ( grassCardSettings ) ) ;
@@ -758,7 +809,7 @@ export class CampfireEnvironment extends RoomEnvironment{
758
809
grassCardsMat . transparent = false ;
759
810
760
811
grassCardSettings [ 'shadow' ] = false ; // Disable shadow for the far grass cards
761
- let grassCardsFarMat = this . pxlFile . pxlShaderBuilder ( grassCardsAUniforms , instPlantsVert ( { } ) , instPlantsFrag ( grassCardSettings ) ) ;
812
+ let grassCardsFarMat = this . pxlFile . pxlShaderBuilder ( grassCardsAUniforms , instPlantsVert ( hasShadowSettings ) , instPlantsFrag ( grassCardSettings ) ) ;
762
813
grassCardsFarMat . side = DoubleSide ;
763
814
grassCardsFarMat . lights = true ;
764
815
grassCardsFarMat . transparent = false ;
0 commit comments