Add setting to disable direction dependent fog and sky colors

master
sapier 2013-12-15 15:30:02 +01:00
parent 848f80b2e5
commit c120ea57c9
4 changed files with 61 additions and 40 deletions

View File

@ -22,7 +22,6 @@
# Client and server
#
# Name of player; on a server this is the main admin
#name =
@ -190,6 +189,8 @@
# The time in seconds it takes between repeated
# right clicks when holding the right mouse button
#repeat_rightclick_time = 0.25
# Make fog and sky colors depend on daytime (dawn/sunset) and view direction
#directional_colored_fog = true
# Default timeout for cURL, in milliseconds
# Only has an effect if compiled with cURL

View File

@ -59,6 +59,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("aux1_descends", "false");
settings->setDefault("doubletap_jump", "false");
settings->setDefault("always_fly_fast", "true");
settings->setDefault("directional_colored_fog", "true");
// Some (temporary) keys for debugging
settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P");

View File

@ -9,6 +9,7 @@
#include "profiler.h"
#include "util/numeric.h" // MYMIN
#include <cmath>
#include "settings.h"
//! constructor
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
);
m_stars[i].normalize();
}
m_directional_colored_fog = g_settings->getBool("directional_colored_fog");
}
void Sky::OnRegisterSceneNode()
@ -482,6 +485,7 @@ void Sky::update(float time_of_day, float time_brightness,
// Horizon coloring based on sun and moon direction during sunset and sunrise
video::SColor pointcolor = video::SColor(255, 255, 255, m_bgcolor.getAlpha());
if (m_directional_colored_fog) {
if (m_horizon_blend() != 0)
{
// calculate hemisphere value from yaw
@ -509,6 +513,7 @@ void Sky::update(float time_of_day, float time_brightness,
// calculate the blend color
pointcolor = m_mix_scolor(pointcolor_moon, pointcolor_sun, pointcolor_blend);
}
}
video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor();
m_bgcolor = video::SColor(
@ -516,7 +521,9 @@ void Sky::update(float time_of_day, float time_brightness,
bgcolor_bright.getRed() * m_brightness,
bgcolor_bright.getGreen() * m_brightness,
bgcolor_bright.getBlue() * m_brightness);
if (m_directional_colored_fog) {
m_bgcolor = m_mix_scolor(m_bgcolor, pointcolor, m_horizon_blend() * 0.5);
}
video::SColor skycolor_bright = m_skycolor_bright_f.toSColor();
m_skycolor = video::SColor(
@ -524,11 +531,20 @@ void Sky::update(float time_of_day, float time_brightness,
skycolor_bright.getRed() * m_brightness,
skycolor_bright.getGreen() * m_brightness,
skycolor_bright.getBlue() * m_brightness);
if (m_directional_colored_fog) {
m_skycolor = m_mix_scolor(m_skycolor, pointcolor, m_horizon_blend() * 0.25);
}
float cloud_direct_brightness = 0;
if(sunlight_seen) {
if (!m_directional_colored_fog) {
cloud_direct_brightness = time_brightness;
if(time_brightness >= 0.2 && time_brightness < 0.7)
cloud_direct_brightness *= 1.3;
}
else {
cloud_direct_brightness = MYMIN(m_horizon_blend() * 0.15 + m_time_brightness, 1);
}
} else {
cloud_direct_brightness = direct_brightness;
}
@ -539,7 +555,9 @@ void Sky::update(float time_of_day, float time_brightness,
m_cloudcolor_bright_f.g * m_cloud_brightness,
m_cloudcolor_bright_f.b * m_cloud_brightness,
1.0);
if (m_directional_colored_fog) {
m_cloudcolor_f = m_mix_scolorf(m_cloudcolor_f, video::SColorf(pointcolor), m_horizon_blend() * 0.75);
}
}

View File

@ -105,6 +105,7 @@ private:
float m_brightness;
float m_cloud_brightness;
bool m_clouds_visible;
bool m_directional_colored_fog;
video::SColorf m_bgcolor_bright_f;
video::SColorf m_skycolor_bright_f;
video::SColorf m_cloudcolor_bright_f;