Beispiel #1
0
        public static Computations prepare_computations(Intersection intersection, Ray ray)
        {
            Computations comps = new Computations();

            comps.t       = intersection.t;
            comps.obj     = intersection.obj;
            comps.point   = position(ray, comps.t);
            comps.eyev    = -1 * ray.direction;
            comps.normalv = normal_at(comps.obj, comps.point);

            if (dot(comps.eyev, comps.normalv) < 0)
            {
                comps.inside   = true;
                comps.normalv *= -1;
            }
            else
            {
                comps.inside = false;
            }
            return(comps);
        }
Beispiel #2
0
 public static Color shade_hit(World world, Computations computations)
 {
     return(lighting(computations.obj.material, world.light, computations.point, computations.eyev, computations.normalv));
 }