Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public IntersectionData Compute(Ray ray, Intersections intersections = null) => new IntersectionData(this, ray, intersections);
Exemplo n.º 4
0
 public abstract void IntersectLocal(ref Tuple origin, ref Tuple direction, Intersections intersections);