[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44330] trunk/blender/intern/cycles/kernel /svm/bsdf_oren_nayar.h: Cycles: improve the Oren-Nayar BSDF ( roughness value for Diffuse), to avoid
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed Feb 22 16:04:23 CET 2012
Revision: 44330
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44330
Author: blendix
Date: 2012-02-22 15:04:22 +0000 (Wed, 22 Feb 2012)
Log Message:
-----------
Cycles: improve the Oren-Nayar BSDF (roughness value for Diffuse), to avoid
undesired dark rings, and give more accurate lighting when the light is
behind the object. As a bonus, the code is simpler & faster.
Patch by Yasuhiro Fujii, detailed explanation here:
http://mimosa-pudica.net/improved-oren-nayar.html
Modified Paths:
--------------
trunk/blender/intern/cycles/kernel/svm/bsdf_oren_nayar.h
Modified: trunk/blender/intern/cycles/kernel/svm/bsdf_oren_nayar.h
===================================================================
--- trunk/blender/intern/cycles/kernel/svm/bsdf_oren_nayar.h 2012-02-22 14:55:12 UTC (rev 44329)
+++ trunk/blender/intern/cycles/kernel/svm/bsdf_oren_nayar.h 2012-02-22 15:04:22 UTC (rev 44330)
@@ -55,25 +55,11 @@
{
float nl = max(dot(n, l), 0.0f);
float nv = max(dot(n, v), 0.0f);
+ float t = dot(l, v) - nl * nv;
- float3 al = normalize(l - nl * n);
- float3 av = normalize(v - nv * n);
- float t = max(dot(al, av), 0.0f);
-
- float cos_a, cos_b;
- if(nl < nv) {
- cos_a = nl;
- cos_b = nv;
- }
- else {
- cos_a = nv;
- cos_b = nl;
- }
-
- float sin_a = sqrtf(max(1.0f - cos_a * cos_a, 0.0f));
- float tan_b = sqrtf(max(1.0f - cos_b * cos_b, 0.0f)) / max(cos_b, 1e-8f);
-
- float is = nl * (sc->data0 + sc->data1 * t * sin_a * tan_b);
+ if (t > 0.0f)
+ t /= max(nl, nv) + FLT_MIN;
+ float is = nl * (sc->data0 + sc->data1 * t);
return make_float3(is, is, is);
}
@@ -84,9 +70,9 @@
sigma = clamp(sigma, 0.0f, 1.0f);
- float div = 1.0f / ((1.0f + 0.5f * sigma) * M_PI_F);
+ float div = 1.0f / (M_PI_F + ((3.0f * M_PI_F - 4.0f) / 6.0f) * sigma);
- sc->data0 = 1.0f * div;
+ sc->data0 = 1.0f * div;
sc->data1 = sigma * div;
}
More information about the Bf-blender-cvs
mailing list