Пример #1
0
        public static Canvas Render(Camera c, World w, LightingModel l)
        {
            Canvas image = new Canvas(c.HSize, c.VSize);

            for (int y = 0; y < image.Height; ++y)
            {
                for (int x = 0; x < image.Width; ++x)
                {
                    Ray   r     = c.RayForPixel(x, y);
                    Tuple color = l.ColorAt(w, r);
                    image.WritePixel(x, y, color);
                }
            }

            return(image);
        }
Пример #2
0
        /// <summary>
        /// Main render call
        /// </summary>
        /// <param name="scene"></param>
        /// <returns></returns>
        public Canvas Render(Scene scene)
        {
            Canvas image = new Canvas(hsize, vsize);
            Camera cam   = this;

            for (int y = 0; y < vsize; y++)
            {
                for (int x = 0; x < hsize; x++)
                {
                    Ray   ray   = cam.RayForPixel(x, y);
                    Color color = scene.ColorAt(ray);

                    Console.WriteLine("Color: " + color.ToString());
                    image.SetPixelColor(x, y, color);
                }
            }
            return(image);
        }