diff options
Diffstat (limited to 'advanced_lighting/1.blinn_phong/shaders/blinn_phong.fs')
-rw-r--r-- | advanced_lighting/1.blinn_phong/shaders/blinn_phong.fs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/advanced_lighting/1.blinn_phong/shaders/blinn_phong.fs b/advanced_lighting/1.blinn_phong/shaders/blinn_phong.fs deleted file mode 100644 index 5c66b3e..0000000 --- a/advanced_lighting/1.blinn_phong/shaders/blinn_phong.fs +++ /dev/null @@ -1,44 +0,0 @@ -#version 330 core - -in VS_OUT { - vec3 frag_pos; - vec3 normal; - vec2 tex_coords; -} fs_in; - -out vec4 frag_color; - -uniform sampler2D texture0; -uniform vec3 light_pos; -uniform vec3 view_pos; -uniform bool blinn; - -void -main(void) -{ - vec3 light_dir = normalize(light_pos-fs_in.frag_pos); - vec3 view_dir = normalize(view_pos-fs_in.frag_pos); - vec3 normal = normalize(fs_in.normal); - - vec3 texture_color = texture(texture0, fs_in.tex_coords).rgb; - - float diff = max(dot(normal, light_dir), 0.0); - - float spec = 0.0; - if (blinn) - { - vec3 halfway_dir = normalize(light_dir+view_dir); - spec = pow(max(dot(normal, halfway_dir), 0.0), 16.0); - } - else - { - vec3 reflect_dir = reflect(-light_dir, normal); - spec = pow(max(dot(view_dir, reflect_dir), 0.0), 8.0); - } - - vec3 ambient = 0.05*texture_color; - vec3 diffuse = diff*texture_color; - vec3 specular = vec3(0.3)*spec; - - frag_color = vec4(ambient+diffuse+specular, 1.0); -} |