determine ambient color based on texture

This commit is contained in:
Josh Holtrop 2015-10-13 23:08:15 -04:00
parent 45453d8ebc
commit ccec3665c3
2 changed files with 2 additions and 2 deletions

2
app.cc
View File

@ -126,7 +126,7 @@ static void draw_cube()
program->use(); program->use();
cube_array->bind(); cube_array->bind();
glUniform4f(uniforms.ambient, 1.0, 1.0, 1.0, 1.0); glUniform4f(uniforms.ambient, 0.2, 0.2, 0.2, 0.2);
glUniform4f(uniforms.specular, 1.0, 1.0, 1.0, 1.0); glUniform4f(uniforms.specular, 1.0, 1.0, 1.0, 1.0);
glUniform1f(uniforms.shininess, 150.0); glUniform1f(uniforms.shininess, 150.0);
glUniform1i(uniforms.tex, 0); glUniform1i(uniforms.tex, 0);

View File

@ -15,7 +15,7 @@ void main(void)
lightDir = normalize(vec3(-0.1, 0, -0.9)); lightDir = normalize(vec3(-0.1, 0, -0.9));
vec4 texture_color = texture2D(tex, tex_coord_i); vec4 texture_color = texture2D(tex, tex_coord_i);
color = vec4(0.2, 0.2, 0.2, texture_color.a) * ambient; /* ambient light */ color = texture_color * ambient; /* ambient light */
n = normalize(normal_i); n = normalize(normal_i);
NdotL = dot(n, -lightDir); NdotL = dot(n, -lightDir);