Skip to content

Commit c120ea5

Browse files
sapiersapier
sapier
authored and
sapier
committedDec 15, 2013
Add setting to disable direction dependent fog and sky colors
1 parent 848f80b commit c120ea5

File tree

4 files changed

+62
-41
lines changed

4 files changed

+62
-41
lines changed
 

Diff for: ‎minetest.conf.example

+10-9
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222
# Client and server
2323
#
2424

25-
2625
# Name of player; on a server this is the main admin
27-
#name =
26+
#name =
2827

2928
#
3029
# Client stuff
3130
#
3231

3332
# Port to connect to (UDP)
34-
#remote_port =
33+
#remote_port =
3534
# Key mappings
3635
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
3736
#keymap_forward = KEY_KEY_W
@@ -83,7 +82,7 @@
8382
#vsync = false
8483
#fov = 72
8584
# Address to connect to (#blank = start local server)
86-
#address =
85+
#address =
8786
# Enable random user input, for testing
8887
#random_input = false
8988
# Timeout for client to remove unused map data from memory
@@ -116,7 +115,7 @@
116115
# disable for speed or for different looks.
117116
#smooth_lighting = true
118117
# Path to texture directory. All textures are first searched from here.
119-
#texture_path =
118+
#texture_path =
120119
# Video back-end.
121120
# Possible values: null, software, burningsvideo, direct3d8, direct3d9, opengl
122121
#video_driver = opengl
@@ -190,6 +189,8 @@
190189
# The time in seconds it takes between repeated
191190
# right clicks when holding the right mouse button
192191
#repeat_rightclick_time = 0.25
192+
# Make fog and sky colors depend on daytime (dawn/sunset) and view direction
193+
#directional_colored_fog = true
193194

194195
# Default timeout for cURL, in milliseconds
195196
# Only has an effect if compiled with cURL
@@ -228,7 +229,7 @@
228229
# Server stuff
229230
#
230231
# Network port to listen (UDP)
231-
#port =
232+
#port =
232233
# Name of server
233234
#server_name = Minetest server
234235
# Description of server
@@ -262,7 +263,7 @@
262263
# Gives some stuff to players at the beginning
263264
#give_initial_stuff = false
264265
# New users need to input this password
265-
#default_password =
266+
#default_password =
266267
# Available privileges: interact, shout, teleport, settime, privs, ...
267268
# See /privs in game for a full list on your server and mod configuration.
268269
#default_privs = interact, shout
@@ -278,7 +279,7 @@
278279
#disable_anticheat = false
279280
# If true, actions are recorded for rollback
280281
#enable_rollback_recording = false
281-
# If true, blocks are cached (and generated if not before) before a player is spawned.
282+
# If true, blocks are cached (and generated if not before) before a player is spawned.
282283
#cache_block_before_spawn = true
283284
# Defines the maximum height a player can spawn in a map, above water level
284285
#max_spawn_height = 50
@@ -342,7 +343,7 @@
342343
#emergequeue_limit_diskonly =
343344
# Maximum number of blocks to be queued that are to be generated.
344345
# Leave blank for an appropriate amount to be chosen automatically.
345-
#emergequeue_limit_generate =
346+
#emergequeue_limit_generate =
346347
# Number of emerge threads to use. Make this field blank, or increase this number, to use multiple threads.
347348
# On multiprocessor systems, this will improve mapgen speed greatly, at the cost of slightly buggy caves.
348349
#num_emerge_threads = 1

Diff for: ‎src/defaultsettings.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void set_default_settings(Settings *settings)
5959
settings->setDefault("aux1_descends", "false");
6060
settings->setDefault("doubletap_jump", "false");
6161
settings->setDefault("always_fly_fast", "true");
62+
settings->setDefault("directional_colored_fog", "true");
6263

6364
// Some (temporary) keys for debugging
6465
settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P");
@@ -268,7 +269,7 @@ void set_default_settings(Settings *settings)
268269
settings->setDefault("mgv7_np_terrain_alt", "4, 25, (600, 600, 600), 5934, 5, 0.6");
269270
settings->setDefault("mgv7_np_terrain_persist", "0.6, 0.1, (500, 500, 500), 539, 3, 0.6");
270271
settings->setDefault("mgv7_np_height_select", "-0.5, 1, (250, 250, 250), 4213, 5, 0.69");
271-
settings->setDefault("mgv7_np_filler_depth", "0, 1.2, (150, 150, 150), 261, 4, 0.7");
272+
settings->setDefault("mgv7_np_filler_depth", "0, 1.2, (150, 150, 150), 261, 4, 0.7");
272273
settings->setDefault("mgv7_np_mount_height", "100, 30, (500, 500, 500), 72449, 4, 0.6");
273274
settings->setDefault("mgv7_np_ridge_uwater", "0, 1, (500, 500, 500), 85039, 4, 0.6");
274275
settings->setDefault("mgv7_np_mountain", "0, 1, (250, 350, 250), 5333, 5, 0.68");

Diff for: ‎src/sky.cpp

+49-31
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "profiler.h"
1010
#include "util/numeric.h" // MYMIN
1111
#include <cmath>
12+
#include "settings.h"
1213

1314
//! constructor
1415
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
5657
);
5758
m_stars[i].normalize();
5859
}
60+
61+
m_directional_colored_fog = g_settings->getBool("directional_colored_fog");
5962
}
6063

6164
void Sky::OnRegisterSceneNode()
@@ -482,32 +485,34 @@ void Sky::update(float time_of_day, float time_brightness,
482485

483486
// Horizon coloring based on sun and moon direction during sunset and sunrise
484487
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+
}
511516
}
512517

513518
video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor();
@@ -516,19 +521,30 @@ void Sky::update(float time_of_day, float time_brightness,
516521
bgcolor_bright.getRed() * m_brightness,
517522
bgcolor_bright.getGreen() * m_brightness,
518523
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+
}
520527

521528
video::SColor skycolor_bright = m_skycolor_bright_f.toSColor();
522529
m_skycolor = video::SColor(
523530
255,
524531
skycolor_bright.getRed() * m_brightness,
525532
skycolor_bright.getGreen() * m_brightness,
526533
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+
}
528537

529538
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+
}
532548
} else {
533549
cloud_direct_brightness = direct_brightness;
534550
}
@@ -539,7 +555,9 @@ void Sky::update(float time_of_day, float time_brightness,
539555
m_cloudcolor_bright_f.g * m_cloud_brightness,
540556
m_cloudcolor_bright_f.b * m_cloud_brightness,
541557
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+
}
543561

544562
}
545563

Diff for: ‎src/sky.h

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class Sky : public scene::ISceneNode
105105
float m_brightness;
106106
float m_cloud_brightness;
107107
bool m_clouds_visible;
108+
bool m_directional_colored_fog;
108109
video::SColorf m_bgcolor_bright_f;
109110
video::SColorf m_skycolor_bright_f;
110111
video::SColorf m_cloudcolor_bright_f;

0 commit comments

Comments
 (0)
Please sign in to comment.