Here is a small modification to my last post by Jagger from the Renderman forums. It adds local lights to my GI loop.
--- shd1.sl 2008-04-02 08:55:28.270635187 +0900
+++ shd2.sl 2008-04-02 08:55:58.334048545 +0900
@@ -1,4 +1,4 @@
-surface be_shave (float Ka = 0, SHAVEambdiff = .6, SHAVEspec = .35, SHAVEgloss = .07,SHAVEopacity = 1.0,SHAVEselfshad=1;
+surface shave_total (float Ka = 0, SHAVEambdiff = .6, SHAVEspec = .35, SHAVEgloss = .07,SHAVEopacity = 1.0,SHAVEselfshad=1;
color SHAVEspec_color=1,rootcolor=1,tipcolor=1;)
{
normal pxslUtilShadingNormal(normal n;){
@@ -56,7 +56,31 @@
Cspec += Cl2*pow( rawspec, 1.0 / ( 3.0 * ( .101 - SHAVEgloss ) ) )*.5; /* specular exponent x illumination */
Cdiff += Cl2*diffterm; /* diffuse x illumination */
}
+illuminance ("-environment", P, "lightcache", "reuse")
+{
+float sq2;
+df2=(T.normalize(L));
+df2*=df2;
+df2=1.0-df2;
+if (df2<0) df2="0;">0)
+df2=sqrt(df2);
+diffterm=df2; /* diffuse */
+if (diffterm<0) diffterm="0;" vt =" V.T" sq2="1.0-vt*vt;" sq2="0;">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 */
+}
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 */
Post a Comment