public Bitmap RenderImage()
        {
            Console.WriteLine("light index to render {0}", lightIndex);

            Bitmap image      = new Bitmap(scene.GetOptions().Width, scene.GetOptions().Height);
            Ray    ray        = new Ray();
            Color  pixelColor = Color.Black;

            CreateRenderedImage(lightIndex, image, ref ray, ref pixelColor);

            textureManager.Clear();

            return(image);
        }
        public static Vector3 GetDirectionFromPixel(PotatoScene scene, float pixelPositionX, float pixelPositionY)
        {
            Vector3 V1       = Vector3.Multiply(scene.GetCamera().Right(), pixelPositionX);
            Vector3 V2       = Vector3.Multiply(scene.GetCamera().Up(), pixelPositionY);
            Vector3 pixelPos = Vector3.Add(Vector3.Add(scene.GetOptions().ScreenLeft, V1), V2);

            return(Vector3.Normalize(Vector3.Add(scene.GetCamera().Forward(), pixelPos)));
        }
        public PotatoRenderer(PotatoScene scene, int lightIndex)
        {
            this.scene = scene;
            option     = scene.GetOptions();

            textureManager = new TextureManager();
            textureManager.AddTextures(scene.GetTexturesPath());
            tracer = new PotatoTracer(scene, textureManager);

            this.lightIndex = lightIndex;

            if (option.SuperSampling)
            {
                superSampling = new SuperSampling(option.Height, option.SuperSamplingDivision, scene, tracer);
            }
        }