From 101ab5be5fd70246a25fb1e313d2487c07b88e77 Mon Sep 17 00:00:00 2001 From: maj00r Date: Wed, 14 Oct 2026 22:09:13 +0200 Subject: [PATCH] fix(shaders): a surface marked as metal in specgloss but with an albedo darker than any real metal is lit as the painted or dirty dielectric it stands for, with its diffuse back and its highlight held to 0.06, instead of going black without a diffuse term, and a metal reflects its surroundings at least at half strength whatever the alpha of its normal map says, since its reflection is all of its colour; materials without specgloss stay as they were --- shaders/light_common.glsl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shaders/light_common.glsl b/shaders/light_common.glsl index a96fa22f..d057e0f7 100644 --- a/shaders/light_common.glsl +++ b/shaders/light_common.glsl @@ -375,6 +375,11 @@ vec3 apply_lights(vec3 fragcolor, vec3 fragnormal, vec3 texturecolor, float refl fragcolor *= pow(gtao.x, gtao_params.y) * min((0.75 + 0.25 * gtao_bent.y) / (0.75 + 0.25 * gtao_normal.y), 1.0); #endif + float metal_dark = metalic * (1.0 - smoothstep(0.02, 0.2, dot(texturecolor, vec3(0.2126, 0.7152, 0.0722)))); + metalic -= metal_dark; + specularity = mix(specularity, min(specularity, 0.06), metal_dark); + reflectivity = max(reflectivity, 0.5 * metalic); + vec3 emissioncolor = vec3(emission); vec3 view_dir = normalize(-f_pos.xyz);