Draw stars behind the moon (#7928)
This time correctly, by resetting the 'material' to '1' after moon draw.master
parent
5dd542401a
commit
ff12630bc9
|
@ -366,6 +366,89 @@ void Sky::render()
|
|||
}
|
||||
}
|
||||
|
||||
// Draw stars before moon to be behind the moon
|
||||
do {
|
||||
driver->setMaterial(m_materials[1]);
|
||||
// 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));
|
||||
float f = starbrightness;
|
||||
float d = 0.007 / 2;
|
||||
video::SColor starcolor(255, f * 90, f * 90, f * 90);
|
||||
// Stars are only drawn when brighter than skycolor
|
||||
if (starcolor.getBlue() < m_skycolor.getBlue())
|
||||
break;
|
||||
#ifdef __ANDROID__
|
||||
u16 indices[SKY_STAR_COUNT * 3];
|
||||
video::S3DVertex vertices[SKY_STAR_COUNT * 3];
|
||||
for (u32 i = 0; i < SKY_STAR_COUNT; i++) {
|
||||
indices[i * 3 + 0] = i * 3 + 0;
|
||||
indices[i * 3 + 1] = i * 3 + 1;
|
||||
indices[i * 3 + 2] = i * 3 + 2;
|
||||
v3f r = m_stars[i];
|
||||
core::CMatrix4<f32> a;
|
||||
a.buildRotateFromTo(v3f(0, 1, 0), r);
|
||||
v3f p = v3f(-d, 1, -d);
|
||||
v3f p1 = v3f(d, 1, 0);
|
||||
v3f p2 = v3f(-d, 1, d);
|
||||
a.rotateVect(p);
|
||||
a.rotateVect(p1);
|
||||
a.rotateVect(p2);
|
||||
p.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p1.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p2.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
vertices[i * 3 + 0].Pos = p;
|
||||
vertices[i * 3 + 0].Color = starcolor;
|
||||
vertices[i * 3 + 1].Pos = p1;
|
||||
vertices[i * 3 + 1].Color = starcolor;
|
||||
vertices[i * 3 + 2].Pos = p2;
|
||||
vertices[i * 3 + 2].Color = starcolor;
|
||||
}
|
||||
driver->drawIndexedTriangleList(vertices, SKY_STAR_COUNT * 3,
|
||||
indices, SKY_STAR_COUNT);
|
||||
#else
|
||||
u16 indices[SKY_STAR_COUNT * 4];
|
||||
video::S3DVertex vertices[SKY_STAR_COUNT * 4];
|
||||
for (u32 i = 0; i < SKY_STAR_COUNT; i++) {
|
||||
indices[i * 4 + 0] = i * 4 + 0;
|
||||
indices[i * 4 + 1] = i * 4 + 1;
|
||||
indices[i * 4 + 2] = i * 4 + 2;
|
||||
indices[i * 4 + 3] = i * 4 + 3;
|
||||
v3f r = m_stars[i];
|
||||
core::CMatrix4<f32> a;
|
||||
a.buildRotateFromTo(v3f(0, 1, 0), r);
|
||||
v3f p = v3f(-d, 1, -d);
|
||||
v3f p1 = v3f( d, 1, -d);
|
||||
v3f p2 = v3f( d, 1, d);
|
||||
v3f p3 = v3f(-d, 1, d);
|
||||
a.rotateVect(p);
|
||||
a.rotateVect(p1);
|
||||
a.rotateVect(p2);
|
||||
a.rotateVect(p3);
|
||||
p.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p1.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p2.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p3.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
vertices[i * 4 + 0].Pos = p;
|
||||
vertices[i * 4 + 0].Color = starcolor;
|
||||
vertices[i * 4 + 1].Pos = p1;
|
||||
vertices[i * 4 + 1].Color = starcolor;
|
||||
vertices[i * 4 + 2].Pos = p2;
|
||||
vertices[i * 4 + 2].Color = starcolor;
|
||||
vertices[i * 4 + 3].Pos = p3;
|
||||
vertices[i * 4 + 3].Color = starcolor;
|
||||
}
|
||||
driver->drawVertexPrimitiveList(vertices, SKY_STAR_COUNT * 4,
|
||||
indices, SKY_STAR_COUNT, video::EVT_STANDARD,
|
||||
scene::EPT_QUADS, video::EIT_16BIT);
|
||||
#endif
|
||||
} while(false);
|
||||
|
||||
// Draw moon
|
||||
if (wicked_time_of_day < 0.3 || wicked_time_of_day > 0.7) {
|
||||
if (!m_moon_texture) {
|
||||
|
@ -442,88 +525,10 @@ void Sky::render()
|
|||
}
|
||||
}
|
||||
|
||||
// Draw stars
|
||||
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.
|
||||
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));
|
||||
float f = starbrightness;
|
||||
float d = 0.007 / 2;
|
||||
video::SColor starcolor(255, f * 90, f * 90, f * 90);
|
||||
// Stars are only drawn when brighter than skycolor
|
||||
if (starcolor.getBlue() < m_skycolor.getBlue())
|
||||
break;
|
||||
#ifdef __ANDROID__
|
||||
u16 indices[SKY_STAR_COUNT * 3];
|
||||
video::S3DVertex vertices[SKY_STAR_COUNT * 3];
|
||||
for (u32 i = 0; i < SKY_STAR_COUNT; i++) {
|
||||
indices[i * 3 + 0] = i * 3 + 0;
|
||||
indices[i * 3 + 1] = i * 3 + 1;
|
||||
indices[i * 3 + 2] = i * 3 + 2;
|
||||
v3f r = m_stars[i];
|
||||
core::CMatrix4<f32> a;
|
||||
a.buildRotateFromTo(v3f(0, 1, 0), r);
|
||||
v3f p = v3f(-d, 1, -d);
|
||||
v3f p1 = v3f(d, 1, 0);
|
||||
v3f p2 = v3f(-d, 1, d);
|
||||
a.rotateVect(p);
|
||||
a.rotateVect(p1);
|
||||
a.rotateVect(p2);
|
||||
p.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p1.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p2.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
vertices[i * 3 + 0].Pos = p;
|
||||
vertices[i * 3 + 0].Color = starcolor;
|
||||
vertices[i * 3 + 1].Pos = p1;
|
||||
vertices[i * 3 + 1].Color = starcolor;
|
||||
vertices[i * 3 + 2].Pos = p2;
|
||||
vertices[i * 3 + 2].Color = starcolor;
|
||||
}
|
||||
driver->drawIndexedTriangleList(vertices, SKY_STAR_COUNT * 3,
|
||||
indices, SKY_STAR_COUNT);
|
||||
#else
|
||||
u16 indices[SKY_STAR_COUNT * 4];
|
||||
video::S3DVertex vertices[SKY_STAR_COUNT * 4];
|
||||
for (u32 i = 0; i < SKY_STAR_COUNT; i++) {
|
||||
indices[i * 4 + 0] = i * 4 + 0;
|
||||
indices[i * 4 + 1] = i * 4 + 1;
|
||||
indices[i * 4 + 2] = i * 4 + 2;
|
||||
indices[i * 4 + 3] = i * 4 + 3;
|
||||
v3f r = m_stars[i];
|
||||
core::CMatrix4<f32> a;
|
||||
a.buildRotateFromTo(v3f(0, 1, 0), r);
|
||||
v3f p = v3f(-d, 1, -d);
|
||||
v3f p1 = v3f( d, 1, -d);
|
||||
v3f p2 = v3f( d, 1, d);
|
||||
v3f p3 = v3f(-d, 1, d);
|
||||
a.rotateVect(p);
|
||||
a.rotateVect(p1);
|
||||
a.rotateVect(p2);
|
||||
a.rotateVect(p3);
|
||||
p.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p1.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p2.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
p3.rotateXYBy(wicked_time_of_day * 360 - 90);
|
||||
vertices[i * 4 + 0].Pos = p;
|
||||
vertices[i * 4 + 0].Color = starcolor;
|
||||
vertices[i * 4 + 1].Pos = p1;
|
||||
vertices[i * 4 + 1].Color = starcolor;
|
||||
vertices[i * 4 + 2].Pos = p2;
|
||||
vertices[i * 4 + 2].Color = starcolor;
|
||||
vertices[i * 4 + 3].Pos = p3;
|
||||
vertices[i * 4 + 3].Color = starcolor;
|
||||
}
|
||||
driver->drawVertexPrimitiveList(vertices, SKY_STAR_COUNT * 4,
|
||||
indices, SKY_STAR_COUNT, video::EVT_STANDARD,
|
||||
scene::EPT_QUADS, video::EIT_16BIT);
|
||||
#endif
|
||||
} while(false);
|
||||
// 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]);
|
||||
|
||||
// Draw far cloudy fog thing below east and west horizons
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue