From 974aec16f88d765e90e897d51de3b04d41acb16b Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Fri, 24 Mar 2023 08:30:51 +0100 Subject: [PATCH] [dataflow-rendering] update shader code for envlighting --- .../Rendering/Shaders/EnvLightNode/shader.frag.glsl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Dataflow/Rendering/Shaders/EnvLightNode/shader.frag.glsl b/src/Dataflow/Rendering/Shaders/EnvLightNode/shader.frag.glsl index d43c2e7d021..80ec97dc1f4 100644 --- a/src/Dataflow/Rendering/Shaders/EnvLightNode/shader.frag.glsl +++ b/src/Dataflow/Rendering/Shaders/EnvLightNode/shader.frag.glsl @@ -105,9 +105,12 @@ void main() { vec2 size = textureSize( amb_occ_sampler, 0 ).xy; vec3 ao = texture( amb_occ_sampler, gl_FragCoord.xy / size ).rgb; bc.rgb = diffuse; - bc.r *= dot( normalWorld, redShCoeffs * normalWorld ); - bc.g *= dot( normalWorld, greenShCoeffs * normalWorld ); - bc.b *= dot( normalWorld, blueShCoeffs * normalWorld ); + vec3 irradiance = vec3( + dot( normalWorld, redShCoeffs * normalWorld ), + dot( normalWorld, greenShCoeffs * normalWorld ), + dot( normalWorld, blueShCoeffs * normalWorld ) + ); + bc.rgb *= irradiance / OneOverPi; // Specular envmap float cosTi = clamp( dot( rfl, normalWorld.xyz ), 0.001, 1. ); vec3 spec = clamp( specular * cosTi * OneOverPi * 0.5, 0.001, 1. );