My original code is better. Ask me for a fix.
a quick fix noted by David:
/*
Shave and a Haircut emulation shader (c) 2010 Joe Alter, Inc
by Joe Alter
Illuminance fixes by Bernard Edlington, updated by David Lin
Last updated: 06/01/2010
*/
normal pxslUtilShadingNormal(normal n;) {
normal Ns = normalize(n);
extern vector I;
uniform float sides = 2;
uniform float raydepth;
attribute("Sides", sides);
rayinfo("depth", raydepth);
if (sides == 2 || raydepth > 0)Ns = faceforward(Ns, I, Ns);
return Ns;
}
surface Shave (float Ka = 0,
SHAVEambdiff = .6,
SHAVEspec = .35,
SHAVEgloss = .07,
SHAVEopacity = 1.0,
SHAVEselfshad = 1,
coneangle = 30; /* note to Joe: this parameter should be converted from the SHAVEgloss primvar */
color SHAVEspec_color = 1,
rootcolor = 1,
tipcolor = 1;) {
normal Ns = pxslUtilShadingNormal(N);
normal Nn = normalize(N);
vector In = normalize(I);
vector T = normalize (dPdv); /* tangent along length of hair */
vector V = -normalize(I); /* V is the view vector */
float df2 = 0, diffterm = 0;
color Cspec = 0, Cdiff = 0; /* collect specular & diffuse light */
color mixed = 1;
float rawspec;
color Cl2;
float vt, tl;
// Direct illumination
illuminance ("-environment", P, Ns, 1.57, "lightcache", "reuse")
{
float sq2;
df2=(T.normalize(L));
df2*=df2;
df2=1.0-df2;
if (df2<0) df2=0;
if (df2>0) df2=sqrt(df2);
diffterm=df2; /* diffuse */
if (diffterm<0) diffterm=0;
vt = V.T;
sq2=1.0-vt*vt;
if (sq2<0) sq2=0;
if (sq2>0) sq2=sqrt(sq2);
rawspec = df2* sqrt( 1.0- vt * vt ) - (normalize(L). T ) * vt; /* raw specular */
if (rawspec<0) rawspec=0;
diffterm=(1.0-SHAVEambdiff)+diffterm*SHAVEambdiff; /* limits gamut of diffuse term */
Cl2=Cl*SHAVEselfshad+(1-SHAVEselfshad); /* limits the gamut of shadowing */
Cspec += Cl2*pow( rawspec, 1.0 / ( 3.0 * ( .101 - SHAVEgloss ) ) )*.5; /* specular exponent x illumination */
Cdiff += Cl2*diffterm; /* diffuse x illumination */
}
// illumination from environments
// this will include both environment and indirect illum
float occl = 0;
color indiff = 0;
color envCol = 0;
color specCol = 0;
// get all envlights
shader envlights[] = getlights("category", "environment");
uniform float i, n = arraylength(envlights);
// for specular calculations
vector envdir = reflect(In, Nn);
float angle = radians(coneangle);
// find out if it's a bake pass
string CurrentPassClass = "";
option("user:pass_class", CurrentPassClass);
//calculate area for occlusion baking; use Cdiff for radiosity
float a = area(P, "dicing");
// If is a bake pass
if (CurrentPassClass == "RenderRadiosity" && a > 0)
{
for(i=0;i < n ; i += 1 ) // Loop through each envlight
{
envlights[i]->bake(P, Nn, a, Cdiff);
}
}
else // calculate indirect illumination
{
for(i=0 ; i < n ; i += 1 ) // Loop through each envlight
{
//Diffuse contributions from EnvLight
envlights[i]->diffuseIllum(P, Ns, Nn, indiff, envCol, envdir, occl);
color env = envCol * (1-occl);
Cdiff += env;
Cdiff += indiff;
//Specular contributions from EnvLight
envlights[i]->specularIllum(P, envdir, angle, specCol);
Cspec += specCol;
}
}
mixed = mix( rootcolor, tipcolor, v );
Oi = Os*SHAVEopacity;
Ci = Oi * Cs * mixed* (Ka*ambient() + Cdiff) + ( Cspec * SHAVEspec_color *SHAVEspec); /*sum terms and premult color x opac */
}
Popular Posts
-
以下は、スタジオ全体をブレンダーパイプラインに変更する方法に関するコツの情報です。 あなたはどうせ物事が変わらないと思っていませんか? 私が最初に来日した時、私はTDIとWavefrontを使用することに慣れていて、それからSoftimge、次にAlias、そしてMayaへと変更...
-
The following is a few tips on how to change an entire studio to a Blender pipeline. If you think things wont change... When I first arrive...
-
Re: https://www.japanindustrynews. com/2016/02/employ-people- japan-legal-perspective/ 人は日本の雇用制度がどのぐらい複雑か分ってくれないと思います 。 法律の範囲を越えないようにするのは重...
-
アシスタントアニメーターのポジションに空席あり Toneplusでは、 ある一つのプロジェクトにおいて日本人の研修アニメーターを募集 しています。 仕事の成果が優秀であれば、長期契約を得ることも可能です。 研修はカナダ人リードアニメーターによって行われます。 ...
-
Yesterday February the 22nd marked Toneplus ’ 19th year anniversary, reincorporated nearly 5 years ago as a stock Corporation so I could inv...
-
Recently I haven't had much time to blog. You may have seen a lot of the cool things that I am doing with toneplus. Anyway this piece ...
-
On Sunday I was over in Toyosu and decided to pop into the Tokyo Gas Science museum. I animated the exhibit a few years ago so I was curious...
-
#event : Thursday August 4 at 19:00 Ginza A lot of you remember I used to host a lot of events under the banner TokyoGAF. I rented out boa...
-
イベント: 8月4日(木)19:00より銀座 記憶に残っている方も多いと思いますが、私は東京GAFという旗印のもと、多くのイベントを主催していました。私はボートやクラブを貸し出し、映画の有名人を迎えたこともあります。 ここにいくつかの思い出があります: https://www.f...
-
I held the eighth TokyoGAF party at club Womb in Dogenzaka this time. A spectacular night with good friends and some new faces representin...
Blogger news
Blogroll
RSS Subscribe
Post a Comment