Ejemplo n.º 1
0
        public bool IsShadowed(Point origin, Point light)
        {
            Interlocked.Increment(ref Stats.ShadowRays);
            var v             = light - origin;
            var distance      = v.Magnitude();
            var direction     = v.Normalize();
            var r             = new Ray(origin, direction, RayType.Shadow);
            var intersections = this.Intersect(r);
            var h             = r.Hit(intersections);

            if (h != null && h.Time < distance)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public Color ColorAt(Ray ray, int remaining = 5)
        {
            var intersections = new List <Intersection>();

            intersections = this.Intersect(ray);
            if (intersections.Count == 0)
            {
                return(new Color(0, 0, 0));
            }

            var hit = ray.Hit(intersections);

            if (hit == null)
            {
                return(new Color(0, 0, 0));
            }

            var comps = hit.PrepareComputations(ray, intersections);

            return(ShadeHit(comps, remaining));
        }