public float Evaluate(float cosi) { cosi = LR.Clamp(cosi, -1.0f, 1.0f); // Compute indices of refraction for dielectric bool entering = cosi > 0.0;//>0 入射 float ei = eta_i, et = eta_t; if (!entering) { LR.Swap(ei, et); } // Compute _sint_ using Snell's law float sint = ei / et * (float)Math.Sqrt(Math.Max(0.0f, 1.0f - cosi * cosi));//处理溢出? if (sint >= 1.0) { // Handle total internal reflection return(1.0f); } else { float cost = (float)Math.Sqrt(Math.Max(0.0f, 1.0f - sint * sint)); return(BSDFFunction.FrDiel(Math.Abs(cosi), cost, ei, et)); } }
public static float SinPhi(Vector w) { float sintheta = SinTheta(w); if (sintheta == 0.0f) { return(0.0f); } return(LR.Clamp(w.y / sintheta, -1.0f, 1.0f)); }
public static float CosPhi(Vector w) { float sintheta = SinTheta(w); if (sintheta == 0.0f) { return(1.0f); //垂直 } return(LR.Clamp(w.x / sintheta, -1.0f, 1.0f)); }