Esempio n. 1
0
        public Spectrum UniformSampleAllLights(Interaction inter, Scene scene, Sampler sampler)
        {
            var L = Spectrum.Zero;

            for (var l = 0; l < scene.Lights.Count; ++l)
            {
                var light = scene.Lights[l];

                // Estimate direct lighting using the requested sample arrays

                var lightPointArray = sampler.Get2DArray(lightSampleCounts[l]);
                var scatteringArray = sampler.Get2DArray(lightSampleCounts[l]);

                if (lightPointArray != null && scatteringArray != null)
                {
                    var Ld = Spectrum.Zero;
                    for (var sample = 0; sample < light.SampleCount; ++sample)
                    {
                        Ld += EstimateDirect(inter, scatteringArray[sample], light, lightPointArray[sample], scene, sampler);
                    }
                    L += Ld / light.SampleCount;
                }

                // If not available, fall back to single sample estimates

                else
                {
                    var lightPoint = sampler.Get2D();
                    var scattering = sampler.Get2D();
                    L += EstimateDirect(inter, scattering, light, lightPoint, scene, sampler);
                }
            }

            return(L);
        }