Exemplo n.º 1
0
 public MonteCarloLightingModel(Scene scene, RNG rng, bool nee, bool cosineDist, bool russianRoulette)
 {
     _scene = scene;
     _rng = rng;
     _nee = nee;
     _cosineDist = cosineDist;
     _russianRoulette = russianRoulette;
 }
Exemplo n.º 2
0
 public Stratifier(RNG rng, int width, int height)
 {
     _rng = rng;
     _width = width;
     _height = height;
     _invWidth = 1f/_width;
     _invHeight = 1f/_height;
 }
Exemplo n.º 3
0
Arquivo: RNG.cs Projeto: tincann/AGR
 public static RNG[] CreateMultipleRNGs(int count)
 {
     var m = new Random();
     var r = new RNG[count];
     for (int i = 0; i < count; i++)
     {
         r[i] = new RNG(m.Next());
     }
     return r;
 }
Exemplo n.º 4
0
        public Color3 Sample(Scene scene, Ray ray, RNG rng, bool ignoreLight)
        {
            if (ray.BouncesLeft < 1)
            {
                return Color4.Black;
            }

            //get nearest intersection
            var intersection = IntersectionHelper.GetClosestIntersection(ray, scene.Objects);
            if (intersection == null)
            {
                return scene.Skybox.Intersect(ray.Direction);
            }

            var lightingModel = new MonteCarloLightingModel(scene, rng, nee: true, cosineDist: true, russianRoulette: false);
            return lightingModel.Calculate(intersection, ignoreLight);
        }
Exemplo n.º 5
0
        public Color3 Sample(Scene scene, Ray ray, RNG random, bool ignoreLight)
        {
            //Debug.Assert(scene.BVH != null);

            if (ray.BouncesLeft < 1)
            {
                return Color4.Red;
            }

            //get nearest intersection
            var intersection = IntersectionHelper.GetClosestIntersection(ray, scene.Objects);
            if (intersection == null)
            {
                return scene.Skybox.Intersect(ray.Direction);
            }

            var lightingModel = new WhittedStyleLightingModel(scene, random);
            return lightingModel.Calculate(intersection);
        }
Exemplo n.º 6
0
 public WhittedStyleLightingModel(Scene scene, RNG rng)
 {
     _scene = scene;
     _rng = rng;
 }
Exemplo n.º 7
0
Arquivo: game.cs Projeto: tincann/AGR
        public Color3 TraceRay(int x, int y, RNG rng)
        {
            float v = (float)y / Screen.Height;
            float u = (float)x / Screen.Width;

            Color3 color = new Color3(0,0,0);
           
            var strat = new Stratifier(rng, _sampleSizeX, _sampleSizeY);
            for (int i = 0; i < SampleSize; i++)
            {
                var pos = strat.GetRandomPointInStratum(i);
                var dx = pos.X / Screen.Width;
                var dy = pos.Y / Screen.Height;
                var r = _camera.CreatePrimaryRay(u + dx, v + dy);
                color += _scene.Sample(r, rng, false);
            }

            color /= SampleSize;
            return color;
        }
Exemplo n.º 8
0
Arquivo: Scene.cs Projeto: tincann/AGR
 public Color3 Sample(Ray ray, RNG random, bool ignoreLight)
 {
     return _tracer.Sample(this, ray, random, ignoreLight);
 }