Oren NayarModel
2019獨角獸企業重金招聘Python工程師標準>>>
???????這里說的并不是什么新技術,都是很古老很古老的東西。
??????? 一般我們用的cg軟件上面大量使用的漫反射模型Lambert’s model,是一個讓光線向各個角度都均勻輻射的模型。這個均勻實在太不可思議了,真實物體表面理應不是這樣的。這里介紹一下Oren/Nayar model。
?????? 其實以下內容基本來自于Advance RenderMan。
?????? Advance RenderMan提到一個極端的例子,就是月球表面。假如你用Lambert來模擬月球,地球等宏觀表面,會發現怎么樣也做不好。在月圓的時候,月球看起來更像一塊發光的平板,而不是一個球體。
?
?????? 另外一個現象就是,即使在燈光方向不變的情況下,觀察物體的角度不同,物體表面光強、顏色也會發生變化(一般粗糙物體正光光強比背光光強要強)。就是光線向各個角度并非均勻輻射。
?
??????? 這個現象應該算是BRDF(Bidirectional Reflectance Distribution Function)現象的一部分。這個函數想用數學方式表述好像很困難,大概只能通過光學測量求得,而且各種物體表面輻射的情況超級復雜,而且差異很大, 比較難一一概括。
??????? 關于BRDF,看以下連接:http://www-modis.bu.edu/brdf/brdfexpl.html
?
?????? Oren/Nayar model 這個主要來自于Michael Oren和Shree K. Nayar在SIGGRAPH94上發表的論文Generalization of Lambert’s Reflectance Model。里面通過統計的等手段總結出比較接近真實粗糙表面的數學公式,然后Advance RenderMan提供了相應實現的函數。其實3dmax好像也帶這個Oren/Nayar model ,不過maya卻沒有的樣子。
?????? 以下是論文的連接:http://www1.cs.columbia.edu/CAVE/publications/pdfs/Oren_SIGGRAPH94.pdf
???????一些另外的連接: http://www.cs.utah.edu/~wyman/classes/BRDF/orn_nyr.html
?
????? 我這里提供一個簡單的sl代碼(根本就只是在Advance RenderMan上抄下來而已)??梢栽趐ixie,prman使用,其他兼容rm應該也沒有問題。
?
surface OrenNayar (float Ka = 1, Kd = 1, roughness=0.5)
{
/*
* Oren and Nayar’s generalization of Lambert’s reflection model.
* The roughness parameter gives the standard deviation of angle
* orientations of the presumed surface grooves. When roughness=0,
* the model is identical to Lambertian reflection.
*/
normal Nf = faceforward (normalize(N),I);
vector In = normalize(-I);
color LocIllumOrenNayar (normal N; vector V; float roughness;)
{
??? /* Surface roughness coefficients for Oren/Nayar’s formula */
??? float sigma2 = roughness * roughness;
??? float A = 1 - 0.5 * sigma2 / (sigma2 + 0.33);
??? float B = 0.45 * sigma2 / (sigma2 + 0.09);
??? /* Useful precomputed quantities */
??? float theta_r = acos (V . N); /* Angle between V and N */
??? vector V_perp_N = normalize(V-N*(V.N)); /* Part of V perpendicular to N */
??? /* Accumulate incoming radiance from lights in C */
??? color C = 0;
??? extern point P;
??? illuminance (P, N, PI/2) {
??????? /* Must declare extern L & Cl because we’re in a function */
??????? extern vector L; extern color Cl;
??????? float nondiff = 0;
??????? lightsource ("__nondiffuse", nondiff);
??????? if (nondiff < 1) {
??????????? vector LN = normalize(L);
??????????? float cos_theta_i = LN . N;
??????????? float cos_phi_diff = V_perp_N . normalize(LN - N*cos_theta_i);
??????????? float theta_i = acos (cos_theta_i);
??????????? float alpha = max (theta_i, theta_r);
??????????? float beta = min (theta_i, theta_r);
??????????? C += (1-nondiff) * Cl * cos_theta_i * (A + B * max(0,cos_phi_diff) * sin(alpha) * tan(beta));
??????? }
??? }
??? return C;
}
Ci =? Cs * (Ka * ambient() + Kd *LocIllumOrenNayar(Nf,In,roughness));
Oi = Os;? Ci *= Oi;
}
?
????? 以下是用pixie渲染的,左邊是matte,就是普通的Lambert(別以為白色暴掉的地方是高光,沒有高光)。右邊的是OrenNayar ,roughness在0.4左右。
????
?
???????另外,下面是正光背光的對比
?
??????? 最后,其實OrenNayar已經是10多年前的東西了,現在應該也有了更新的論文跟光照模型。那些遲點看到再說了。
轉載于:https://my.oschina.net/zsjasper/blog/368301
總結
以上是生活随笔為你收集整理的Oren NayarModel的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JAVA_NIO ,走进JavaNIO的
- 下一篇: 使用telnet命令验证邮箱