feat(render): basic normal-based lighting

This commit is contained in:
Chance 2025-04-27 16:06:59 -04:00
parent 5e2cb15e13
commit 22a58044d5
Signed by: caznix
GPG key ID: 489D213143D753FD
2 changed files with 12 additions and 0 deletions

View file

@ -1,10 +1,19 @@
#version 450
layout(location = 0) in vec2 tex_coords;
layout(location = 1) in vec3 normal;
layout(set = 1, binding = 0) uniform texture2D t_diffuse;
layout(set = 1, binding = 1) uniform sampler s_diffuse;
layout(location = 0) out vec4 out_color;
// layout(group = 0, binding = 0) out texture2D;
void main() {
float ambient = 0.2;
vec3 light_dir = normalize(vec3(0.5, 1.0, 0.5));
float diffuse = clamp(dot(normalize(normal), light_dir), 0.0, 1.0);
float brightness = ambient + (1.0 - ambient) * diffuse;
out_color = texture(sampler2D(t_diffuse, s_diffuse), tex_coords);
out_color.r = clamp(out_color.r * 0.6 * brightness, 0.0, 1.0);
out_color.g = clamp(out_color.g * 0.6 * brightness, 0.0, 1.0);
out_color.b = clamp(out_color.b * 0.9 * brightness, 0.0, 1.0);
}