aboutsummaryrefslogtreecommitdiff
path: root/src/client/sky.cpp
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2022-09-06 12:21:55 +0200
committerGitHub <noreply@github.com>2022-09-06 11:21:55 +0100
commit643971c948c1aef424f2a55e81414e30958c40ee (patch)
treeb7e39dd437e155dcd69bfeeb92241409b8b15376 /src/client/sky.cpp
parent038da00e799b4bf3af824075a260083c56392964 (diff)
downloadminetest-643971c948c1aef424f2a55e81414e30958c40ee.tar.xz
Add documentation of sun/moon orientation/scale differences (#12145)
Diffstat (limited to 'src/client/sky.cpp')
-rw-r--r--src/client/sky.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/client/sky.cpp b/src/client/sky.cpp
index 5541b16aa..e622a6a94 100644
--- a/src/client/sky.cpp
+++ b/src/client/sky.cpp
@@ -142,7 +142,6 @@ void Sky::render()
driver->setTransform(video::ETS_WORLD, translate * scale);
if (m_sunlight_seen) {
- float sunsize = 0.07;
video::SColorf suncolor_f(1, 1, 0, 1);
//suncolor_f.r = 1;
//suncolor_f.g = MYMAX(0.3, MYMIN(1.0, 0.7 + m_time_brightness * 0.5));
@@ -156,7 +155,6 @@ void Sky::render()
suncolor_f.g = MYMAX(0.3, MYMIN(1.0, 0.85 + m_time_brightness * 0.5));
suncolor_f.b = MYMAX(0.0, m_brightness);
- float moonsize = 0.04;
video::SColorf mooncolor_f(0.50, 0.57, 0.65, 1);
video::SColorf mooncolor2_f(0.85, 0.875, 0.9, 1);
@@ -294,11 +292,11 @@ void Sky::render()
// Draw sun
if (m_sun_params.visible)
- draw_sun(driver, sunsize, suncolor, suncolor2, wicked_time_of_day);
+ draw_sun(driver, suncolor, suncolor2, wicked_time_of_day);
// Draw moon
if (m_moon_params.visible)
- draw_moon(driver, moonsize, mooncolor, mooncolor2, wicked_time_of_day);
+ draw_moon(driver, mooncolor, mooncolor2, wicked_time_of_day);
// Draw far cloudy fog thing below all horizons in front of sun, moon
// and stars.
@@ -573,16 +571,18 @@ v3f Sky::getMoonDirection()
return getSkyBodyPosition(270, getWickedTimeOfDay(m_time_of_day) * 360 - 90, m_sky_body_orbit_tilt);
}
-void Sky::draw_sun(video::IVideoDriver *driver, float sunsize, const video::SColor &suncolor,
+void Sky::draw_sun(video::IVideoDriver *driver, const video::SColor &suncolor,
const video::SColor &suncolor2, float wicked_time_of_day)
/* Draw sun in the sky.
* driver: Video driver object used to draw
- * sunsize: the default size of the sun
* suncolor: main sun color
* suncolor2: second sun color
* wicked_time_of_day: current time of day, to know where should be the sun in the sky
*/
{
+ // A magic number that contributes to the ratio 1.57 sun/moon size difference.
+ constexpr float sunsize = 0.07;
+
static const u16 indices[] = {0, 1, 2, 0, 2, 3};
std::array<video::S3DVertex, 4> vertices;
if (!m_sun_texture) {
@@ -605,6 +605,8 @@ void Sky::draw_sun(video::IVideoDriver *driver, float sunsize, const video::SCol
}
} else {
driver->setMaterial(m_materials[3]);
+ // Another magic number that contributes to the ratio 1.57 sun/moon size
+ // difference.
float d = (sunsize * 1.7) * m_sun_params.scale;
video::SColor c;
if (m_sun_tonemap)
@@ -618,18 +620,20 @@ void Sky::draw_sun(video::IVideoDriver *driver, float sunsize, const video::SCol
}
-void Sky::draw_moon(video::IVideoDriver *driver, float moonsize, const video::SColor &mooncolor,
+void Sky::draw_moon(video::IVideoDriver *driver, const video::SColor &mooncolor,
const video::SColor &mooncolor2, float wicked_time_of_day)
/*
* Draw moon in the sky.
* driver: Video driver object used to draw
- * moonsize: the default size of the moon
* mooncolor: main moon color
* mooncolor2: second moon color
* wicked_time_of_day: current time of day, to know where should be the moon in
* the sky
*/
{
+ // A magic number that contributes to the ratio 1.57 sun/moon size difference.
+ constexpr float moonsize = 0.04;
+
static const u16 indices[] = {0, 1, 2, 0, 2, 3};
std::array<video::S3DVertex, 4> vertices;
if (!m_moon_texture) {
@@ -658,6 +662,8 @@ void Sky::draw_moon(video::IVideoDriver *driver, float moonsize, const video::SC
}
} else {
driver->setMaterial(m_materials[4]);
+ // Another magic number that contributes to the ratio 1.57 sun/moon size
+ // difference.
float d = (moonsize * 1.9) * m_moon_params.scale;
video::SColor c;
if (m_moon_tonemap)