Load multiple textures

This commit is contained in:
2020-10-26 10:00:01 +01:00
parent c055ea19ed
commit 9687f5ec89
10 changed files with 73 additions and 32 deletions

View File

@@ -9,7 +9,8 @@ layout(binding = 0) uniform ObjectUniformData {
vec3 camera_position;
} ubo;
layout(binding = 1) uniform sampler2D tex;
layout(binding = 1) uniform sampler2D diffuse_tex;
layout(binding = 2) uniform sampler2D normal_tex;
layout(location = 0) in vec2 tex_coords;
layout(location = 1) in vec3 normal_wld;
@@ -18,7 +19,9 @@ layout(location = 2) in vec3 position_wld;
layout(location = 0) out vec4 out_color;
void main() {
vec3 normal_cam_u = normalize(normal_wld);
// 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);
vec3 light_direction_cam_u = normalize(ubo.light_position - position_wld);
float ambient_strength = 0.1;
@@ -35,5 +38,5 @@ void main() {
float specular_strength = pow(max(dot(reflect_direction, view_direction), 0.0), 64);
vec3 specular_color = specular_value * specular_strength * light_color;
out_color = vec4(ambient_color + diffuse_color + specular_color, 1.0) * texture(tex, tex_coords);
out_color = vec4(ambient_color + diffuse_color + specular_color, 1.0) * texture(diffuse_tex, tex_coords);
}

View File

@@ -11,7 +11,6 @@ layout(binding = 0) uniform ObjectUniformData {
float time;
vec3 light_position;
vec3 camera_position;
} ubo;
layout(location = 0) in vec3 position;