Let lighting be done only CPU side. Remove finalColorBlend implementation from shaders.
authorRealBadAngel <maciej.kasatkin@o2.pl>
Sat, 16 Aug 2014 12:02:50 +0000 (14:02 +0200)
committerRealBadAngel <maciej.kasatkin@o2.pl>
Sat, 16 Aug 2014 12:48:52 +0000 (14:48 +0200)
client/shaders/nodes_shader/opengl_vertex.glsl
client/shaders/water_surface_shader/opengl_vertex.glsl
src/mapblock_mesh.cpp

index 28d3e8ed828be998616e3451d1c61da6d043350b..36d29c1e58be02803c5dc3884b8b7f712595b6a0 100644 (file)
@@ -97,31 +97,5 @@ void main(void)
        eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
        tsEyeVec = eyeVec * tbnMatrix;\r
 \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
+       gl_FrontColor = gl_BackColor = gl_Color;\r
 }\r
index 03b682d1be40b20682befe42007a677e6cf249be..36d29c1e58be02803c5dc3884b8b7f712595b6a0 100644 (file)
@@ -97,31 +97,5 @@ void main(void)
        eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
        tsEyeVec = eyeVec * tbnMatrix;\r
 \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) / 13.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
+       gl_FrontColor = gl_BackColor = gl_Color;\r
 }\r
index ef2c868a066a911d11b3d68329a9c9a30dd31d8c..ad0fcb436d914a3fb9d6737c15d2cbd4eddab3b5 100644 (file)
@@ -1158,16 +1158,13 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
                                        applyFacesShading (vc, 0.836660);
                                }
                        }
-                       if(!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);
-                       }
+                       // - Classic lighting
+                       // 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