2 #include "IVideoDriver.h"
3 #include "ISceneManager.h"
4 #include "ICameraSceneNode.h"
6 #include "tile.h" // getTexturePath
7 #include "noise.h" // easeCurve
8 #include "main.h" // g_profiler
10 #include "util/numeric.h" // MYMIN
15 Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, LocalPlayer* player):
16 scene::ISceneNode(parent, mgr, id),
18 m_fallback_bg_color(255,255,255,255),
21 m_cloud_brightness(0.5),
22 m_bgcolor_bright_f(1,1,1,1),
23 m_skycolor_bright_f(1,1,1,1),
24 m_cloudcolor_bright_f(1,1,1,1),
27 setAutomaticCulling(scene::EAC_OFF);
28 Box.MaxEdge.set(0,0,0);
29 Box.MinEdge.set(0,0,0);
35 mat.ZBuffer = video::ECFN_NEVER;
36 mat.ZWriteEnable = false;
38 mat.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
39 mat.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
40 mat.BackfaceCulling = false;
45 //m_materials[1].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
46 m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
49 m_materials[2].setTexture(0, mgr->getVideoDriver()->getTexture(
50 getTexturePath("sunrisebg.png").c_str()));
51 m_materials[2].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
52 //m_materials[2].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
54 for(u32 i=0; i<SKY_STAR_COUNT; i++){
56 myrand_range(-10000,10000),
57 myrand_range(-10000,10000),
58 myrand_range(-10000,10000)
60 m_stars[i].normalize();
63 m_directional_colored_fog = g_settings->getBool("directional_colored_fog");
66 void Sky::OnRegisterSceneNode()
69 SceneManager->registerNodeForRendering(this, scene::ESNRP_SKY_BOX);
71 scene::ISceneNode::OnRegisterSceneNode();
74 const core::aabbox3d<f32>& Sky::getBoundingBox() const
85 video::IVideoDriver* driver = SceneManager->getVideoDriver();
86 scene::ICameraSceneNode* camera = SceneManager->getActiveCamera();
88 if (!camera || !driver)
91 ScopeProfiler sp(g_profiler, "Sky::render()", SPT_AVG);
93 // draw perspective skybox
95 core::matrix4 translate(AbsoluteTransformation);
96 translate.setTranslation(camera->getAbsolutePosition());
98 // Draw the sky box between the near and far clip plane
99 const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
101 scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
103 driver->setTransform(video::ETS_WORLD, translate * scale);
107 float sunsize = 0.07;
108 video::SColorf suncolor_f(1, 1, 0, 1);
110 suncolor_f.g = MYMAX(0.3, MYMIN(1.0, 0.7+m_time_brightness*(0.5)));
111 suncolor_f.b = MYMAX(0.0, m_brightness*0.95);
112 video::SColorf suncolor2_f(1, 1, 1, 1);
114 suncolor_f.g = MYMAX(0.3, MYMIN(1.0, 0.85+m_time_brightness*(0.5)));
115 suncolor_f.b = MYMAX(0.0, m_brightness);
117 float moonsize = 0.04;
118 video::SColorf mooncolor_f(0.50, 0.57, 0.65, 1);
119 video::SColorf mooncolor2_f(0.85, 0.875, 0.9, 1);
121 float nightlength = 0.415;
122 float wn = nightlength / 2;
123 float wicked_time_of_day = 0;
124 if(m_time_of_day > wn && m_time_of_day < 1.0 - wn)
125 wicked_time_of_day = (m_time_of_day - wn)/(1.0-wn*2)*0.5 + 0.25;
126 else if(m_time_of_day < 0.5)
127 wicked_time_of_day = m_time_of_day / wn * 0.25;
129 wicked_time_of_day = 1.0 - ((1.0-m_time_of_day) / wn * 0.25);
130 /*std::cerr<<"time_of_day="<<m_time_of_day<<" -> "
131 <<"wicked_time_of_day="<<wicked_time_of_day<<std::endl;*/
133 video::SColor suncolor = suncolor_f.toSColor();
134 video::SColor suncolor2 = suncolor2_f.toSColor();
135 video::SColor mooncolor = mooncolor_f.toSColor();
136 video::SColor mooncolor2 = mooncolor2_f.toSColor();
140 static const u16 indices[4] = {0,1,2,3};
141 video::S3DVertex vertices[4];
143 driver->setMaterial(m_materials[1]);
145 //video::SColor cloudyfogcolor(255,255,255,255);
146 video::SColor cloudyfogcolor = m_bgcolor;
147 //video::SColor cloudyfogcolor = m_bgcolor.getInterpolated(m_skycolor, 0.5);
149 // Draw far cloudy fog thing
150 for(u32 j=0; j<4; j++)
152 video::SColor c = cloudyfogcolor.getInterpolated(m_skycolor, 0.45);
153 vertices[0] = video::S3DVertex(-1, 0.08,-1, 0,0,1, c, t, t);
154 vertices[1] = video::S3DVertex( 1, 0.08,-1, 0,0,1, c, o, t);
155 vertices[2] = video::S3DVertex( 1, 0.12,-1, 0,0,1, c, o, o);
156 vertices[3] = video::S3DVertex(-1, 0.12,-1, 0,0,1, c, t, o);
157 for(u32 i=0; i<4; i++){
162 // Switch from -Z (south) to +X (east)
163 vertices[i].Pos.rotateXZBy(90);
165 // Switch from -Z (south) to -X (west)
166 vertices[i].Pos.rotateXZBy(-90);
168 // Switch from -Z (south) to -Z (north)
169 vertices[i].Pos.rotateXZBy(-180);
171 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
173 for(u32 j=0; j<4; j++)
175 video::SColor c = cloudyfogcolor;
176 vertices[0] = video::S3DVertex(-1,-1.0,-1, 0,0,1, c, t, t);
177 vertices[1] = video::S3DVertex( 1,-1.0,-1, 0,0,1, c, o, t);
178 vertices[2] = video::S3DVertex( 1, 0.08,-1, 0,0,1, c, o, o);
179 vertices[3] = video::S3DVertex(-1, 0.08,-1, 0,0,1, c, t, o);
180 for(u32 i=0; i<4; i++){
185 // Switch from -Z (south) to +X (east)
186 vertices[i].Pos.rotateXZBy(90);
188 // Switch from -Z (south) to -X (west)
189 vertices[i].Pos.rotateXZBy(-90);
191 // Switch from -Z (south) to -Z (north)
192 vertices[i].Pos.rotateXZBy(-180);
194 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
197 driver->setMaterial(m_materials[2]);
201 float mid = (wicked_time_of_day < 0.5 ? mid1 : (1.0 - mid1));
202 float a_ = 1.0 - fabs(wicked_time_of_day - mid) * 35.0;
203 float a = easeCurve(MYMAX(0, MYMIN(1, a_)));
204 //std::cerr<<"a_="<<a_<<" a="<<a<<std::endl;
205 video::SColor c(255,255,255,255);
206 float y = -(1.0 - a) * 0.2;
207 vertices[0] = video::S3DVertex(-1,-0.05+y,-1, 0,0,1, c, t, t);
208 vertices[1] = video::S3DVertex( 1,-0.05+y,-1, 0,0,1, c, o, t);
209 vertices[2] = video::S3DVertex( 1, 0.2+y,-1, 0,0,1, c, o, o);
210 vertices[3] = video::S3DVertex(-1, 0.2+y,-1, 0,0,1, c, t, o);
211 for(u32 i=0; i<4; i++){
212 if(wicked_time_of_day < 0.5)
213 // Switch from -Z (south) to +X (east)
214 vertices[i].Pos.rotateXZBy(90);
216 // Switch from -Z (south) to -X (west)
217 vertices[i].Pos.rotateXZBy(-90);
219 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
222 driver->setMaterial(m_materials[1]);
225 if(wicked_time_of_day > 0.15 && wicked_time_of_day < 0.85)
227 float d = sunsize * 1.7;
228 video::SColor c = suncolor;
229 c.setAlpha(0.05*255);
230 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t);
231 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t);
232 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o);
233 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o);
234 for(u32 i=0; i<4; i++){
235 // Switch from -Z (south) to +X (east)
236 vertices[i].Pos.rotateXZBy(90);
237 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
239 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
243 c.setAlpha(0.15*255);
244 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t);
245 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t);
246 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o);
247 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o);
248 for(u32 i=0; i<4; i++){
249 // Switch from -Z (south) to +X (east)
250 vertices[i].Pos.rotateXZBy(90);
251 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
253 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
256 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, suncolor, t, t);
257 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, suncolor, o, t);
258 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, suncolor, o, o);
259 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, suncolor, t, o);
260 for(u32 i=0; i<4; i++){
261 // Switch from -Z (south) to +X (east)
262 vertices[i].Pos.rotateXZBy(90);
263 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
265 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
268 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, suncolor2, t, t);
269 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, suncolor2, o, t);
270 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, suncolor2, o, o);
271 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, suncolor2, t, o);
272 for(u32 i=0; i<4; i++){
273 // Switch from -Z (south) to +X (east)
274 vertices[i].Pos.rotateXZBy(90);
275 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
277 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
280 if(wicked_time_of_day < 0.3 || wicked_time_of_day > 0.7)
282 float d = moonsize * 1.9;
283 video::SColor c = mooncolor;
284 c.setAlpha(0.05*255);
285 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t);
286 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t);
287 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o);
288 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o);
289 for(u32 i=0; i<4; i++){
290 // Switch from -Z (south) to -X (west)
291 vertices[i].Pos.rotateXZBy(-90);
292 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
294 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
298 c.setAlpha(0.15*255);
299 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t);
300 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t);
301 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o);
302 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o);
303 for(u32 i=0; i<4; i++){
304 // Switch from -Z (south) to -X (west)
305 vertices[i].Pos.rotateXZBy(-90);
306 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
308 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
311 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, mooncolor, t, t);
312 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, mooncolor, o, t);
313 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, mooncolor, o, o);
314 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, mooncolor, t, o);
315 for(u32 i=0; i<4; i++){
316 // Switch from -Z (south) to -X (west)
317 vertices[i].Pos.rotateXZBy(-90);
318 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
320 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
322 float d2 = moonsize * 0.6;
323 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, mooncolor2, t, t);
324 vertices[1] = video::S3DVertex( d2,-d,-1, 0,0,1, mooncolor2, o, t);
325 vertices[2] = video::S3DVertex( d2, d2,-1, 0,0,1, mooncolor2, o, o);
326 vertices[3] = video::S3DVertex(-d, d2,-1, 0,0,1, mooncolor2, t, o);
327 for(u32 i=0; i<4; i++){
328 // Switch from -Z (south) to -X (west)
329 vertices[i].Pos.rotateXZBy(-90);
330 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
332 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
336 float starbrightness = MYMAX(0, MYMIN(1,
337 (0.285 - fabs(wicked_time_of_day < 0.5 ?
338 wicked_time_of_day : (1.0 - wicked_time_of_day))) * 10));
339 float f = starbrightness;
341 video::SColor starcolor(255, f*90,f*90,f*90);
342 if(starcolor.getBlue() < m_skycolor.getBlue())
344 u16 indices[SKY_STAR_COUNT*4];
345 video::S3DVertex vertices[SKY_STAR_COUNT*4];
346 for(u32 i=0; i<SKY_STAR_COUNT; i++){
347 indices[i*4+0] = i*4+0;
348 indices[i*4+1] = i*4+1;
349 indices[i*4+2] = i*4+2;
350 indices[i*4+3] = i*4+3;
352 core::CMatrix4<f32> a;
353 a.buildRotateFromTo(v3f(0,1,0), v3f(d,1+d/2,0));
356 a.buildRotateFromTo(v3f(0,1,0), v3f(d,1,d));
359 a.buildRotateFromTo(v3f(0,1,0), v3f(0,1-d/2,d));
362 p.rotateXYBy(wicked_time_of_day * 360 - 90);
363 p1.rotateXYBy(wicked_time_of_day * 360 - 90);
364 p2.rotateXYBy(wicked_time_of_day * 360 - 90);
365 p3.rotateXYBy(wicked_time_of_day * 360 - 90);
366 vertices[i*4+0].Pos = p;
367 vertices[i*4+0].Color = starcolor;
368 vertices[i*4+1].Pos = p1;
369 vertices[i*4+1].Color = starcolor;
370 vertices[i*4+2].Pos = p2;
371 vertices[i*4+2].Color = starcolor;
372 vertices[i*4+3].Pos = p3;
373 vertices[i*4+3].Color = starcolor;
375 driver->drawVertexPrimitiveList(vertices, SKY_STAR_COUNT*4,
376 indices, SKY_STAR_COUNT, video::EVT_STANDARD,
377 scene::EPT_QUADS, video::EIT_16BIT);
380 for(u32 j=0; j<2; j++)
382 //video::SColor c = m_skycolor;
383 video::SColor c = cloudyfogcolor;
384 vertices[0] = video::S3DVertex(-1,-1.0,-1, 0,0,1, c, t, t);
385 vertices[1] = video::S3DVertex( 1,-1.0,-1, 0,0,1, c, o, t);
386 vertices[2] = video::S3DVertex( 1,-0.02,-1, 0,0,1, c, o, o);
387 vertices[3] = video::S3DVertex(-1,-0.02,-1, 0,0,1, c, t, o);
388 for(u32 i=0; i<4; i++){
389 //if(wicked_time_of_day < 0.5)
391 // Switch from -Z (south) to +X (east)
392 vertices[i].Pos.rotateXZBy(90);
394 // Switch from -Z (south) to -X (west)
395 vertices[i].Pos.rotateXZBy(-90);
397 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
402 void Sky::update(float time_of_day, float time_brightness,
403 float direct_brightness, bool sunlight_seen)
405 // Stabilize initial brightness and color values by flooding updates
407 /*dstream<<"First update with time_of_day="<<time_of_day
408 <<" time_brightness="<<time_brightness
409 <<" direct_brightness="<<direct_brightness
410 <<" sunlight_seen="<<sunlight_seen<<std::endl;*/
411 m_first_update = false;
412 for(u32 i=0; i<100; i++){
413 update(time_of_day, time_brightness, direct_brightness,
419 m_time_of_day = time_of_day;
420 m_time_brightness = time_brightness;
421 m_sunlight_seen = sunlight_seen;
423 bool is_dawn = (time_brightness >= 0.20 && time_brightness < 0.35);
425 //video::SColorf bgcolor_bright_normal_f(170./255,200./255,230./255, 1.0);
426 video::SColorf bgcolor_bright_normal_f(155./255,193./255,240./255, 1.0);
427 video::SColorf bgcolor_bright_indoor_f(100./255,100./255,100./255, 1.0);
428 //video::SColorf bgcolor_bright_dawn_f(0.666,200./255*0.7,230./255*0.5,1.0);
429 //video::SColorf bgcolor_bright_dawn_f(0.666,0.549,0.220,1.0);
430 //video::SColorf bgcolor_bright_dawn_f(0.666*1.2,0.549*1.0,0.220*1.0, 1.0);
431 //video::SColorf bgcolor_bright_dawn_f(0.666*1.2,0.549*1.0,0.220*1.2,1.0);
432 video::SColorf bgcolor_bright_dawn_f
433 (155./255*1.2,193./255,240./255, 1.0);
435 video::SColorf skycolor_bright_normal_f =
436 video::SColor(255, 140, 186, 250);
437 video::SColorf skycolor_bright_dawn_f =
438 video::SColor(255, 180, 186, 250);
440 video::SColorf cloudcolor_bright_normal_f =
441 video::SColor(255, 240,240,255);
442 //video::SColorf cloudcolor_bright_dawn_f(1.0, 0.591, 0.4);
443 //video::SColorf cloudcolor_bright_dawn_f(1.0, 0.65, 0.44);
444 //video::SColorf cloudcolor_bright_dawn_f(1.0, 0.7, 0.5);
445 video::SColorf cloudcolor_bright_dawn_f(1.0, 0.875, 0.75);
447 float cloud_color_change_fraction = 0.95;
449 if(fabs(time_brightness - m_brightness) < 0.2){
450 m_brightness = m_brightness * 0.95 + time_brightness * 0.05;
452 m_brightness = m_brightness * 0.80 + time_brightness * 0.20;
453 cloud_color_change_fraction = 0.0;
457 if(direct_brightness < m_brightness)
458 m_brightness = m_brightness * 0.95 + direct_brightness * 0.05;
460 m_brightness = m_brightness * 0.98 + direct_brightness * 0.02;
463 m_clouds_visible = true;
464 float color_change_fraction = 0.98;
467 m_bgcolor_bright_f = m_bgcolor_bright_f.getInterpolated(
468 bgcolor_bright_dawn_f, color_change_fraction);
469 m_skycolor_bright_f = m_skycolor_bright_f.getInterpolated(
470 skycolor_bright_dawn_f, color_change_fraction);
471 m_cloudcolor_bright_f = m_cloudcolor_bright_f.getInterpolated(
472 cloudcolor_bright_dawn_f, color_change_fraction);
474 m_bgcolor_bright_f = m_bgcolor_bright_f.getInterpolated(
475 bgcolor_bright_normal_f, color_change_fraction);
476 m_skycolor_bright_f = m_skycolor_bright_f.getInterpolated(
477 skycolor_bright_normal_f, color_change_fraction);
478 m_cloudcolor_bright_f = m_cloudcolor_bright_f.getInterpolated(
479 cloudcolor_bright_normal_f, color_change_fraction);
482 m_bgcolor_bright_f = m_bgcolor_bright_f.getInterpolated(
483 bgcolor_bright_indoor_f, color_change_fraction);
484 m_skycolor_bright_f = m_skycolor_bright_f.getInterpolated(
485 bgcolor_bright_indoor_f, color_change_fraction);
486 m_cloudcolor_bright_f = m_cloudcolor_bright_f.getInterpolated(
487 cloudcolor_bright_normal_f, color_change_fraction);
488 m_clouds_visible = false;
491 // Horizon coloring based on sun and moon direction during sunset and sunrise
492 video::SColor pointcolor = video::SColor(255, 255, 255, m_bgcolor.getAlpha());
493 if (m_directional_colored_fog) {
494 if (m_horizon_blend() != 0)
496 // calculate hemisphere value from yaw
497 f32 pointcolor_blend = wrapDegrees_0_360(m_player->getYaw() + 90);
498 if (pointcolor_blend > 180)
499 pointcolor_blend = 360 - pointcolor_blend;
500 pointcolor_blend /= 180;
501 // bound view angle to determine where transition starts and ends
502 pointcolor_blend = rangelim(1 - pointcolor_blend * 1.375, 0, 1 / 1.375) * 1.375;
503 // combine the colors when looking up or down, otherwise turning looks weird
504 pointcolor_blend += (0.5 - pointcolor_blend) * (1 - MYMIN((90 - std::abs(m_player->getPitch())) / 90 * 1.5, 1));
505 // invert direction to match where the sun and moon are rising
506 if (m_time_of_day > 0.5)
507 pointcolor_blend = 1 - pointcolor_blend;
509 // horizon colors of sun and moon
510 f32 pointcolor_light = rangelim(m_time_brightness * 3, 0.2, 1);
511 video::SColorf pointcolor_sun_f(1, 1, 1, 1);
512 pointcolor_sun_f.r = pointcolor_light * 1;
513 pointcolor_sun_f.b = pointcolor_light * (0.25 + (rangelim(m_time_brightness, 0.25, 0.75) - 0.25) * 2 * 0.75);
514 pointcolor_sun_f.g = pointcolor_light * (pointcolor_sun_f.b * 0.375 + (rangelim(m_time_brightness, 0.05, 0.15) - 0.05) * 10 * 0.625);
515 video::SColorf pointcolor_moon_f(0.5 * pointcolor_light, 0.6 * pointcolor_light, 0.8 * pointcolor_light, 1);
516 video::SColor pointcolor_sun = pointcolor_sun_f.toSColor();
517 video::SColor pointcolor_moon = pointcolor_moon_f.toSColor();
518 // calculate the blend color
519 pointcolor = m_mix_scolor(pointcolor_moon, pointcolor_sun, pointcolor_blend);
523 video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor();
524 m_bgcolor = video::SColor(
526 bgcolor_bright.getRed() * m_brightness,
527 bgcolor_bright.getGreen() * m_brightness,
528 bgcolor_bright.getBlue() * m_brightness);
529 if (m_directional_colored_fog) {
530 m_bgcolor = m_mix_scolor(m_bgcolor, pointcolor, m_horizon_blend() * 0.5);
533 video::SColor skycolor_bright = m_skycolor_bright_f.toSColor();
534 m_skycolor = video::SColor(
536 skycolor_bright.getRed() * m_brightness,
537 skycolor_bright.getGreen() * m_brightness,
538 skycolor_bright.getBlue() * m_brightness);
539 if (m_directional_colored_fog) {
540 m_skycolor = m_mix_scolor(m_skycolor, pointcolor, m_horizon_blend() * 0.25);
543 float cloud_direct_brightness = 0;
545 if (!m_directional_colored_fog) {
546 cloud_direct_brightness = time_brightness;
547 if(time_brightness >= 0.2 && time_brightness < 0.7)
548 cloud_direct_brightness *= 1.3;
551 cloud_direct_brightness = MYMIN(m_horizon_blend() * 0.15 + m_time_brightness, 1);
554 cloud_direct_brightness = direct_brightness;
556 m_cloud_brightness = m_cloud_brightness * cloud_color_change_fraction +
557 cloud_direct_brightness * (1.0 - cloud_color_change_fraction);
558 m_cloudcolor_f = video::SColorf(
559 m_cloudcolor_bright_f.r * m_cloud_brightness,
560 m_cloudcolor_bright_f.g * m_cloud_brightness,
561 m_cloudcolor_bright_f.b * m_cloud_brightness,
563 if (m_directional_colored_fog) {
564 m_cloudcolor_f = m_mix_scolorf(m_cloudcolor_f, video::SColorf(pointcolor), m_horizon_blend() * 0.25);