vec4 pos = gl_Vertex;\r
vec4 pos2 = mWorld * gl_Vertex;\r
if (gl_TexCoord[0].y < 0.05) {\r
- pos.x += (smoothTriangleWave(animationTimer * 20.0 + pos2.x * 0.1 + pos2.z * 0.1) * 2.0 - 1.0) * 0.8;\r
- pos.y -= (smoothTriangleWave(animationTimer * 10.0 + pos2.x * -0.5 + pos2.z * -0.5) * 2.0 - 1.0) * 0.4;\r
+ pos.x += (smoothTriangleWave(animationTimer * 20.0 + pos2.x * 0.1 + pos2.z * 0.1) * 2.0 - 1.0) * 0.8;\r
+ pos.y -= (smoothTriangleWave(animationTimer * 10.0 + pos2.x * -0.5 + pos2.z * -0.5) * 2.0 - 1.0) * 0.4;\r
}\r
gl_Position = mWorldViewProj * pos;\r
#else\r
eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
tsEyeVec = eyeVec * tbnMatrix;\r
\r
- gl_FrontColor = gl_BackColor = gl_Color;\r
+ vec4 color;\r
+ float day = gl_Color.r;\r
+ float night = gl_Color.g;\r
+ float light_source = gl_Color.b;\r
+\r
+ float rg = mix(night, day, dayNightRatio);\r
+ rg += light_source * 2.5; // Make light sources brighter\r
+ float b = rg;\r
+\r
+ // Moonlight is blue\r
+ b += (day - night) / 13.0;\r
+ rg -= (day - night) / 23.0;\r
+\r
+ // Emphase blue a bit in darker places\r
+ // See C++ implementation in mapblock_mesh.cpp finalColorBlend()\r
+ b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025);\r
+\r
+ // Artificial light is yellow-ish\r
+ // See C++ implementation in mapblock_mesh.cpp finalColorBlend()\r
+ rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065);\r
+\r
+ color.r = rg;\r
+ color.g = rg;\r
+ color.b = b;\r
+\r
+ color.a = gl_Color.a;\r
+ gl_FrontColor = gl_BackColor = clamp(color,0.0,1.0);\r
}\r
vec4 pos = gl_Vertex;\r
vec4 pos2 = mWorld * gl_Vertex;\r
if (gl_TexCoord[0].y < 0.05) {\r
- pos.x += (smoothTriangleWave(animationTimer * 20.0 + pos2.x * 0.1 + pos2.z * 0.1) * 2.0 - 1.0) * 0.8;\r
- pos.y -= (smoothTriangleWave(animationTimer * 10.0 + pos2.x * -0.5 + pos2.z * -0.5) * 2.0 - 1.0) * 0.4;\r
+ pos.x += (smoothTriangleWave(animationTimer * 20.0 + pos2.x * 0.1 + pos2.z * 0.1) * 2.0 - 1.0) * 0.8;\r
+ pos.y -= (smoothTriangleWave(animationTimer * 10.0 + pos2.x * -0.5 + pos2.z * -0.5) * 2.0 - 1.0) * 0.4; \r
}\r
gl_Position = mWorldViewProj * pos;\r
#else\r
eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
tsEyeVec = eyeVec * tbnMatrix;\r
\r
- gl_FrontColor = gl_BackColor = gl_Color;\r
+ vec4 color;\r
+ float day = gl_Color.r;\r
+ float night = gl_Color.g;\r
+ float light_source = gl_Color.b;\r
+\r
+ float rg = mix(night, day, dayNightRatio);\r
+ rg += light_source * 2.5; // Make light sources brighter\r
+ float b = rg;\r
+\r
+ // Moonlight is blue\r
+ b += (day - night) / 13.0;\r
+ rg -= (day - night) / 23.0;\r
+\r
+ // Emphase blue a bit in darker places\r
+ // See C++ implementation in mapblock_mesh.cpp finalColorBlend()\r
+ b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025);\r
+\r
+ // Artificial light is yellow-ish\r
+ // See C++ implementation in mapblock_mesh.cpp finalColorBlend()\r
+ rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065);\r
+\r
+ color.r = rg;\r
+ color.g = rg;\r
+ color.b = b;\r
+\r
+ color.a = gl_Color.a;\r
+ gl_FrontColor = gl_BackColor = clamp(color,0.0,1.0);\r
}\r
applyFacesShading (vc, 0.836660);
}
}
- // - Classic lighting
- // Set initial real color and store for later updates
- u8 day = vc.getRed();
- u8 night = vc.getGreen();
- finalColorBlend(vc, day, night, 1000);
- m_daynight_diffs[i][j] = std::make_pair(day, night);
+ if(!m_enable_shaders)
+ {
+ // - Classic lighting (shaders handle this by themselves)
+ // Set initial real color and store for later updates
+ u8 day = vc.getRed();
+ u8 night = vc.getGreen();
+ finalColorBlend(vc, day, night, 1000);
+ if(day != night)
+ m_daynight_diffs[i][j] = std::make_pair(day, night);
+ }
}
// Create material
}
// Day-night transition
- if(daynight_ratio != m_last_daynight_ratio)
+ if(!m_enable_shaders && (daynight_ratio != m_last_daynight_ratio))
{
for(std::map<u32, std::map<u32, std::pair<u8, u8> > >::iterator
i = m_daynight_diffs.begin();