1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add documentation of sun/moon orientation/scale differences (#12145)

This commit is contained in:
DS 2022-09-06 12:21:55 +02:00 committed by GitHub
parent 038da00e79
commit 643971c948
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 15 deletions

View file

@ -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)