public void AbsDotProduct() { var a = new Normal(1, 2, 3); var b = new Normal(2, 3, 4); Normal.AbsDot(a, b).Should().BeApproximately(20f, 0.00001f); b = new Normal(-2, 3, -4); Normal.Dot(a, b).Should().BeApproximately(-8f, 0.00001f); Normal.AbsDot(a, b).Should().BeApproximately(8f, 0.00001f); }
public virtual float Pdf(Point p, Vector wi) { // Intersect sample ray with area light geometry var ray = new Ray(p, wi, 1e-3f); ray.Depth = -1; // temporary hack to ignore alpha mask float thit, rayEpsilon; DifferentialGeometry dgLight; if (!TryIntersect(ray, out thit, out rayEpsilon, out dgLight)) { return(0.0f); } // Convert light sample weight to solid angle measure float pdf = Point.DistanceSquared(p, ray.Evaluate(thit)) / (Normal.AbsDot(dgLight.Normal, -wi) * Area); if (float.IsInfinity(pdf)) { pdf = 0.0f; } return(pdf); }