Ejemplo n.º 1
0
        public override void Splat(SampleBuffer sampleBuffer)
        {

            var waveLengthWeight = 1f/ (SpectralSamplingHelper.SpectralSamples);
            lambdas[lambdaSample] = (HeroWavelength);
            wls[lambdaSample] = (waveRadiance * waveLengthWeight);

            lambdaSample++;
            if (lambdaSample >= SpectralSamplingHelper.SpectralSamples)
            {
#if RandomWavelength

                var lb = lambdas.ToList();
                lb.Sort();
                lambdas = lb.ToArray();

#endif
                var spd = new IrregularSPD(lambdas, wls, SpectralSamplingHelper.SpectralSamples, SpectralSamplingHelper.SpectralResolution, SPDResamplingMethod.Linear);
                //var spd = new RegularSPD(wls, SampledSpectrum.sampledLambdaStart, SampledSpectrum.sampledLambdaEnd, SpectralSamplingHelper.SpectralSamples);
                spd.Normalize();
                var pix =
                    //ColorFactory.ToRgb(spd);
                    spd.ToRgb();

                sampleBuffer.SplatSample(this.Sample.imageX, this.Sample.imageY, ref pix);
                lambdaSample = 0;
            }
            this.InitPath(pathIntegrator);
        }
Ejemplo n.º 2
0
        public static IrregularSPD CreateIrregular(float[] wl)
        {

            var nSamples = wl.Length / 2;
            var lambda = new float[nSamples];
            var val = new float[nSamples];

            for (int index = 0; index < lambda.Length; index++)
            {
                lambda[index] = wl[index * 2];
                val[index] = wl[index * 2 + 1];
            }

            var spd = new IrregularSPD(lambda, val, lambda.Length, 300f / lambda.Length);
            spd.Normalize();
            return spd;
        }