diff options
author | clayjohn <claynjohn@gmail.com> | 2022-09-08 13:55:49 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2022-09-12 08:45:40 -0700 |
commit | 97be1fb7b6e0866bebbc39e852791f09ac9c0aac (patch) | |
tree | da2e36be4364c3ccce9089f9db67bd4f7f425fbe /drivers/gles3/shaders | |
parent | d2a6a187f45345f00214c746924c57752a1f5260 (diff) |
Apply energy conservation to LAMBERT_WRAP and TOON diffuse modes by dividing by PI
Diffstat (limited to 'drivers/gles3/shaders')
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index c7fdd6ebd8..efd6036ba9 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -629,11 +629,12 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte float diffuse_brdf_NL; // BRDF times N.L for calculating diffuse radiance #if defined(DIFFUSE_LAMBERT_WRAP) - // energy conserving lambert wrap shader - diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness))); + // Energy conserving lambert wrap shader. + // https://web.archive.org/web/20210228210901/http://blog.stevemcauley.com/2011/12/03/energy-conserving-wrapped-diffuse/ + diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness))) * (1.0 / M_PI); #elif defined(DIFFUSE_TOON) - diffuse_brdf_NL = smoothstep(-roughness, max(roughness, 0.01), NdotL); + diffuse_brdf_NL = smoothstep(-roughness, max(roughness, 0.01), NdotL) * (1.0 / M_PI); #elif defined(DIFFUSE_BURLEY) |