float alpha = gl_Color.a;
vec4 col = vec4(color.rgb, alpha);
col *= gl_Color;
- col = col * col; // SRGB -> Linear
- col *= 1.8;
- col.r = 1.0 - exp(1.0 - col.r) / e;
- col.g = 1.0 - exp(1.0 - col.g) / e;
- col.b = 1.0 - exp(1.0 - col.b) / e;
- col = sqrt(col); // Linear -> SRGB
if(fogDistance != 0.0){
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
alpha = mix(alpha, 0.0, d);
#else
vec4 col = vec4(color.rgb, base.a);
col *= gl_Color;
- col = col * col; // SRGB -> Linear
- col *= 1.8;
- col.r = 1.0 - exp(1.0 - col.r) / e;
- col.g = 1.0 - exp(1.0 - col.g) / e;
- col.b = 1.0 - exp(1.0 - col.b) / e;
- col = sqrt(col); // Linear -> SRGB
if(fogDistance != 0.0){
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
col = mix(col, skyBgColor, d);
\r
vec3 normal, tangent, binormal;\r
normal = normalize(gl_NormalMatrix * gl_Normal);\r
+ float tileContrast = 1.0;\r
if (gl_Normal.x > 0.5) {\r
// 1.0, 0.0, 0.0\r
+ tileContrast = 0.8;\r
tangent = normalize(gl_NormalMatrix * vec3( 0.0, 0.0, -1.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
} else if (gl_Normal.x < -0.5) {\r
// -1.0, 0.0, 0.0\r
+ tileContrast = 0.8;\r
tangent = normalize(gl_NormalMatrix * vec3( 0.0, 0.0, 1.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
} else if (gl_Normal.y > 0.5) {\r
// 0.0, 1.0, 0.0\r
+ tileContrast = 1.2;\r
tangent = normalize(gl_NormalMatrix * vec3( 1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, 0.0, 1.0));\r
} else if (gl_Normal.y < -0.5) {\r
// 0.0, -1.0, 0.0\r
+ tileContrast = 0.3;\r
tangent = normalize(gl_NormalMatrix * vec3( 1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, 0.0, 1.0));\r
} else if (gl_Normal.z > 0.5) {\r
// 0.0, 0.0, 1.0\r
+ tileContrast = 0.5;\r
tangent = normalize(gl_NormalMatrix * vec3( 1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
} else if (gl_Normal.z < -0.5) {\r
// 0.0, 0.0, -1.0\r
+ tileContrast = 0.5;\r
tangent = normalize(gl_NormalMatrix * vec3(-1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
}\r
\r
// Moonlight is blue\r
b += (day - night) / 13.0;\r
- rg -= (day - night) / 23.0;\r
+ rg -= (day - night) / 13.0;\r
\r
// Emphase blue a bit in darker places\r
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()\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 = clamp(rg,0.0,1.0);\r
- color.g = clamp(rg,0.0,1.0);\r
- color.b = clamp(b,0.0,1.0);\r
+ color.r = rg;\r
+ color.g = rg;\r
+ color.b = b;\r
\r
#if !(MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE)\r
// Make sides and bottom darker than the top\r
color = color * color; // SRGB -> Linear\r
- if(gl_Normal.y <= 0.5)\r
- color *= 0.6;\r
+ color *= tileContrast;\r
color = sqrt(color); // Linear -> SRGB\r
#endif\r
\r
color.a = gl_Color.a;\r
- gl_FrontColor = gl_BackColor = color;\r
+ gl_FrontColor = gl_BackColor = clamp(color,0.0,1.0);\r
}\r
float alpha = gl_Color.a;
vec4 col = vec4(color.rgb, alpha);
col *= gl_Color;
- col = col * col; // SRGB -> Linear
- col *= 1.8;
- col.r = 1.0 - exp(1.0 - col.r) / e;
- col.g = 1.0 - exp(1.0 - col.g) / e;
- col.b = 1.0 - exp(1.0 - col.b) / e;
- col = sqrt(col); // Linear -> SRGB
if(fogDistance != 0.0){
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
alpha = mix(alpha, 0.0, d);
#else
vec4 col = vec4(color.rgb, base.a);
col *= gl_Color;
- col = col * col; // SRGB -> Linear
- col *= 1.8;
- col.r = 1.0 - exp(1.0 - col.r) / e;
- col.g = 1.0 - exp(1.0 - col.g) / e;
- col.b = 1.0 - exp(1.0 - col.b) / e;
- col = sqrt(col); // Linear -> SRGB
if(fogDistance != 0.0){
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
col = mix(col, skyBgColor, d);
\r
vec3 normal, tangent, binormal;\r
normal = normalize(gl_NormalMatrix * gl_Normal);\r
+ float tileContrast = 1.0;\r
if (gl_Normal.x > 0.5) {\r
// 1.0, 0.0, 0.0\r
+ tileContrast = 0.8;\r
tangent = normalize(gl_NormalMatrix * vec3( 0.0, 0.0, -1.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
} else if (gl_Normal.x < -0.5) {\r
// -1.0, 0.0, 0.0\r
+ tileContrast = 0.8;\r
tangent = normalize(gl_NormalMatrix * vec3( 0.0, 0.0, 1.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
} else if (gl_Normal.y > 0.5) {\r
// 0.0, 1.0, 0.0\r
+ tileContrast = 1.2;\r
tangent = normalize(gl_NormalMatrix * vec3( 1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, 0.0, 1.0));\r
} else if (gl_Normal.y < -0.5) {\r
// 0.0, -1.0, 0.0\r
+ tileContrast = 0.3;\r
tangent = normalize(gl_NormalMatrix * vec3( 1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, 0.0, 1.0));\r
} else if (gl_Normal.z > 0.5) {\r
// 0.0, 0.0, 1.0\r
+ tileContrast = 0.5;\r
tangent = normalize(gl_NormalMatrix * vec3( 1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
} else if (gl_Normal.z < -0.5) {\r
// 0.0, 0.0, -1.0\r
+ tileContrast = 0.5;\r
tangent = normalize(gl_NormalMatrix * vec3(-1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
}\r
\r
// Moonlight is blue\r
b += (day - night) / 13.0;\r
- rg -= (day - night) / 23.0;\r
+ rg -= (day - night) / 13.0;\r
\r
// Emphase blue a bit in darker places\r
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()\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 = clamp(rg,0.0,1.0);\r
- color.g = clamp(rg,0.0,1.0);\r
- color.b = clamp(b,0.0,1.0);\r
+ color.r = rg;\r
+ color.g = rg;\r
+ color.b = b;\r
\r
#if !(MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE)\r
// Make sides and bottom darker than the top\r
color = color * color; // SRGB -> Linear\r
- if(gl_Normal.y <= 0.5)\r
- color *= 0.6;\r
+ color *= tileContrast;\r
color = sqrt(color); // Linear -> SRGB\r
#endif\r
\r
color.a = gl_Color.a;\r
- gl_FrontColor = gl_BackColor = color;\r
+ gl_FrontColor = gl_BackColor = clamp(color,0.0,1.0);\r
}\r
u8 night = j->second.second;
finalColorBlend(vertices[vertexIndex].Color,
day, night, daynight_ratio);
- // Brighten topside (no shaders)
- if(vertices[vertexIndex].Normal.Y > 0.5)
- {
- video::SColor &vc = vertices[vertexIndex].Color;
- vc.setRed (srgb_linear_multiply(vc.getRed(), 1.3, 255.0));
- vc.setGreen(srgb_linear_multiply(vc.getGreen(), 1.3, 255.0));
- vc.setBlue (srgb_linear_multiply(vc.getBlue(), 1.3, 255.0));
+ // Make sides and bottom darker than the top
+ video::SColor &vc = vertices[vertexIndex].Color;
+ if(vertices[vertexIndex].Normal.Y > 0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 1.2, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 1.2, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 1.2, 255.0));
+ } else if (vertices[vertexIndex].Normal.Y < -0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.3, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.3, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.3, 255.0));
+ } else if (vertices[vertexIndex].Normal.X > 0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.8, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.8, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.8, 255.0));
+ } else if (vertices[vertexIndex].Normal.X < -0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.8, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.8, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.8, 255.0));
+ } else if (vertices[vertexIndex].Normal.Z > 0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.5, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.5, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.5, 255.0));
+ } else if (vertices[vertexIndex].Normal.Z < -0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.5, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.5, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.5, 255.0));
}
}
}