Ejemplo n.º 1
0
        private void LinearScanner(object o)
        {
            var config = (ScannerConfig)o;
            int n;

            lock (buff) n = ++NowSample;
            for (var j = config.h - 1; j >= 0; j--)
            {
                for (var i = 0; i < config.w; i++)
                {
                    var color = mode == Mode.Diffusing
                        ? Diffusing(camera.CreateRay(
                                        (i + Random.Range(0, 1f)) * recip_width,
                                        (j + Random.Range(0, 1f)) * recip_height), hitableList, 0)
                        : NormalMap(camera.CreateRay(
                                        (i + Random.Range(0, 1f)) * recip_width,
                                        (j + Random.Range(0, 1f)) * recip_height), hitableList);
                    SetPixel(i, config.h - j - 1, color, n);
                }
            }
            Form1.main.BeginInvoke(new Action(() => { Form1.main.SetSPP(); }));
        }
Ejemplo n.º 2
0
        public Vector3 GetRandomPointInUnitSphere()
        {
            var p = new Vector3(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f)) * 2f - Vector3.one;

            return(p.Normalized() * Random.Range(0f, 1f));
        }