Surface Shader (more)
// add in specular relectance contribution to color
if (ks > 0) {
float spec = v.dot(2*lambert*n.x - l.x,
2*lambert*n.y - l.y,
2*lambert*n.z - l.z);
if (spec > 0) {
spec = ks*((float) Math.pow((double) spec, (double) ns));
r += spec*light.ir;
g += spec*light.ig;
b += spec*light.ib;
}
}
}
} // else (directional or point light source)
} // while (loop over lights)
|