zenyx-engine/shaders/shader.frag
Chance 5afd5b0c1e
Some checks failed
Build Zenyx ⚡ / 🧪 Run Cargo Tests (push) Successful in 4m23s
Build Zenyx ⚡ / 🏗️ Build aarch64-unknown-linux-gnu (push) Failing after 7m10s
Build Zenyx ⚡ / 🏗️ Build x86_64-apple-darwin (push) Failing after 9m3s
Build Zenyx ⚡ / 🏗️ Build aarch64-apple-darwin (push) Failing after 9m12s
Build Zenyx ⚡ / 🏗️ Build aarch64-pc-windows-msvc (push) Failing after 9m48s
Build Zenyx ⚡ / 🏗️ Build x86_64-pc-windows-msvc (push) Failing after 6m22s
Build Zenyx ⚡ / 🏗️ Build x86_64-unknown-linux-gnu (push) Failing after 5m7s
fix(err): Improve error handling to reduce crashes
2025-05-05 17:24:24 -04:00

20 lines
915 B
GLSL

#version 450
layout(location = 0) in vec2 tex_coords;
layout(location = 1) in vec4 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(vec3(normal.x, normal.y, normal.z)), light_dir), 0.0, 1.0);
float brightness = ambient + (1.0 - ambient) * diffuse;
// out_color = vec4(normal.x, normal.y, normal.z, 1.0);
// out_color = vec3(1.0,.0.0)
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);
}