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),
19 m_cloud_brightness(0.5),
20 m_bgcolor_bright_f(1,1,1,1),
21 m_skycolor_bright_f(1,1,1,1),
22 m_cloudcolor_bright_f(1,1,1,1),
25 setAutomaticCulling(scene::EAC_OFF);
26 Box.MaxEdge.set(0,0,0);
27 Box.MinEdge.set(0,0,0);
33 mat.ZBuffer = video::ECFN_NEVER;
34 mat.ZWriteEnable = false;
36 mat.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
37 mat.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
38 mat.BackfaceCulling = false;
43 //m_materials[1].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
44 m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
47 m_materials[2].setTexture(0, mgr->getVideoDriver()->getTexture(
48 getTexturePath("sunrisebg.png").c_str()));
49 m_materials[2].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
50 //m_materials[2].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
52 for(u32 i=0; i<SKY_STAR_COUNT; i++){
54 myrand_range(-10000,10000),
55 myrand_range(-10000,10000),
56 myrand_range(-10000,10000)
58 m_stars[i].normalize();
61 m_directional_colored_fog = g_settings->getBool("directional_colored_fog");
64 void Sky::OnRegisterSceneNode()
67 SceneManager->registerNodeForRendering(this, scene::ESNRP_SKY_BOX);
69 scene::ISceneNode::OnRegisterSceneNode();
72 const core::aabbox3d<f32>& Sky::getBoundingBox() const
80 video::IVideoDriver* driver = SceneManager->getVideoDriver();
81 scene::ICameraSceneNode* camera = SceneManager->getActiveCamera();
83 if (!camera || !driver)
86 ScopeProfiler sp(g_profiler, "Sky::render()", SPT_AVG);
88 // draw perspective skybox
90 core::matrix4 translate(AbsoluteTransformation);
91 translate.setTranslation(camera->getAbsolutePosition());
93 // Draw the sky box between the near and far clip plane
94 const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
96 scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
98 driver->setTransform(video::ETS_WORLD, translate * scale);
102 float sunsize = 0.07;
103 video::SColorf suncolor_f(1, 1, 0, 1);
105 suncolor_f.g = MYMAX(0.3, MYMIN(1.0, 0.7+m_time_brightness*(0.5)));
106 suncolor_f.b = MYMAX(0.0, m_brightness*0.95);
107 video::SColorf suncolor2_f(1, 1, 1, 1);
109 suncolor_f.g = MYMAX(0.3, MYMIN(1.0, 0.85+m_time_brightness*(0.5)));
110 suncolor_f.b = MYMAX(0.0, m_brightness);
112 float moonsize = 0.04;
113 video::SColorf mooncolor_f(0.50, 0.57, 0.65, 1);
114 video::SColorf mooncolor2_f(0.85, 0.875, 0.9, 1);
116 float nightlength = 0.415;
117 float wn = nightlength / 2;
118 float wicked_time_of_day = 0;
119 if(m_time_of_day > wn && m_time_of_day < 1.0 - wn)
120 wicked_time_of_day = (m_time_of_day - wn)/(1.0-wn*2)*0.5 + 0.25;
121 else if(m_time_of_day < 0.5)
122 wicked_time_of_day = m_time_of_day / wn * 0.25;
124 wicked_time_of_day = 1.0 - ((1.0-m_time_of_day) / wn * 0.25);
125 /*std::cerr<<"time_of_day="<<m_time_of_day<<" -> "
126 <<"wicked_time_of_day="<<wicked_time_of_day<<std::endl;*/
128 video::SColor suncolor = suncolor_f.toSColor();
129 video::SColor suncolor2 = suncolor2_f.toSColor();
130 video::SColor mooncolor = mooncolor_f.toSColor();
131 video::SColor mooncolor2 = mooncolor2_f.toSColor();
135 static const u16 indices[4] = {0,1,2,3};
136 video::S3DVertex vertices[4];
138 driver->setMaterial(m_materials[1]);
140 //video::SColor cloudyfogcolor(255,255,255,255);
141 video::SColor cloudyfogcolor = m_bgcolor;
142 //video::SColor cloudyfogcolor = m_bgcolor.getInterpolated(m_skycolor, 0.5);
144 // Draw far cloudy fog thing
145 for(u32 j=0; j<4; j++)
147 video::SColor c = cloudyfogcolor.getInterpolated(m_skycolor, 0.45);
148 vertices[0] = video::S3DVertex(-1, 0.08,-1, 0,0,1, c, t, t);
149 vertices[1] = video::S3DVertex( 1, 0.08,-1, 0,0,1, c, o, t);
150 vertices[2] = video::S3DVertex( 1, 0.12,-1, 0,0,1, c, o, o);
151 vertices[3] = video::S3DVertex(-1, 0.12,-1, 0,0,1, c, t, o);
152 for(u32 i=0; i<4; i++){
157 // Switch from -Z (south) to +X (east)
158 vertices[i].Pos.rotateXZBy(90);
160 // Switch from -Z (south) to -X (west)
161 vertices[i].Pos.rotateXZBy(-90);
163 // Switch from -Z (south) to -Z (north)
164 vertices[i].Pos.rotateXZBy(-180);
166 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
168 for(u32 j=0; j<4; j++)
170 video::SColor c = cloudyfogcolor;
171 vertices[0] = video::S3DVertex(-1,-1.0,-1, 0,0,1, c, t, t);
172 vertices[1] = video::S3DVertex( 1,-1.0,-1, 0,0,1, c, o, t);
173 vertices[2] = video::S3DVertex( 1, 0.08,-1, 0,0,1, c, o, o);
174 vertices[3] = video::S3DVertex(-1, 0.08,-1, 0,0,1, c, t, o);
175 for(u32 i=0; i<4; i++){
180 // Switch from -Z (south) to +X (east)
181 vertices[i].Pos.rotateXZBy(90);
183 // Switch from -Z (south) to -X (west)
184 vertices[i].Pos.rotateXZBy(-90);
186 // Switch from -Z (south) to -Z (north)
187 vertices[i].Pos.rotateXZBy(-180);
189 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
192 driver->setMaterial(m_materials[2]);
196 float mid = (wicked_time_of_day < 0.5 ? mid1 : (1.0 - mid1));
197 float a_ = 1.0 - fabs(wicked_time_of_day - mid) * 35.0;
198 float a = easeCurve(MYMAX(0, MYMIN(1, a_)));
199 //std::cerr<<"a_="<<a_<<" a="<<a<<std::endl;
200 video::SColor c(255,255,255,255);
201 float y = -(1.0 - a) * 0.2;
202 vertices[0] = video::S3DVertex(-1,-0.05+y,-1, 0,0,1, c, t, t);
203 vertices[1] = video::S3DVertex( 1,-0.05+y,-1, 0,0,1, c, o, t);
204 vertices[2] = video::S3DVertex( 1, 0.2+y,-1, 0,0,1, c, o, o);
205 vertices[3] = video::S3DVertex(-1, 0.2+y,-1, 0,0,1, c, t, o);
206 for(u32 i=0; i<4; i++){
207 if(wicked_time_of_day < 0.5)
208 // Switch from -Z (south) to +X (east)
209 vertices[i].Pos.rotateXZBy(90);
211 // Switch from -Z (south) to -X (west)
212 vertices[i].Pos.rotateXZBy(-90);
214 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
217 driver->setMaterial(m_materials[1]);
220 if(wicked_time_of_day > 0.15 && wicked_time_of_day < 0.85)
222 float d = sunsize * 1.7;
223 video::SColor c = suncolor;
224 c.setAlpha(0.05*255);
225 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t);
226 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t);
227 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o);
228 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o);
229 for(u32 i=0; i<4; i++){
230 // Switch from -Z (south) to +X (east)
231 vertices[i].Pos.rotateXZBy(90);
232 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
234 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
238 c.setAlpha(0.15*255);
239 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t);
240 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t);
241 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o);
242 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o);
243 for(u32 i=0; i<4; i++){
244 // Switch from -Z (south) to +X (east)
245 vertices[i].Pos.rotateXZBy(90);
246 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
248 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
251 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, suncolor, t, t);
252 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, suncolor, o, t);
253 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, suncolor, o, o);
254 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, suncolor, t, o);
255 for(u32 i=0; i<4; i++){
256 // Switch from -Z (south) to +X (east)
257 vertices[i].Pos.rotateXZBy(90);
258 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
260 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
263 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, suncolor2, t, t);
264 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, suncolor2, o, t);
265 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, suncolor2, o, o);
266 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, suncolor2, t, o);
267 for(u32 i=0; i<4; i++){
268 // Switch from -Z (south) to +X (east)
269 vertices[i].Pos.rotateXZBy(90);
270 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
272 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
275 if(wicked_time_of_day < 0.3 || wicked_time_of_day > 0.7)
277 float d = moonsize * 1.9;
278 video::SColor c = mooncolor;
279 c.setAlpha(0.05*255);
280 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t);
281 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t);
282 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o);
283 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o);
284 for(u32 i=0; i<4; i++){
285 // Switch from -Z (south) to -X (west)
286 vertices[i].Pos.rotateXZBy(-90);
287 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
289 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
293 c.setAlpha(0.15*255);
294 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t);
295 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t);
296 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o);
297 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o);
298 for(u32 i=0; i<4; i++){
299 // Switch from -Z (south) to -X (west)
300 vertices[i].Pos.rotateXZBy(-90);
301 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
303 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
306 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, mooncolor, t, t);
307 vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, mooncolor, o, t);
308 vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, mooncolor, o, o);
309 vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, mooncolor, t, o);
310 for(u32 i=0; i<4; i++){
311 // Switch from -Z (south) to -X (west)
312 vertices[i].Pos.rotateXZBy(-90);
313 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
315 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
317 float d2 = moonsize * 0.6;
318 vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, mooncolor2, t, t);
319 vertices[1] = video::S3DVertex( d2,-d,-1, 0,0,1, mooncolor2, o, t);
320 vertices[2] = video::S3DVertex( d2, d2,-1, 0,0,1, mooncolor2, o, o);
321 vertices[3] = video::S3DVertex(-d, d2,-1, 0,0,1, mooncolor2, t, o);
322 for(u32 i=0; i<4; i++){
323 // Switch from -Z (south) to -X (west)
324 vertices[i].Pos.rotateXZBy(-90);
325 vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
327 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
331 float starbrightness = MYMAX(0, MYMIN(1,
332 (0.285 - fabs(wicked_time_of_day < 0.5 ?
333 wicked_time_of_day : (1.0 - wicked_time_of_day))) * 10));
334 float f = starbrightness;
336 video::SColor starcolor(255, f*90,f*90,f*90);
337 if(starcolor.getBlue() < m_skycolor.getBlue())
339 u16 indices[SKY_STAR_COUNT*4];
340 video::S3DVertex vertices[SKY_STAR_COUNT*4];
341 for(u32 i=0; i<SKY_STAR_COUNT; i++){
342 indices[i*4+0] = i*4+0;
343 indices[i*4+1] = i*4+1;
344 indices[i*4+2] = i*4+2;
345 indices[i*4+3] = i*4+3;
347 core::CMatrix4<f32> a;
348 a.buildRotateFromTo(v3f(0,1,0), v3f(d,1+d/2,0));
351 a.buildRotateFromTo(v3f(0,1,0), v3f(d,1,d));
354 a.buildRotateFromTo(v3f(0,1,0), v3f(0,1-d/2,d));
357 p.rotateXYBy(wicked_time_of_day * 360 - 90);
358 p1.rotateXYBy(wicked_time_of_day * 360 - 90);
359 p2.rotateXYBy(wicked_time_of_day * 360 - 90);
360 p3.rotateXYBy(wicked_time_of_day * 360 - 90);
361 vertices[i*4+0].Pos = p;
362 vertices[i*4+0].Color = starcolor;
363 vertices[i*4+1].Pos = p1;
364 vertices[i*4+1].Color = starcolor;
365 vertices[i*4+2].Pos = p2;
366 vertices[i*4+2].Color = starcolor;
367 vertices[i*4+3].Pos = p3;
368 vertices[i*4+3].Color = starcolor;
370 driver->drawVertexPrimitiveList(vertices, SKY_STAR_COUNT*4,
371 indices, SKY_STAR_COUNT, video::EVT_STANDARD,
372 scene::EPT_QUADS, video::EIT_16BIT);
375 for(u32 j=0; j<2; j++)
377 //video::SColor c = m_skycolor;
378 video::SColor c = cloudyfogcolor;
379 vertices[0] = video::S3DVertex(-1,-1.0,-1, 0,0,1, c, t, t);
380 vertices[1] = video::S3DVertex( 1,-1.0,-1, 0,0,1, c, o, t);
381 vertices[2] = video::S3DVertex( 1,-0.02,-1, 0,0,1, c, o, o);
382 vertices[3] = video::S3DVertex(-1,-0.02,-1, 0,0,1, c, t, o);
383 for(u32 i=0; i<4; i++){
384 //if(wicked_time_of_day < 0.5)
386 // Switch from -Z (south) to +X (east)
387 vertices[i].Pos.rotateXZBy(90);
389 // Switch from -Z (south) to -X (west)
390 vertices[i].Pos.rotateXZBy(-90);
392 driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
397 void Sky::update(float time_of_day, float time_brightness,
398 float direct_brightness, bool sunlight_seen)
400 // Stabilize initial brightness and color values by flooding updates
402 /*dstream<<"First update with time_of_day="<<time_of_day
403 <<" time_brightness="<<time_brightness
404 <<" direct_brightness="<<direct_brightness
405 <<" sunlight_seen="<<sunlight_seen<<std::endl;*/
406 m_first_update = false;
407 for(u32 i=0; i<100; i++){
408 update(time_of_day, time_brightness, direct_brightness,
414 m_time_of_day = time_of_day;
415 m_time_brightness = time_brightness;
416 m_sunlight_seen = sunlight_seen;
418 bool is_dawn = (time_brightness >= 0.20 && time_brightness < 0.35);
420 //video::SColorf bgcolor_bright_normal_f(170./255,200./255,230./255, 1.0);
421 video::SColorf bgcolor_bright_normal_f(155./255,193./255,240./255, 1.0);
422 video::SColorf bgcolor_bright_indoor_f(100./255,100./255,100./255, 1.0);
423 //video::SColorf bgcolor_bright_dawn_f(0.666,200./255*0.7,230./255*0.5,1.0);
424 //video::SColorf bgcolor_bright_dawn_f(0.666,0.549,0.220,1.0);
425 //video::SColorf bgcolor_bright_dawn_f(0.666*1.2,0.549*1.0,0.220*1.0, 1.0);
426 //video::SColorf bgcolor_bright_dawn_f(0.666*1.2,0.549*1.0,0.220*1.2,1.0);
427 video::SColorf bgcolor_bright_dawn_f
428 (155./255*1.2,193./255,240./255, 1.0);
430 video::SColorf skycolor_bright_normal_f =
431 video::SColor(255, 140, 186, 250);
432 video::SColorf skycolor_bright_dawn_f =
433 video::SColor(255, 180, 186, 250);
435 video::SColorf cloudcolor_bright_normal_f =
436 video::SColor(255, 240,240,255);
437 //video::SColorf cloudcolor_bright_dawn_f(1.0, 0.591, 0.4);
438 //video::SColorf cloudcolor_bright_dawn_f(1.0, 0.65, 0.44);
439 //video::SColorf cloudcolor_bright_dawn_f(1.0, 0.7, 0.5);
440 video::SColorf cloudcolor_bright_dawn_f(1.0, 0.875, 0.75);
442 float cloud_color_change_fraction = 0.95;
444 if(fabs(time_brightness - m_brightness) < 0.2){
445 m_brightness = m_brightness * 0.95 + time_brightness * 0.05;
447 m_brightness = m_brightness * 0.80 + time_brightness * 0.20;
448 cloud_color_change_fraction = 0.0;
452 if(direct_brightness < m_brightness)
453 m_brightness = m_brightness * 0.95 + direct_brightness * 0.05;
455 m_brightness = m_brightness * 0.98 + direct_brightness * 0.02;
458 m_clouds_visible = true;
459 float color_change_fraction = 0.98;
462 m_bgcolor_bright_f = m_bgcolor_bright_f.getInterpolated(
463 bgcolor_bright_dawn_f, color_change_fraction);
464 m_skycolor_bright_f = m_skycolor_bright_f.getInterpolated(
465 skycolor_bright_dawn_f, color_change_fraction);
466 m_cloudcolor_bright_f = m_cloudcolor_bright_f.getInterpolated(
467 cloudcolor_bright_dawn_f, color_change_fraction);
469 m_bgcolor_bright_f = m_bgcolor_bright_f.getInterpolated(
470 bgcolor_bright_normal_f, color_change_fraction);
471 m_skycolor_bright_f = m_skycolor_bright_f.getInterpolated(
472 skycolor_bright_normal_f, color_change_fraction);
473 m_cloudcolor_bright_f = m_cloudcolor_bright_f.getInterpolated(
474 cloudcolor_bright_normal_f, color_change_fraction);
477 m_bgcolor_bright_f = m_bgcolor_bright_f.getInterpolated(
478 bgcolor_bright_indoor_f, color_change_fraction);
479 m_skycolor_bright_f = m_skycolor_bright_f.getInterpolated(
480 bgcolor_bright_indoor_f, color_change_fraction);
481 m_cloudcolor_bright_f = m_cloudcolor_bright_f.getInterpolated(
482 cloudcolor_bright_normal_f, color_change_fraction);
483 m_clouds_visible = false;
486 // Horizon coloring based on sun and moon direction during sunset and sunrise
487 video::SColor pointcolor = video::SColor(255, 255, 255, m_bgcolor.getAlpha());
488 if (m_directional_colored_fog) {
489 if (m_horizon_blend() != 0)
491 // calculate hemisphere value from yaw
492 f32 pointcolor_blend = wrapDegrees_0_360(m_player->getYaw() + 90);
493 if (pointcolor_blend > 180)
494 pointcolor_blend = 360 - pointcolor_blend;
495 pointcolor_blend /= 180;
496 // bound view angle to determine where transition starts and ends
497 pointcolor_blend = rangelim(1 - pointcolor_blend * 1.375, 0, 1 / 1.375) * 1.375;
498 // combine the colors when looking up or down, otherwise turning looks weird
499 pointcolor_blend += (0.5 - pointcolor_blend) * (1 - MYMIN((90 - std::abs(m_player->getPitch())) / 90 * 1.5, 1));
500 // invert direction to match where the sun and moon are rising
501 if (m_time_of_day > 0.5)
502 pointcolor_blend = 1 - pointcolor_blend;
504 // horizon colors of sun and moon
505 f32 pointcolor_light = rangelim(m_time_brightness * 3, 0.2, 1);
506 video::SColorf pointcolor_sun_f(1, 1, 1, 1);
507 pointcolor_sun_f.r = pointcolor_light * 1;
508 pointcolor_sun_f.b = pointcolor_light * (0.25 + (rangelim(m_time_brightness, 0.25, 0.75) - 0.25) * 2 * 0.75);
509 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);
510 video::SColorf pointcolor_moon_f(0.5 * pointcolor_light, 0.6 * pointcolor_light, 0.8 * pointcolor_light, 1);
511 video::SColor pointcolor_sun = pointcolor_sun_f.toSColor();
512 video::SColor pointcolor_moon = pointcolor_moon_f.toSColor();
513 // calculate the blend color
514 pointcolor = m_mix_scolor(pointcolor_moon, pointcolor_sun, pointcolor_blend);
518 video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor();
519 m_bgcolor = video::SColor(
521 bgcolor_bright.getRed() * m_brightness,
522 bgcolor_bright.getGreen() * m_brightness,
523 bgcolor_bright.getBlue() * m_brightness);
524 if (m_directional_colored_fog) {
525 m_bgcolor = m_mix_scolor(m_bgcolor, pointcolor, m_horizon_blend() * 0.5);
528 video::SColor skycolor_bright = m_skycolor_bright_f.toSColor();
529 m_skycolor = video::SColor(
531 skycolor_bright.getRed() * m_brightness,
532 skycolor_bright.getGreen() * m_brightness,
533 skycolor_bright.getBlue() * m_brightness);
534 if (m_directional_colored_fog) {
535 m_skycolor = m_mix_scolor(m_skycolor, pointcolor, m_horizon_blend() * 0.25);
538 float cloud_direct_brightness = 0;
540 if (!m_directional_colored_fog) {
541 cloud_direct_brightness = time_brightness;
542 if(time_brightness >= 0.2 && time_brightness < 0.7)
543 cloud_direct_brightness *= 1.3;
546 cloud_direct_brightness = MYMIN(m_horizon_blend() * 0.15 + m_time_brightness, 1);
549 cloud_direct_brightness = direct_brightness;
551 m_cloud_brightness = m_cloud_brightness * cloud_color_change_fraction +
552 cloud_direct_brightness * (1.0 - cloud_color_change_fraction);
553 m_cloudcolor_f = video::SColorf(
554 m_cloudcolor_bright_f.r * m_cloud_brightness,
555 m_cloudcolor_bright_f.g * m_cloud_brightness,
556 m_cloudcolor_bright_f.b * m_cloud_brightness,
558 if (m_directional_colored_fog) {
559 m_cloudcolor_f = m_mix_scolorf(m_cloudcolor_f, video::SColorf(pointcolor), m_horizon_blend() * 0.25);