Exemplo n.º 1
0
        private static Colour RayColour(Ray r, Hittable world, int depth)
        {
            // If we've exceeded the ray bounce limit, no more light is gathered.
            if (depth <= 0)
            {
                return(Colour.Zero);
            }

            HitRecord rec = new HitRecord();

            if (world.Hit(r, 0.001f, float.PositiveInfinity, ref rec))
            {
                Ray    scattered   = new Ray();
                Colour attenuation = new Colour();
                if (rec.Mat.Scatter(ref r, ref rec, ref attenuation, ref scattered))
                {
                    return(attenuation * RayColour(scattered, world, depth - 1));
                }
                return(Colour.Zero);
            }
            Vector3 unitDirection = Vector3.Normalize(r.Direction);
            float   t             = 0.5f * (unitDirection.Y + 1f);

            return((1f - t) * Colour.One + t * new Colour(0.5f, 0.7f, 1.0f));
        }
Exemplo n.º 2
0
 public void Add(Hittable h)
 {
     hittables.Add(h);
 }