public Color ColorAt(Ray ray, int remaining = 5) { var intersections = new Intersections(); Intersect(ray, intersections); var hit = intersections.Hit(); if (hit == null) { return(Color.Black); } var intersectionData = hit.Compute(ray, intersections); var color = ShadeHit(intersectionData, remaining); return(color); }
public bool IsShadowed(Tuple point, ILight light) { var v = light.Position - point; var distance = v.Magnitude; var direction = v.Normalize(); var r = Helper.Ray(point, direction); var intersections = new Intersections(); Intersect(r, intersections); var h = intersections.Hit(); if (h != null && h.T < distance) { return(true); } return(false); }
public IntersectionData Compute(Ray ray, Intersections intersections = null) => new IntersectionData(this, ray, intersections);
public abstract void IntersectLocal(ref Tuple origin, ref Tuple direction, Intersections intersections);