示例#1
0
        private void RenderProgressive()
        {
            Frames      = 0;
            FrameBuffer = new Core.Vector3[RT.Width, RT.Height];

            RT.Samples = 1;

            for (int i = 0; i < Samples; i++)
            {
                RT.Render();

                Frames++;

                Color[] Data = new Color[RT.Width * RT.Height];

                for (int x = 0; x < RT.Width; x++)
                {
                    for (int y = 0; y < RT.Height; y++)
                    {
                        //Accumulate buffer
                        FrameBuffer[x, y] += RT.Framebuffer[x, y];

                        //Tone mapping
                        Core.Vector3 CurrentColor = FrameBuffer[x, y] / Frames;
                        Core.Vector3 Mapped       = CurrentColor / (CurrentColor + Core.Vector3.One);
                        Mapped = new Core.Vector3(Math.Pow(Mapped.X, 1.0 / 2.2), Math.Pow(Mapped.Y, 1.0 / 2.2), Math.Pow(Mapped.Z, 1.0 / 2.2));

                        //Draw
                        Data[RT.Width * y + x] = new Color((int)(Mapped.X * 255), (int)(Mapped.Y * 255), (int)(Mapped.Z * 255));
                    }
                }

                RenderTarget.SetData(Data);
            }

            Window.AllowUserResizing = true;
        }
示例#2
0
        static void Main(string[] args)
        {
            #if (!DEBUG)
            Core.Raytracer Raytracer = new Core.Raytracer(604, 340, 55, Core.Vector3.Zero, Core.Vector3.Zero, new Core.Texture("Assets/EnvMaps/portland.png", true), 5, 5, 50, 12, false);
            #else
            Core.Raytracer Raytracer = new Core.Raytracer(1280, 720, 75, Core.Vector3.Zero, Core.Vector3.Zero, new Core.Texture("Assets/EnvMaps/portland.png", true), 3, 7, 20, 1, true);
            #endif

            Stopwatch Time = new Stopwatch();
            Time.Start();
            Raytracer.Render();
            Time.Stop();

            Raytracer.ExportToFile("Render.png");

            Process.Start("Render.png");

            Console.WriteLine("Finished rendering in {0} seconds", Time.Elapsed.TotalSeconds);
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }