Example #1
0
        public static Tuple ColourAt(World world, Ray ray, int remaining)
        {
            Intersection[] worldIntersections = IntersectWorld(world, ray);
            Intersection   hit = Intersect.Hit(worldIntersections);

            if (hit != null)
            {
                Precomputation comps = Intersect.PrepareComputations(hit, ray);
                return(ShadeHit(world, comps, remaining));
            }
            else
            {
                return(new Tuple(0, 0, 0, 0));
            }
        }
Example #2
0
        public static bool IsShadowed(World world, Tuple point)
        {
            Tuple lightv    = world.SceneLight.Position - point;
            float distance  = lightv.Magnitude();
            Tuple direction = lightv.Normalise();
            Ray   shadowRay = new Ray(point, direction);

            Intersection[] worldIntersections = IntersectWorld(world, shadowRay);
            Intersection   hit = Intersect.Hit(worldIntersections);

            if (hit != null)
            {
                if (hit.T_Value < distance)
                {
                    return(true);
                }
            }
            return(false);
        }