diff options
Diffstat (limited to 'advanced_lighting/blinn_phong/shaders')
-rw-r--r-- | advanced_lighting/blinn_phong/shaders/.blinn_phong.fs.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | advanced_lighting/blinn_phong/shaders/blinn_phong.fs | 62 | ||||
-rw-r--r-- | advanced_lighting/blinn_phong/shaders/blinn_phong.vs | 21 |
3 files changed, 0 insertions, 83 deletions
diff --git a/advanced_lighting/blinn_phong/shaders/.blinn_phong.fs.swp b/advanced_lighting/blinn_phong/shaders/.blinn_phong.fs.swp Binary files differdeleted file mode 100644 index cfc93b0..0000000 --- a/advanced_lighting/blinn_phong/shaders/.blinn_phong.fs.swp +++ /dev/null diff --git a/advanced_lighting/blinn_phong/shaders/blinn_phong.fs b/advanced_lighting/blinn_phong/shaders/blinn_phong.fs deleted file mode 100644 index 23e2968..0000000 --- a/advanced_lighting/blinn_phong/shaders/blinn_phong.fs +++ /dev/null @@ -1,62 +0,0 @@ -#version 330 core - -in vec2 tex_coords; -in vec3 normal; -in vec3 frag_pos; - -out vec4 frag_color; - -uniform sampler2D texture_diffuse; -uniform sampler2D texture_specular; - -uniform vec3 light_pos; -uniform vec3 view_pos; - -uniform float ambient_strength; -uniform float specular_strength; -uniform float shininess; - -vec4 -spotlight(vec3 light_dir, vec3 view_dir) -{ - vec3 tex_color_diff = texture(texture_diffuse, tex_coords); - float ambient_strength = 0.1f; - vec4 ambient = tex_color_diff*ambient_strength; - vec4 diffuse = tex_color_diff*dot(-light_dir, ) - return(color); -} - -vec4 -blinn_phong() -{ - // Sample the diffuse color from the texture - vec3 diffuse_color = texture(texture_diffuse, tex_coords).rgb; - - // Sample the specular color from the texture (if available) - vec3 specular_color = texture(texture_specular, tex_coords).rgb; - - // Ambient lighting - vec3 ambient = ambient_strength*diffuse_color; - - // Diffuse lighting - vec3 norm = normalize(normal); - vec3 light_dir = normalize(light_pos-frag_pos); - float diff = max(dot(norm, light_dir), 0.0); - vec3 diffuse = diff * diffuse_color; - - // Specular lighting - vec3 view_dir = normalize(view_pos-frag_pos); - vec3 halfway_dir = normalize(light_dir+view_dir); // Halfway vector - float spec = pow(max(dot(norm, halfway_dir), 0.0), shininess); - vec3 specular = specular_strength*spec*specular_color; - - // Combine all components - vec3 result = (ambient+diffuse+specular); - return((result, 1.0)); -} - -void -main(void) -{ - frag_color = blinn_phong(); -} diff --git a/advanced_lighting/blinn_phong/shaders/blinn_phong.vs b/advanced_lighting/blinn_phong/shaders/blinn_phong.vs deleted file mode 100644 index d4e5dbc..0000000 --- a/advanced_lighting/blinn_phong/shaders/blinn_phong.vs +++ /dev/null @@ -1,21 +0,0 @@ -#version 330 core -layout(location = 0) in vec3 apos; -layout(location = 1) in vec3 anormal; -layout(location = 2) in vec2 atex_coords; - -out vec3 frag_pos; -out vec3 normal; -out vec2 tex_coords; - -uniform mat4 projection; -uniform mat4 view; -uniform mat4 model; - -void -main(void) -{ - frag_pos = vec3(model*vec4(apos, 1.0f); - normal = mat3(transpose(inverse(view*model)))*anormal; - tex_coords = atex_coords; - gl_Position = projection*view*model*vec4(apos, 1.0f); -} |