/***************************** ** Simple fur-shader ** ****************************** ** Created by Zeger Knaepen ** ** 12 january 2002 ** ** zeger_knaepen@yahoo.com ** ** www.povplace.be.tf ** ****************************** ** Simulates short hairs, ** ** like fur, with: ** ** - Fuzzy edges ** ** - Dark highlights ** ** - 'glowing' edges ** ** Not suitable for ** ** animated objects. ** *****************************/ color diffuus (normal Normaal; float Brilliance=1, Diffuus = .7) { normal Nn=normalize(Normaal),Ln; color kleur=0; extern point P; extern vector L; extern color Cl; illuminance(P,Nn,PI/2) { Ln = normalize(L); kleur += Cl*pow(Ln.Nn,Brilliance)*Diffuus; } return kleur; } surface material ( float transparantie=1, //transparance at edges (0: solid, 1=fuzzy edges, 2=completely tranparent. Values between 1 and 2 might give "weird" results :) edgefalloff=2.5, //"fuzziness" of the edges randhelderheid=.5, //brightness of the glow on the edges brilliance=1, //brilliance (as in POV-Ray) diffuus=.7, //diffuse (as in POV-Ray) speculair=.5, //specular (as in POV-Ray, except this is a darker specular-high'light') roughness=.4, //roughness, size of the dark spot metallic=0; //metallic (as in POV-Ray, although I don't really know if it has much effect here :) color indirect=0, //ambient (as in POV-Ray) Kleur2=Cs; //second color (currently, the fur has only 2 colors: Cs and Kleur2) vector Scale=(1,1,1) //the scale of the fur-structure ) { //calculate some often-used values normal Norm=normalize(N); normal V=normalize(I); point Punt=P/Scale; //for some reason it's quite dark. Multiplying the colors with 4 gives much better results :) Cs=Cs*4; Kleur2=Kleur2*4; //calculate values to find the 'edge' of the object. float opac = pow (abs(Norm.V), edgefalloff); float randje = (1 - opac); //calculate the color of the fur at this point float ruis3=noise(Punt*5); color K1=mix(Cs,Kleur2,ruis3); //noisy calculations to simulate the hairs point ruiskleur=((.5,.5,.5)+noise(Punt)*.5)/25; float ruis2=.25+noise(Punt/100)*.75; float ruis=pow(.25+noise(Punt*1/ruiskleur)*.75*ruis2,3); color Oppervlaktekleur=K1*pow(ruis,.5); //calculate the diffuse lighting color D=diffuus(Norm,brilliance,diffuus); color D2=diffuus(Norm,brilliance*4,diffuus*.25); //calculate specular highlights (here used as, uhm... lowdarks? :) color S2=phong(Norm,-V,1/roughness)*speculair*mix((1,1,1),Oppervlaktekleur,metallic); //calculate the actual color of this point Ci = Oppervlaktekleur*(D-D2)-S2+indirect; Ci += Ci*randje*randhelderheid; //calculate the transparancy at the edges float cosinus=cos(noise(Punt*25)*PI); float ruis4=.6+.9*pow(abs(cosinus),.75)*sign(cosinus)/2; float T=min(opac*5,1); Oi=max(min(T-(sin(T*PI)*ruis4)+(1-transparantie),1),0); }