Exemple #1
0
        Color sampleLights(Scene scene, Ray n, Random rand)
        {
            var nLights = scene.Lights.Length;

            if (nLights == 0)
            {
                return(Color.Black);
            }
            if (LightMode.Equals(LightMode.LightModeAll))
            {
                Color result = new Color();
                foreach (var light in scene.Lights)
                {
                    result = result.Add(sampleLight(scene, n, rand, light));
                }
                return(result);
            }
            else
            {
                // pick a random light
                var light = scene.Lights[rand.Next(nLights)];
                return(sampleLight(scene, n, rand, light).MulScalar(nLights));
            }
        }