Skip to content

Commit bf91d62

Browse files
committedAug 16, 2014
Let lighting be done only CPU side. Remove finalColorBlend implementation from shaders.
1 parent 0a57b5b commit bf91d62

File tree

3 files changed

+9
-64
lines changed

3 files changed

+9
-64
lines changed
 

‎client/shaders/nodes_shader/opengl_vertex.glsl

+1-27
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,5 @@ void main(void)
9797
eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;
9898
tsEyeVec = eyeVec * tbnMatrix;
9999

100-
vec4 color;
101-
float day = gl_Color.r;
102-
float night = gl_Color.g;
103-
float light_source = gl_Color.b;
104-
105-
float rg = mix(night, day, dayNightRatio);
106-
rg += light_source * 2.5; // Make light sources brighter
107-
float b = rg;
108-
109-
// Moonlight is blue
110-
b += (day - night) / 13.0;
111-
rg -= (day - night) / 23.0;
112-
113-
// Emphase blue a bit in darker places
114-
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
115-
b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025);
116-
117-
// Artificial light is yellow-ish
118-
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
119-
rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065);
120-
121-
color.r = rg;
122-
color.g = rg;
123-
color.b = b;
124-
125-
color.a = gl_Color.a;
126-
gl_FrontColor = gl_BackColor = clamp(color,0.0,1.0);
100+
gl_FrontColor = gl_BackColor = gl_Color;
127101
}

‎client/shaders/water_surface_shader/opengl_vertex.glsl

+1-27
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,5 @@ void main(void)
9797
eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;
9898
tsEyeVec = eyeVec * tbnMatrix;
9999

100-
vec4 color;
101-
float day = gl_Color.r;
102-
float night = gl_Color.g;
103-
float light_source = gl_Color.b;
104-
105-
float rg = mix(night, day, dayNightRatio);
106-
rg += light_source * 2.5; // Make light sources brighter
107-
float b = rg;
108-
109-
// Moonlight is blue
110-
b += (day - night) / 13.0;
111-
rg -= (day - night) / 13.0;
112-
113-
// Emphase blue a bit in darker places
114-
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
115-
b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025);
116-
117-
// Artificial light is yellow-ish
118-
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
119-
rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065);
120-
121-
color.r = rg;
122-
color.g = rg;
123-
color.b = b;
124-
125-
color.a = gl_Color.a;
126-
gl_FrontColor = gl_BackColor = clamp(color,0.0,1.0);
100+
gl_FrontColor = gl_BackColor = gl_Color;
127101
}

‎src/mapblock_mesh.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -1158,16 +1158,13 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
11581158
applyFacesShading (vc, 0.836660);
11591159
}
11601160
}
1161-
if(!enable_shaders)
1162-
{
1163-
// - Classic lighting (shaders handle this by themselves)
1164-
// Set initial real color and store for later updates
1165-
u8 day = vc.getRed();
1166-
u8 night = vc.getGreen();
1167-
finalColorBlend(vc, day, night, 1000);
1168-
if(day != night)
1169-
m_daynight_diffs[i][j] = std::make_pair(day, night);
1170-
}
1161+
// - Classic lighting
1162+
// Set initial real color and store for later updates
1163+
u8 day = vc.getRed();
1164+
u8 night = vc.getGreen();
1165+
finalColorBlend(vc, day, night, 1000);
1166+
if(day != night)
1167+
m_daynight_diffs[i][j] = std::make_pair(day, night);
11711168
}
11721169

11731170
// Create material

1 commit comments

Comments
 (1)

HybridDog commented on Aug 16, 2014

@HybridDog
Contributor

Does this disable blue moonlight?

Please sign in to comment.