Merge pull request #65544 from clayjohn/lambert-wrap
Apply energy conservation to LAMBERT_WRAP diffuse mode by dividing by PI
This commit is contained in:
commit
79b21e96ad
2 changed files with 8 additions and 6 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -97,11 +97,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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue