|
surface
carpaint_basic(
float Kd = 1;
float shellac = 0.6;
float specLevel = 0.5;
float specRoughness = 0.4;
float shellacOffset = 0.01;
color upperClamp = 1.1;
color inputcolor = color (0.337,0.521,0.933);)
{
//set clamping values
color minC = color(0,0,0);
color maxC = color(1,1,1);
//set up normals, vectors etc
normal n = normalize(N);
vector i = normalize(-I);
normal nf = faceforward(n, I);
float fr = abs(n.normalize(I)); //calc facing ratio
color diffuseValue = Kd * diffuse(nf); //add in some diffuse
vector rRay = reflect(i*N,N); //get reflected vector
color calcEnvColor = environment("uffizi.tex", rRay); //use the env function to calc env reflection
color envColor = color clamp(color calcEnvColor, minC, upperClamp); //clamp it
color calcShellac = (shellac * envColor * (1-fr)) - shellacOffset; //shellac layer calc
color finalShellac = color clamp(color calcShellac, minC, maxC); //clamp it
//spec layer stuff:
color specColor = specular(nf, i, specRoughness);
Oi = Os;
Ci = Oi * Cs * inputcolor * fr * diffuseValue + finalShellac + specColor * specLevel * fr; //final maths
}
|