fix for hair GI code

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 */
}