9
9
#include " profiler.h"
10
10
#include " util/numeric.h" // MYMIN
11
11
#include < cmath>
12
+ #include " settings.h"
12
13
13
14
// ! constructor
14
15
Sky::Sky (scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, LocalPlayer* player):
@@ -56,6 +57,8 @@ Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, LocalPlay
56
57
);
57
58
m_stars[i].normalize ();
58
59
}
60
+
61
+ m_directional_colored_fog = g_settings->getBool (" directional_colored_fog" );
59
62
}
60
63
61
64
void Sky::OnRegisterSceneNode ()
@@ -482,32 +485,34 @@ void Sky::update(float time_of_day, float time_brightness,
482
485
483
486
// Horizon coloring based on sun and moon direction during sunset and sunrise
484
487
video::SColor pointcolor = video::SColor (255 , 255 , 255 , m_bgcolor.getAlpha ());
485
- if (m_horizon_blend () != 0 )
486
- {
487
- // calculate hemisphere value from yaw
488
- f32 pointcolor_blend = wrapDegrees_0_360 (m_player->getYaw () + 90 );
489
- if (pointcolor_blend > 180 )
490
- pointcolor_blend = 360 - pointcolor_blend;
491
- pointcolor_blend /= 180 ;
492
- // bound view angle to determine where transition starts and ends
493
- pointcolor_blend = rangelim (1 - pointcolor_blend * 1.375 , 0 , 1 / 1.375 ) * 1.375 ;
494
- // combine the colors when looking up or down, otherwise turning looks weird
495
- pointcolor_blend += (0.5 - pointcolor_blend) * (1 - MYMIN ((90 - std::abs (m_player->getPitch ())) / 90 * 1.5 , 1 ));
496
- // invert direction to match where the sun and moon are rising
497
- if (m_time_of_day > 0.5 )
498
- pointcolor_blend = 1 - pointcolor_blend;
499
-
500
- // horizon colors of sun and moon
501
- f32 pointcolor_light = rangelim (m_time_brightness * 3 , 0.2 , 1 );
502
- video::SColorf pointcolor_sun_f (1 , 1 , 1 , 1 );
503
- pointcolor_sun_f.r = pointcolor_light * 1 ;
504
- pointcolor_sun_f.b = pointcolor_light * (0.25 + (rangelim (m_time_brightness, 0.25 , 0.75 ) - 0.25 ) * 2 * 0.75 );
505
- pointcolor_sun_f.g = pointcolor_light * (pointcolor_sun_f.b * 0.375 + (rangelim (m_time_brightness, 0.05 , 0.15 ) - 0.05 ) * 10 * 0.625 );
506
- video::SColorf pointcolor_moon_f (0.5 * pointcolor_light, 0.6 * pointcolor_light, 0.8 * pointcolor_light, 1 );
507
- video::SColor pointcolor_sun = pointcolor_sun_f.toSColor ();
508
- video::SColor pointcolor_moon = pointcolor_moon_f.toSColor ();
509
- // calculate the blend color
510
- pointcolor = m_mix_scolor (pointcolor_moon, pointcolor_sun, pointcolor_blend);
488
+ if (m_directional_colored_fog) {
489
+ if (m_horizon_blend () != 0 )
490
+ {
491
+ // calculate hemisphere value from yaw
492
+ f32 pointcolor_blend = wrapDegrees_0_360 (m_player->getYaw () + 90 );
493
+ if (pointcolor_blend > 180 )
494
+ pointcolor_blend = 360 - pointcolor_blend;
495
+ pointcolor_blend /= 180 ;
496
+ // bound view angle to determine where transition starts and ends
497
+ pointcolor_blend = rangelim (1 - pointcolor_blend * 1.375 , 0 , 1 / 1.375 ) * 1.375 ;
498
+ // combine the colors when looking up or down, otherwise turning looks weird
499
+ pointcolor_blend += (0.5 - pointcolor_blend) * (1 - MYMIN ((90 - std::abs (m_player->getPitch ())) / 90 * 1.5 , 1 ));
500
+ // invert direction to match where the sun and moon are rising
501
+ if (m_time_of_day > 0.5 )
502
+ pointcolor_blend = 1 - pointcolor_blend;
503
+
504
+ // horizon colors of sun and moon
505
+ f32 pointcolor_light = rangelim (m_time_brightness * 3 , 0.2 , 1 );
506
+ video::SColorf pointcolor_sun_f (1 , 1 , 1 , 1 );
507
+ pointcolor_sun_f.r = pointcolor_light * 1 ;
508
+ pointcolor_sun_f.b = pointcolor_light * (0.25 + (rangelim (m_time_brightness, 0.25 , 0.75 ) - 0.25 ) * 2 * 0.75 );
509
+ pointcolor_sun_f.g = pointcolor_light * (pointcolor_sun_f.b * 0.375 + (rangelim (m_time_brightness, 0.05 , 0.15 ) - 0.05 ) * 10 * 0.625 );
510
+ video::SColorf pointcolor_moon_f (0.5 * pointcolor_light, 0.6 * pointcolor_light, 0.8 * pointcolor_light, 1 );
511
+ video::SColor pointcolor_sun = pointcolor_sun_f.toSColor ();
512
+ video::SColor pointcolor_moon = pointcolor_moon_f.toSColor ();
513
+ // calculate the blend color
514
+ pointcolor = m_mix_scolor (pointcolor_moon, pointcolor_sun, pointcolor_blend);
515
+ }
511
516
}
512
517
513
518
video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor ();
@@ -516,19 +521,30 @@ void Sky::update(float time_of_day, float time_brightness,
516
521
bgcolor_bright.getRed () * m_brightness,
517
522
bgcolor_bright.getGreen () * m_brightness,
518
523
bgcolor_bright.getBlue () * m_brightness);
519
- m_bgcolor = m_mix_scolor (m_bgcolor, pointcolor, m_horizon_blend () * 0.5 );
524
+ if (m_directional_colored_fog) {
525
+ m_bgcolor = m_mix_scolor (m_bgcolor, pointcolor, m_horizon_blend () * 0.5 );
526
+ }
520
527
521
528
video::SColor skycolor_bright = m_skycolor_bright_f.toSColor ();
522
529
m_skycolor = video::SColor (
523
530
255 ,
524
531
skycolor_bright.getRed () * m_brightness,
525
532
skycolor_bright.getGreen () * m_brightness,
526
533
skycolor_bright.getBlue () * m_brightness);
527
- m_skycolor = m_mix_scolor (m_skycolor, pointcolor, m_horizon_blend () * 0.25 );
534
+ if (m_directional_colored_fog) {
535
+ m_skycolor = m_mix_scolor (m_skycolor, pointcolor, m_horizon_blend () * 0.25 );
536
+ }
528
537
529
538
float cloud_direct_brightness = 0 ;
530
- if (sunlight_seen){
531
- cloud_direct_brightness = MYMIN (m_horizon_blend () * 0.15 + m_time_brightness, 1 );
539
+ if (sunlight_seen) {
540
+ if (!m_directional_colored_fog) {
541
+ cloud_direct_brightness = time_brightness;
542
+ if (time_brightness >= 0.2 && time_brightness < 0.7 )
543
+ cloud_direct_brightness *= 1.3 ;
544
+ }
545
+ else {
546
+ cloud_direct_brightness = MYMIN (m_horizon_blend () * 0.15 + m_time_brightness, 1 );
547
+ }
532
548
} else {
533
549
cloud_direct_brightness = direct_brightness;
534
550
}
@@ -539,7 +555,9 @@ void Sky::update(float time_of_day, float time_brightness,
539
555
m_cloudcolor_bright_f.g * m_cloud_brightness,
540
556
m_cloudcolor_bright_f.b * m_cloud_brightness,
541
557
1.0 );
542
- m_cloudcolor_f = m_mix_scolorf (m_cloudcolor_f, video::SColorf (pointcolor), m_horizon_blend () * 0.75 );
558
+ if (m_directional_colored_fog) {
559
+ m_cloudcolor_f = m_mix_scolorf (m_cloudcolor_f, video::SColorf (pointcolor), m_horizon_blend () * 0.75 );
560
+ }
543
561
544
562
}
545
563
0 commit comments