diff options
author | Liso <anlismon@gmail.com> | 2021-06-06 18:51:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-06 18:51:21 +0200 |
commit | c47313db65f968559711ac1b505ef341a9872017 (patch) | |
tree | 63d9b1b2be512918e2361d96e4fb52ff1ec3f9de /src/client/sky.cpp | |
parent | 46f42e15c41cf4ab23c5ff4cd8a7d99d94d10d7b (diff) | |
download | minetest-c47313db65f968559711ac1b505ef341a9872017.tar.gz minetest-c47313db65f968559711ac1b505ef341a9872017.tar.bz2 minetest-c47313db65f968559711ac1b505ef341a9872017.zip |
Shadow mapping render pass (#11244)
Co-authored-by: x2048 <codeforsmile@gmail.com>
Diffstat (limited to 'src/client/sky.cpp')
-rw-r--r-- | src/client/sky.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/client/sky.cpp b/src/client/sky.cpp index 47296a7a5..1cf9a4afc 100644 --- a/src/client/sky.cpp +++ b/src/client/sky.cpp @@ -122,7 +122,14 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade m_materials[i].Lighting = true; m_materials[i].MaterialType = video::EMT_SOLID; } + m_directional_colored_fog = g_settings->getBool("directional_colored_fog"); + + if (g_settings->getBool("enable_dynamic_shadows")) { + float val = g_settings->getFloat("shadow_sky_body_orbit_tilt"); + m_sky_body_orbit_tilt = rangelim(val, 0.0f, 60.0f); + } + setStarCount(1000, true); } @@ -175,17 +182,7 @@ void Sky::render() video::SColorf mooncolor_f(0.50, 0.57, 0.65, 1); video::SColorf mooncolor2_f(0.85, 0.875, 0.9, 1); - float nightlength = 0.415; - float wn = nightlength / 2; - float wicked_time_of_day = 0; - if (m_time_of_day > wn && m_time_of_day < 1.0 - wn) - wicked_time_of_day = (m_time_of_day - wn) / (1.0 - wn * 2) * 0.5 + 0.25; - else if (m_time_of_day < 0.5) - wicked_time_of_day = m_time_of_day / wn * 0.25; - else - wicked_time_of_day = 1.0 - ((1.0 - m_time_of_day) / wn * 0.25); - /*std::cerr<<"time_of_day="<<m_time_of_day<<" -> " - <<"wicked_time_of_day="<<wicked_time_of_day<<std::endl;*/ + float wicked_time_of_day = getWickedTimeOfDay(m_time_of_day); video::SColor suncolor = suncolor_f.toSColor(); video::SColor suncolor2 = suncolor2_f.toSColor(); @@ -739,10 +736,15 @@ void Sky::place_sky_body( * day_position: turn the body around the Z axis, to place it depending of the time of the day */ { + v3f centrum(0, 0, -1); + centrum.rotateXZBy(horizon_position); + centrum.rotateXYBy(day_position); + centrum.rotateYZBy(m_sky_body_orbit_tilt); for (video::S3DVertex &vertex : vertices) { // Body is directed to -Z (south) by default vertex.Pos.rotateXZBy(horizon_position); vertex.Pos.rotateXYBy(day_position); + vertex.Pos.Z += centrum.Z; } } @@ -931,3 +933,17 @@ void Sky::setSkyDefaults() m_moon_params = sky_defaults.getMoonDefaults(); m_star_params = sky_defaults.getStarDefaults(); } + +float getWickedTimeOfDay(float time_of_day) +{ + float nightlength = 0.415f; + float wn = nightlength / 2; + float wicked_time_of_day = 0; + if (time_of_day > wn && time_of_day < 1.0f - wn) + wicked_time_of_day = (time_of_day - wn) / (1.0f - wn * 2) * 0.5f + 0.25f; + else if (time_of_day < 0.5f) + wicked_time_of_day = time_of_day / wn * 0.25f; + else + wicked_time_of_day = 1.0f - ((1.0f - time_of_day) / wn * 0.25f); + return wicked_time_of_day; +} |