diff options
author | Ferenc Arn <tagcup@yahoo.com> | 2017-09-28 19:26:01 -0400 |
---|---|---|
committer | Ferenc Arn <tagcup@yahoo.com> | 2017-09-28 19:26:01 -0400 |
commit | 8cb67b03a9cd7df802ea9a98f6ac2a10e6071cb8 (patch) | |
tree | 67d9ff34b030e61c8d35336e8ad111e80ee0e2a7 /drivers | |
parent | 4f39ce32b9195405f934445b20059e86632b47f9 (diff) |
Fix Oren-Nayar diffuse.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index b6fb69a2aa..531e52f843 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -920,6 +920,7 @@ LIGHT_SHADER_CODE #elif defined(DIFFUSE_OREN_NAYAR) { + // see http://mimosa-pudica.net/improved-oren-nayar.html float LdotV = dot(L, V); float NdotL = dot(L, N); 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 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); - 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) |