public double Schlick() { // find the cosine of the angle between the eye and normal vectors double cos = EyeVector.DotProduct(Normal); // total internal reflection can only occur if n1 > n2 if (N1 > N2) { double n = N1 / N2; double sin2t = n * n * (1.0 - cos * cos); if (sin2t > 1.0) { return(1.0); } // compute cosine of theta_t using trig identity var cost = Math.Sqrt(1.0 - sin2t); // when n1 > n2, use cos(theta_t) instead cos = cost; } var r0 = Math.Pow((N1 - N2) / (N1 + N2), 2); return(r0 + (1 - r0) * Math.Pow((1 - cos), 5)); }
/* * Christophe Schlick, came up with an * approximation to Fresnel’s equations that is much faster, and plenty accurate * besides. Hurray for Schlick! */ internal double Schlick() { var cos = EyeVector.Dot(NormalVector); if (n1 > n2) { var n = n1 / n2; var sin2_t = n * n * (1.0 - cos * cos); if (sin2_t > 1) { return(1.0); } var cos_t = Math.Sqrt(1.0 - sin2_t); cos = cos_t; } var r0 = Math.Pow((n1 - n2) / (n1 + n2), 2); return(r0 + (1 - r0) * Math.Pow(1 - cos, 5)); }
public double Schlick() { var cos = EyeVector.Dot(NormalVector); if (n1 > n2) { var n = n1 / n2; var sin2T = Math.Pow(n, 2) * (1.0 - Math.Pow(cos, 2)); if (sin2T > 1.0) { return(1.0); } var cosT = Math.Sqrt(1.0 - sin2T); cos = cosT; } var r0 = Math.Pow((n1 - n2) / (n1 + n2), 2); return(r0 + (1 - r0) * Math.Pow((1 - cos), 5)); }