@@ -67,6 +67,8 @@ export class CampfireEnvironment extends RoomEnvironment{
6767
6868 this . materialList = { } ;
6969 this . particleList = { } ;
70+
71+ this . campfireLight = null ;
7072
7173
7274 this . pxlCamFOV = { 'PC' :60 , 'MOBILE' :80 } ;
@@ -76,7 +78,7 @@ export class CampfireEnvironment extends RoomEnvironment{
7678 this . pxlCamFarClipping = 5000 ;
7779
7880 // this.fogColor=new Color(.3,.3,.3);
79- this . fogColor = new Color ( .015 , .025 , .06 ) ;
81+ this . fogColor = new Color ( .008 , .020 , .04 ) ;
8082 this . fogExp = .0055 ;
8183 this . fog = new FogExp2 ( this . fogColor , this . fogExp ) ;
8284
@@ -152,6 +154,34 @@ export class CampfireEnvironment extends RoomEnvironment{
152154
153155 //let curFOV = this.pxlCamFOV[ this.mobile ? 'MOBILE' : 'PC' ];
154156 //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+
155185 }
156186
157187 checkEyeBlink ( ) {
@@ -424,6 +454,17 @@ export class CampfireEnvironment extends RoomEnvironment{
424454 pokinStick . material . lights = true ;
425455 }
426456
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+
427468 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
428469
429470 // Log replicator time!
@@ -560,7 +601,8 @@ export class CampfireEnvironment extends RoomEnvironment{
560601 // Enable shadows for non-mobile devices
561602 let shadowMapUniforms = this . mobile ? { } : UniformsLib [ "shadowmap" ] ;
562603 let hasShadowSettings = {
563- 'shadows' : this . mobile ? false : true ,
604+ //'shadows' : this.mobile ? false : true,
605+ 'shadows' : true ,
564606 }
565607
566608 let envGroundUniforms = UniformsUtils . merge (
@@ -600,6 +642,10 @@ export class CampfireEnvironment extends RoomEnvironment{
600642 'USE_MAP' : "" ,
601643 } ;
602644
645+ let envGroundSettings = Object . assign ( { } , hasShadowSettings , {
646+ 'shadowReach' : this . mobile ? 0.65 : 0.3 , // Shadow reach for non-mobile devices
647+ } ) ;
648+
603649 let environmentGroundMat = this . pxlFile . pxlShaderBuilder ( envGroundUniforms , envGroundVert ( hasShadowSettings ) , envGroundFrag ( hasShadowSettings ) , defines ) ;
604650 environmentGroundMat . lights = true ;
605651 environmentGroundMat . transparent = false ;
@@ -706,16 +752,20 @@ export class CampfireEnvironment extends RoomEnvironment{
706752 shadowMapUniforms ,
707753 {
708754 'noiseTexture' : { type :'t' , value : null } ,
755+ 'intensity' : { type : "f" , value : 1.25 } ,
709756 'fogColor' : { type : "c" , value : this . fogColor } ,
710757 } ]
711758 )
759+
760+ grassClusterUniforms . intensity . value = this . mobile ? 1.0 : 1.3 ; // Lower intensity for mobile devices
712761 grassClusterUniforms . noiseTexture . value = this . pxlUtils . loadTexture ( this . assetPath + "Noise_UniformWebbing.jpg" , null , { 'encoding' :SRGBColorSpace } ) ;
713762
714763
715764 let grassMat = this . pxlFile . pxlShaderBuilder ( grassClusterUniforms , grassClusterVert ( hasShadowSettings ) , grassClusterFrag ( hasShadowSettings ) ) ;
716765 grassMat . side = FrontSide ;
717766 grassMat . lights = true ;
718767 grassMat . transparent = false ;
768+
719769
720770
721771 // -- -- --
@@ -738,6 +788,7 @@ export class CampfireEnvironment extends RoomEnvironment{
738788 'fogColor' : { type : "c" , value : this . fogColor }
739789 } ]
740790 )
791+ grassClusterUniforms . intensity . value = this . mobile ? 2.25 : 2.0 ; // Lower intensity for mobile devices
741792 grassCardsAUniforms . noiseTexture . value = this . pxlUtils . loadTexture ( this . assetPath + "Noise_UniformWebbing.jpg" ) ;
742793 grassCardsAUniforms . diffuse . value = this . pxlUtils . loadTexture ( this . assetPath + "grassCardsA_diffuse.webp" ) ;
743794 grassCardsAUniforms . alphaMap . value = this . pxlUtils . loadTexture ( this . assetPath + "grassCardsA_alpha.jpg" ) ;
@@ -749,7 +800,7 @@ export class CampfireEnvironment extends RoomEnvironment{
749800 'addCampfire' : true ,
750801 'depthScalar' : 0.003 ,
751802 'fogDepthScalar' : 0.8 ,
752- 'shadows' : this . mobile ? false : true ,
803+ 'shadows' : true ,
753804 }
754805
755806 let grassCardsMat = this . pxlFile . pxlShaderBuilder ( grassCardsAUniforms , instPlantsVert ( hasShadowSettings ) , instPlantsFrag ( grassCardSettings ) ) ;
@@ -758,7 +809,7 @@ export class CampfireEnvironment extends RoomEnvironment{
758809 grassCardsMat . transparent = false ;
759810
760811 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 ) ) ;
762813 grassCardsFarMat . side = DoubleSide ;
763814 grassCardsFarMat . lights = true ;
764815 grassCardsFarMat . transparent = false ;
0 commit comments