Simple normal map implementation

This commit is contained in:
2020-10-26 18:15:39 +01:00
parent 9687f5ec89
commit 38ea41b550
6 changed files with 56 additions and 24 deletions

View File

@@ -15,13 +15,14 @@ layout(binding = 2) uniform sampler2D normal_tex;
layout(location = 0) in vec2 tex_coords;
layout(location = 1) in vec3 normal_wld;
layout(location = 2) in vec3 position_wld;
layout(location = 3) in mat3 tbn;
layout(location = 0) out vec4 out_color;
void main() {
// vec3 normal_cam_u = normalize(normal_wld); // TODO
vec3 normal_cam_u = texture(normal_tex, tex_coords).rgb;
normal_cam_u = normalize(normal_cam_u * 2.0 - 1.0);
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);
float ambient_strength = 0.1;