Example #1
0
        public static Spectrum UniformSampleOneLight(this Interaction it,
                                                     IScene scene,
                                                     IObjectArena arena,
                                                     ISampler sampler,
                                                     bool handleMedia = false,
                                                     Distribution1D lightDistribution = null)
        {
            var nLights = scene.Lights.Length;

            if (nLights == 0)
            {
                return(Spectrum.Zero);
            }

            int   lightNum;
            float lightPdf;

            if (!(lightDistribution is null))
            {
                lightNum = lightDistribution.SampleDiscrete(sampler.Get1D(), out lightPdf, out _);
                if (lightPdf == 0f)
                {
                    return(Spectrum.Zero);
                }
            }