public static Color ColorAt(World w, Ray r, int remaining = 5) { var inters = w.Intersect(r); var hit = Intersection.Hit(inters); if (hit == null) { return(Color.Black); } var comps = Computation.PrepareComputations(hit, r, inters); return(ShadeHit(w, comps, remaining)); }
public static bool IsShadowed(World world, PointType point) { foreach (var light in world.Lights) { var v = light.Position - point; var distance = v.Magnetude(); var direction = v.Normalize(); var r = new Ray(point, direction); var intersections = world.Intersect(r); var h = Intersection.Hit(intersections); if (!(h is null) && h.T < distance) { continue; }