Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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;
                }