"Fossies" - the Fresh Open Source Software Archive

Member "aqsis-1.8.2/tools/procedurals/hairgen/shaders/hair_gritz.sl" (24 Aug 2012, 1049 Bytes) of package /linux/privat/aqsis-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 /** hair.sl from 
    2  *
    3  * "Advanced RenderMan: Beyond the Companion"
    4  * by Larry Gritz and Tony Apodaca,  course notes from Siggraph 1999 Course 25
    5  */
    6 
    7 surface hair_gritz (
    8 		float Ka = 1;
    9 		float Kd = 0.6;
   10 		float Ks = 0.35;
   11 		float roughness = 0.15;
   12 		color rootcolor = color(0.109, 0.037, 0.007);
   13 		color tipcolor = color(0.519, 0.325, 0.125);
   14 		color specularcolor = (color(1) + tipcolor)/2;
   15 	)
   16 {
   17 	vector T = normalize(dPdv); /* tangent along lenght of hair */
   18 	vector V = -normalize(I);   /* V is the view vector */
   19 	color Cspec = 0, Cdiff = 0; /* collect specular & diffuse light */
   20 	float cosang;
   21 	/* Loop over lights, catch highlights as if this was a thin cylinder */
   22 	illuminance(P)
   23 	{
   24 		cosang = cos(abs(acos(T.normalize(L)) - acos(-T.V)));
   25 		Cspec += Cl * v * pow(cosang, 1/roughness);
   26 		Cdiff += Cl * v;
   27 		/* We multipled by v to make it darker at the roots.  This assumes v=0
   28 		 * at the root, v=1 at the tip.
   29 		 */
   30 	}
   31 	Oi = Os;
   32 	Ci = Oi * (mix(rootcolor, tipcolor, v) * (Ka*ambient() + Kd*Cdiff)
   33 			+ (Ks * Cspec * specularcolor));
   34 }
   35