Merge pull request #11672 from tagcup/fix_oren_nayar

Fix Oren-Nayar diffuse.
This commit is contained in:
Gilles Roudiere 2017-09-29 13:47:38 +02:00 committed by GitHub
commit 2c5fa0947d
1 changed files with 3 additions and 2 deletions

View File

@ -920,6 +920,7 @@ LIGHT_SHADER_CODE
#elif defined(DIFFUSE_OREN_NAYAR) #elif defined(DIFFUSE_OREN_NAYAR)
{ {
// see http://mimosa-pudica.net/improved-oren-nayar.html
float LdotV = dot(L, V); float LdotV = dot(L, V);
float NdotL = dot(L, N); float NdotL = dot(L, N);
float NdotV = dot(N, V); float NdotV = dot(N, V);
@ -928,10 +929,10 @@ LIGHT_SHADER_CODE
float t = mix(1.0, max(NdotL, NdotV), step(0.0, s)); float t = mix(1.0, max(NdotL, NdotV), step(0.0, s));
float sigma2 = roughness * roughness; float sigma2 = roughness * roughness;
vec3 A = 1.0 + sigma2 * (diffuse_color / (sigma2 + 0.13) + 0.5 / (sigma2 + 0.33)); vec3 A = 1.0 + sigma2 * (- 0.5 / (sigma2 + 0.33) + 0.17*diffuse_color / (sigma2 + 0.13) );
float B = 0.45 * sigma2 / (sigma2 + 0.09); float B = 0.45 * sigma2 / (sigma2 + 0.09);
light_amount = max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI; light_amount = diffuse_color * dotNL * (A + vec3(B) * s / t) / M_PI;
} }
#elif defined(DIFFUSE_TOON) #elif defined(DIFFUSE_TOON)