- "layout(location = 1) in vec3 vtx_color;\n"
- "layout(location = 2) in vec3 vtx_normal;\n"
+ "layout(location = 1) in vec3 vtx_tex_uv;\n"
+ "layout(location = 2) in vec3 vtx_color;\n"
+ "layout(location = 3) in vec3 vtx_normal;\n"
"gl_Position = MVP * vec4(vtx_position, 1);\n"
"vtx_viewspace = (MV * vec4(vtx_position, 1)).xyz;\n"
"normal = (M * vec4(vtx_normal, 0)).xyz;\n"
"gl_Position = MVP * vec4(vtx_position, 1);\n"
"vtx_viewspace = (MV * vec4(vtx_position, 1)).xyz;\n"
"normal = (M * vec4(vtx_normal, 0)).xyz;\n"
"uniform vec3 light_direction;\n"
"uniform vec3 light_color;\n"
"uniform float fog_density;\n"
"out vec3 color;\n"
"void main() {\n"
"uniform vec3 light_direction;\n"
"uniform vec3 light_color;\n"
"uniform float fog_density;\n"
"out vec3 color;\n"
"void main() {\n"
- "vec3 ambient = vec3(0.1, 0.1, 0.1) * frag_color;\n"
+ "vec3 tex_color = texture(tex_sampler, frag_tex_uv).rgb;\n"
+ "vec3 base_color = tex_color * frag_color;\n"
+ "vec3 ambient = vec3(0.1, 0.1, 0.1) * base_color;\n"
// this should be the same as the clear color, otherwise looks really weird
"vec3 fog_color = vec3(0, 0, 0);\n"
"float e = 2.718281828;\n"
"vec3 n = normalize(normal);\n"
"vec3 l = normalize(light_direction);\n"
"float cos_theta = clamp(dot(n, l), 0, 1);\n"
// this should be the same as the clear color, otherwise looks really weird
"vec3 fog_color = vec3(0, 0, 0);\n"
"float e = 2.718281828;\n"
"vec3 n = normalize(normal);\n"
"vec3 l = normalize(light_direction);\n"
"float cos_theta = clamp(dot(n, l), 0, 1);\n"
"float value = pow(e, -pow(fog_density * length(vtx_viewspace), 5));"
"color = mix(fog_color, reflect_color, value);\n"
"}\n"
"float value = pow(e, -pow(fog_density * length(vtx_viewspace), 5));"
"color = mix(fog_color, reflect_color, value);\n"
"}\n"
m_handle = program.UniformLocation("M");
mv_handle = program.UniformLocation("MV");
mvp_handle = program.UniformLocation("MVP");
m_handle = program.UniformLocation("M");
mv_handle = program.UniformLocation("MV");
mvp_handle = program.UniformLocation("MVP");
light_direction_handle = program.UniformLocation("light_direction");
light_color_handle = program.UniformLocation("light_color");
fog_density_handle = program.UniformLocation("fog_density");
light_direction_handle = program.UniformLocation("light_direction");
light_color_handle = program.UniformLocation("light_color");
fog_density_handle = program.UniformLocation("fog_density");
void DirectionalLighting::SetFogDensity(float f) noexcept {
program.Uniform(fog_density_handle, f);
}
void DirectionalLighting::SetFogDensity(float f) noexcept {
program.Uniform(fog_density_handle, f);
}
- "layout(location = 1) in vec3 vtx_color;\n"
- "layout(location = 2) in float vtx_light;\n"
+ "layout(location = 1) in vec3 vtx_tex_uv;\n"
+ "layout(location = 2) in vec3 vtx_color;\n"
+ "layout(location = 3) in float vtx_light;\n"
"out vec3 frag_color;\n"
"out vec3 vtx_viewspace;\n"
"out float frag_light;\n"
"void main() {\n"
"gl_Position = MVP * vec4(vtx_position, 1);\n"
"out vec3 frag_color;\n"
"out vec3 vtx_viewspace;\n"
"out float frag_light;\n"
"void main() {\n"
"gl_Position = MVP * vec4(vtx_position, 1);\n"
"frag_color = vtx_color;\n"
"vtx_viewspace = (MV * vec4(vtx_position, 1)).xyz;\n"
"frag_light = vtx_light;\n"
"frag_color = vtx_color;\n"
"vtx_viewspace = (MV * vec4(vtx_position, 1)).xyz;\n"
"frag_light = vtx_light;\n"
- "vec3 ambient = vec3(0.1, 0.1, 0.1) * frag_color;\n"
+ "vec3 tex_color = texture(tex_sampler, frag_tex_uv).rgb;\n"
+ "vec3 base_color = tex_color * frag_color;\n"
"float light_power = clamp(pow(0.8, 15 - frag_light), 0, 1);\n"
"vec3 fog_color = vec3(0, 0, 0);\n"
"float e = 2.718281828;\n"
"float light_power = clamp(pow(0.8, 15 - frag_light), 0, 1);\n"
"vec3 fog_color = vec3(0, 0, 0);\n"
"float e = 2.718281828;\n"
"float value = pow(e, -pow(fog_density * length(vtx_viewspace), 5));"
"color = mix(fog_color, reflect_color, value);\n"
"}\n"
"float value = pow(e, -pow(fog_density * length(vtx_viewspace), 5));"
"color = mix(fog_color, reflect_color, value);\n"
"}\n"
-void BlockLighting::SetM(const glm::mat4 &m) noexcept {
- program.Uniform(mv_handle, view * m);
- program.Uniform(mvp_handle, vp * m);
+void BlockLighting::SetTexture(ArrayTexture &tex) noexcept {
+ glActiveTexture(GL_TEXTURE0);
+ tex.Bind();
+ program.Uniform(sampler_handle, GLint(0));
}
void BlockLighting::SetFogDensity(float f) noexcept {
program.Uniform(fog_density_handle, f);
}
}
void BlockLighting::SetFogDensity(float f) noexcept {
program.Uniform(fog_density_handle, f);
}