From a262a590b287850a97a5258b34eb804a7b164756 Mon Sep 17 00:00:00 2001 From: Katajisto Date: Sat, 21 Mar 2026 10:47:57 +0200 Subject: [PATCH] reduce indirect specular lighting at grazing angles --- src/shaders/shader_trile.glsl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shaders/shader_trile.glsl b/src/shaders/shader_trile.glsl index 756046d..f22c31e 100644 --- a/src/shaders/shader_trile.glsl +++ b/src/shaders/shader_trile.glsl @@ -554,7 +554,10 @@ void main() { indirectSpec = mix(indirectSpec, vec3(specLum), metallic); vec2 envBRDF = texture(sampler2D(brdf_lut, rdmsmp), vec2(max(dot(N, V), 0.0), roughness)).rg; - light += indirectSpec * (Frough * envBRDF.x + envBRDF.y) * rdm_spec_scale; + float NdotV_s = max(dot(N, V), 0.0); + float roughnessBell = 1.0 - 0.7 * sin(roughness * PI); + float grazingSuppress = 1.0 - 0.9 * roughness * sin(roughness * PI) * pow(1.0 - NdotV_s, 2.0); + light += indirectSpec * (Frough * envBRDF.x + envBRDF.y) * rdm_spec_scale * roughnessBell * grazingSuppress; // Indirect diffuse (interpolated from neighbor probes) vec3 indirectDiff = sample_rdm_diff(N, vpos - hemispherePos, local) * rdm_tint;