diff --git a/shaders/triangle.frag b/shaders/triangle.frag index 125097a..eba1bc5 100644 --- a/shaders/triangle.frag +++ b/shaders/triangle.frag @@ -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); diff --git a/shaders/triangle.frag.spv b/shaders/triangle.frag.spv index 17b63a4..e6711a2 100644 Binary files a/shaders/triangle.frag.spv and b/shaders/triangle.frag.spv differ diff --git a/src/game/mod.rs b/src/game/mod.rs index 78ef8f5..7af77ec 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -1,7 +1,7 @@ use std::time::SystemTime; -use cgmath::{Deg, InnerSpace, Quaternion, Rotation3}; +use cgmath::{Deg, InnerSpace, Quaternion, Rotation3, vec3}; use winit::event::Event; use level::{load_level, save_level}; @@ -73,7 +73,7 @@ impl Game for TestGame { } // Custom game object stuff - let light_pos = self.player.camera.position * -1.0; + let light_pos = vec3(2.0, 0.5, 2.0); if !self.paused { self.player.update(frame_time, &self.input, renderer); }