public static XMVector FresnelTerm(XMVector cosIncidentAngle, XMVector refractionIndex) { Debug.Assert(!XMVector4.IsInfinite(cosIncidentAngle), "Reviewed"); //// Result = 0.5f * (g - c)^2 / (g + c)^2 * ((c * (g + c) - 1)^2 / (c * (g - c) + 1)^2 + 1) where //// c = CosIncidentAngle //// g = sqrt(c^2 + RefractionIndex^2 - 1) XMVector g = XMVector.MultiplyAdd(refractionIndex, refractionIndex, XMGlobalConstants.NegativeOne); g = XMVector.MultiplyAdd(cosIncidentAngle, cosIncidentAngle, g); g = g.Abs().Sqrt(); XMVector s = XMVector.Add(g, cosIncidentAngle); XMVector d = XMVector.Subtract(g, cosIncidentAngle); XMVector v0 = XMVector.Multiply(d, d); XMVector v1 = XMVector.Multiply(s, s).Reciprocal(); v0 = XMVector.Multiply(XMGlobalConstants.OneHalf, v0); v0 = XMVector.Multiply(v0, v1); XMVector v2 = XMVector.MultiplyAdd(cosIncidentAngle, s, XMGlobalConstants.NegativeOne); XMVector v3 = XMVector.MultiplyAdd(cosIncidentAngle, d, XMGlobalConstants.One); v2 = XMVector.Multiply(v2, v2); v3 = XMVector.Multiply(v3, v3); v3 = v3.Reciprocal(); v2 = XMVector.MultiplyAdd(v2, v3, XMGlobalConstants.One); return(XMVector.Multiply(v0, v2).Saturate()); }
public static bool IsInfinite(XMVector p) { return(XMVector4.IsInfinite(p)); }
public static bool IsInfinite(XMVector c) { return(XMVector4.IsInfinite(c)); }
public static bool IsInfinite(XMVector q) { return(XMVector4.IsInfinite(q)); }