Blinn-Phong

This commit is contained in:
2021-03-14 19:37:57 +01:00
parent 4b87a8752b
commit a0bfdab902
3 changed files with 5 additions and 6 deletions

View File

@@ -25,8 +25,7 @@ void main() {
normal_cam_u = normal_cam_u * 2.0 - 1.0;
normal_cam_u = normalize(tbn * normal_cam_u);
// vec3 light_direction_cam_u = normalize(ubo.light_position - position_wld);
vec3 light_direction_cam_u = normalize(vec3(1.0, 1.0, 1.0));
vec3 light_direction_cam_u = normalize(ubo.light_position - position_wld);
float ambient_strength = 0.1;
vec3 light_color = vec3(1.0, 1.0, 1.0);
@@ -38,8 +37,8 @@ void main() {
float specular_value = 1.0;
vec3 view_direction = normalize(vec3(inverse(ubo.view) * vec4(0.0, 0.0, 0.0, 1.0)) - position_wld);
vec3 reflect_direction = reflect(-light_direction_cam_u, normal_cam_u);
float specular_strength = pow(max(dot(reflect_direction, view_direction), 0.0), 64);
vec3 halfway_direction = normalize(light_direction_cam_u + view_direction);
float specular_strength = pow(max(dot(normal_cam_u, halfway_direction), 0.0), 2);
vec3 specular_color = specular_value * specular_strength * light_color;
out_color = vec4(ambient_color + diffuse_color + specular_color, 1.0) * texture(diffuse_tex, tex_coords);

Binary file not shown.