aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/sky.cpp167
1 files changed, 86 insertions, 81 deletions
diff --git a/src/client/sky.cpp b/src/client/sky.cpp
index 4df51b4eb..766f08b1a 100644
--- a/src/client/sky.cpp
+++ b/src/client/sky.cpp
@@ -366,88 +366,14 @@ void Sky::render()
}
}
- // Draw moon
- if (wicked_time_of_day < 0.3 || wicked_time_of_day > 0.7) {
- if (!m_moon_texture) {
- driver->setMaterial(m_materials[1]);
- float d = moonsize * 1.9;
- video::SColor c = mooncolor;
- c.setAlpha(0.05 * 255);
- vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, c, t, t);
- vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
- vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
- vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for (video::S3DVertex &vertex : vertices) {
- // Switch from -Z (south) to -X (west)
- vertex.Pos.rotateXZBy(-90);
- vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
- }
- driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
-
- d = moonsize * 1.3;
- c = mooncolor;
- c.setAlpha(0.15 * 255);
- vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, c, t, t);
- vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
- vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
- vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for (video::S3DVertex &vertex : vertices) {
- // Switch from -Z (south) to -X (west)
- vertex.Pos.rotateXZBy(-90);
- vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
- }
- driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
-
- d = moonsize;
- vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, mooncolor, t, t);
- vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, mooncolor, o, t);
- vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, mooncolor, o, o);
- vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, mooncolor, t, o);
- for (video::S3DVertex &vertex : vertices) {
- // Switch from -Z (south) to -X (west)
- vertex.Pos.rotateXZBy(-90);
- vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
- }
- driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
-
- float d2 = moonsize * 0.6;
- vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, mooncolor2, t, t);
- vertices[1] = video::S3DVertex( d2,-d, -1, 0, 0, 1, mooncolor2, o, t);
- vertices[2] = video::S3DVertex( d2, d2, -1, 0, 0, 1, mooncolor2, o, o);
- vertices[3] = video::S3DVertex(-d, d2, -1, 0, 0, 1, mooncolor2, t, o);
- for (video::S3DVertex &vertex : vertices) {
- // Switch from -Z (south) to -X (west)
- vertex.Pos.rotateXZBy(-90);
- vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
- }
- driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
- } else {
- driver->setMaterial(m_materials[4]);
- float d = moonsize * 1.9;
- video::SColor c;
- if (m_moon_tonemap)
- c = video::SColor (0, 0, 0, 0);
- else
- c = video::SColor (255, 255, 255, 255);
- vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, c, t, t);
- vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
- vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
- vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for (video::S3DVertex &vertex : vertices) {
- // Switch from -Z (south) to -X (west)
- vertex.Pos.rotateXZBy(-90);
- vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
- }
- driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
- }
- }
-
- // Draw stars
+ // Draw stars before moon to be behind the moon
do {
driver->setMaterial(m_materials[1]);
- // Tune values, so that stars begin to be drawn at the same time the
- // sun disappears over the horizon, and so that star full brightness
- // is reached at time 20000, for 8 'hours' of full star brightness.
+ // Tune values so that stars first appear just after the sun
+ // disappears over the horizon, and disappear just before the sun
+ // appears over the horizon.
+ // Also tune so that stars are at full brightness from time 20000 to
+ // time 4000.
float starbrightness = MYMAX(0, MYMIN(1,
(0.25 - fabs(wicked_time_of_day < 0.5 ?
wicked_time_of_day : (1.0 - wicked_time_of_day))) * 20));
@@ -523,7 +449,86 @@ void Sky::render()
#endif
} while(false);
- // Draw far cloudy fog thing below east and west horizons
+ // Draw moon
+ if (wicked_time_of_day < 0.3 || wicked_time_of_day > 0.7) {
+ if (!m_moon_texture) {
+ driver->setMaterial(m_materials[1]);
+ float d = moonsize * 1.9;
+ video::SColor c = mooncolor;
+ c.setAlpha(0.05 * 255);
+ vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, c, t, t);
+ vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
+ vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
+ vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
+ for (video::S3DVertex &vertex : vertices) {
+ // Switch from -Z (south) to -X (west)
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ }
+ driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
+
+ d = moonsize * 1.3;
+ c = mooncolor;
+ c.setAlpha(0.15 * 255);
+ vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, c, t, t);
+ vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
+ vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
+ vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
+ for (video::S3DVertex &vertex : vertices) {
+ // Switch from -Z (south) to -X (west)
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ }
+ driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
+
+ d = moonsize;
+ vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, mooncolor, t, t);
+ vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, mooncolor, o, t);
+ vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, mooncolor, o, o);
+ vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, mooncolor, t, o);
+ for (video::S3DVertex &vertex : vertices) {
+ // Switch from -Z (south) to -X (west)
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ }
+ driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
+
+ float d2 = moonsize * 0.6;
+ vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, mooncolor2, t, t);
+ vertices[1] = video::S3DVertex( d2,-d, -1, 0, 0, 1, mooncolor2, o, t);
+ vertices[2] = video::S3DVertex( d2, d2, -1, 0, 0, 1, mooncolor2, o, o);
+ vertices[3] = video::S3DVertex(-d, d2, -1, 0, 0, 1, mooncolor2, t, o);
+ for (video::S3DVertex &vertex : vertices) {
+ // Switch from -Z (south) to -X (west)
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ }
+ driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
+ } else {
+ driver->setMaterial(m_materials[4]);
+ float d = moonsize * 1.9;
+ video::SColor c;
+ if (m_moon_tonemap)
+ c = video::SColor (0, 0, 0, 0);
+ else
+ c = video::SColor (255, 255, 255, 255);
+ vertices[0] = video::S3DVertex(-d, -d, -1, 0, 0, 1, c, t, t);
+ vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
+ vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
+ vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
+ for (video::S3DVertex &vertex : vertices) {
+ // Switch from -Z (south) to -X (west)
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ }
+ driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
+ }
+ }
+
+ // Draw far cloudy fog thing below East and West horizons.
+ // These act as horizons that the sun and moon rise and set over.
+ driver->setMaterial(m_materials[1]);
+
for (u32 j = 0; j < 2; j++) {
video::SColor c = cloudyfogcolor;
vertices[0] = video::S3DVertex(-1, -1.0, -1, 0, 0, 1, c, t, t);