diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index 79c0909a0..8fccf81e6 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -274,7 +274,7 @@ bool lightingEngineViewscreen::lightUpCell(std::vector & target, ligh } if(ls.radius>0 && dsq>0) { - if(power12h 0->24h + daycol= fmod(dayHour,24.0f)/24.0f; //1->12h 0->24h - lightCell sky_col(daycol, daycol, daycol); - lightSource sky(sky_col, 15); + lightCell sky_col=getSkyColor(daycol); + lightSource sky(sky_col, 15);//auto calculate best size lightSource candle(lightCell(0.96f,0.84f,0.03f),5); lightSource torch(lightCell(0.9f,0.75f,0.3f),8); @@ -970,7 +991,18 @@ int lightingEngineViewscreen::parseSpecial(lua_State* L) LOAD_SPECIAL(CITIZEN,matCitizen); GETLUANUMBER(engine->levelDim,levelDim); GETLUANUMBER(engine->dayHour,dayHour); - + GETLUANUMBER(engine->daySpeed,daySpeed); + lua_getfield(L,-1,"dayColors"); + if(lua_istable(L,-1)) + { + engine->dayColors.clear(); + lua_pushnil(L); + while (lua_next(L, -2) != 0) { + engine->dayColors.push_back(lua_parseLightCell(L)); + lua_pop(L,1); + } + lua_pop(L,1); + } return 0; } #undef LOAD_SPECIAL @@ -1037,6 +1069,10 @@ void lightingEngineViewscreen::defaultSettings() matCitizen=matLightDef(lightCell(0.8f,0.8f,0.9f),6); levelDim=0.2f; dayHour=-1; + daySpeed=1; + dayColors.push_back(lightCell(0,0,0)); + dayColors.push_back(lightCell(1,1,1)); + dayColors.push_back(lightCell(0,0,0)); } void lightingEngineViewscreen::loadSettings() { @@ -1075,6 +1111,7 @@ void lightingEngineViewscreen::loadSettings() lua_pushlightuserdata(s, this); lua_pushvalue(s,env); Lua::SafeCall(out,s,2,0); + out.print("%d day light colors loaded\n",dayColors.size()); lua_pushcfunction(s, parseBuildings); lua_pushlightuserdata(s, this); diff --git a/plugins/rendermax/renderer_light.hpp b/plugins/rendermax/renderer_light.hpp index 465d46ce0..e5a9db787 100644 --- a/plugins/rendermax/renderer_light.hpp +++ b/plugins/rendermax/renderer_light.hpp @@ -188,8 +188,11 @@ private: public: void lightWorkerThread(void * arg); private: + lightCell getSkyColor(float v); //settings + float daySpeed; float dayHour; //<0 to cycle + std::vector dayColors; // a gradient of colors, first to 0, last to 24 ///set up sane settings if setting file does not exist. void defaultSettings(); diff --git a/plugins/rendermax/renderer_opengl.hpp b/plugins/rendermax/renderer_opengl.hpp index 57e81295b..8ba35f5ea 100644 --- a/plugins/rendermax/renderer_opengl.hpp +++ b/plugins/rendermax/renderer_opengl.hpp @@ -223,9 +223,9 @@ struct lightCell { return lightCell(r+other.r,g+other.g,b+other.b); } - bool operator<(const lightCell& other) const + bool operator<=(const lightCell& other) const { - return r1200 cur_year_ticks per day. 2->600 ticks --TODO dragonfire --materials