Exemplo n.º 1
0
 public PixelJob(Canvas canvas, World world, int maxRecursion, RenderStatistics renderStatistics, ICamera camera)
 {
     Canvas           = canvas;
     World            = world;
     MaxRecursion     = maxRecursion;
     RenderStatistics = renderStatistics;
     Camera           = camera;
 }
Exemplo n.º 2
0
        private void Run()
        {
            while (!stopRequested && PixelJobs.TryDequeue(out var renderJob))
            {
                renderJob.DoWork();
            }

            RenderStatistics.Stop();
        }
Exemplo n.º 3
0
        public void Render(ICameraParameters camParams, RenderParameters renderParameters, World world)
        {
            Image = new Canvas(camParams.Width, camParams.Height);
            var camera = camParams.BuildCamera();

            stopRequested    = false;
            RenderStatistics = new RenderStatistics {
                Start = DateTime.Now, TotalPixels = camParams.Width * camParams.Height
            };
            Render(camera, world, renderParameters.NbThreads, shuffle: renderParameters.Shuffle);
        }
Exemplo n.º 4
0
 public void DoWork()
 {
     for (int i = 0; i < X.Count; i++)
     {
         int x     = X[i];
         int y     = Y[i];
         var ray   = Camera.RayForPixel(x, y);
         var color = World.ColorAt(ray, MaxRecursion);
         Canvas.SetPixel(x, y, color);
         RenderStatistics.IncNbPixels();
     }
 }