Esempio n. 1
0
        private void LinearScanner(object o)
        {
            ScannerConfig config = (ScannerConfig)o;

            for (int j = config.h - 1; j >= 0; j--)
            {
                for (int i = 0; i < config.w; i++)
                {
                    SColor color = mode == Mode.Diffusing
                        ? Diffusing(camera.CreateRay(
                                        (i + Random.Get()) * recip_width,
                                        (j + Random.Get()) * recip_height), world, 0)
                        : NormalMap(camera.CreateRay(
                                        (i + Random.Get()) * recip_width,
                                        (j + Random.Get()) * recip_height), world);
                    SetPixel(config.w - i - 1, config.h - j - 1, color);
                }
            }
            Form1.main.BeginInvoke(new Action(() => { Form1.main.ShowTips(); }));
        }
Esempio n. 2
0
        public Ray CreateRay(double x, double y)
        {
            //在下面声明射线对象的时候赋予参数,一个在时间0到时间1内的随机时间。
            if (radius == 0.0)
            {
                return(new Ray(position, lowLeftCorner + x * horizontal + y * vertical - position, time0 + Random.Get() * (time1 - time0)));
            }
            Vector3D rd     = radius * GetRandomPointInUnitDisk();
            Vector3D offset = rd.X * u + rd.Y * v;

            return(new Ray(position + offset, lowLeftCorner + x * horizontal + y * vertical - position - offset, time0 + Random.Get() * (time1 - time0)));
        }
Esempio n. 3
0
        public static Vector3D GetRandomPointInUnitDisk()
        {
            Vector3D p = 2.0 * new Vector3D(Random.Get(), Random.Get(), 0) - new Vector3D(1, 1, 0);

            return(p.GetNormalizeVector() * Random.Get());
        }
        public Vector3D GetRandomPointInUnitSphere()
        {
            Vector3D p = new Vector3D(Random.Get(), Random.Get(), Random.Get()) * 2.0 - Vector3D.one;

            return(p.GetNormalizeVector() * Random.Get());
        }