protected virtual RgbSpectrum SamplePath(int x, int y)
        {
            float lambda;
            Tuple<float, float>[] c = new Tuple<float, float>[MaxSpectralSamples];
            float[] v = new float[MaxSpectralSamples];
            float dLambda = (SampledSpectrum.sampledLambdaEnd - SampledSpectrum.sampledLambdaStart) / ((float)MaxSpectralSamples + 0f);

            for (int l = 0; l < MaxSpectralSamples; l++)
            {
                lambda = SampledSpectrum.sampledLambdaStart + l * dLambda;
                RayData cameraRay;
                Scene.GenerateCameraRay(x, y, out cameraRay);
                var pix = EvalRadiance(ref cameraRay, lambda, 0);
                totalSamples++;
                v[l] = pix;
                c[l] = new Tuple<float, float>(lambda, pix);
                //lambda += dLambda;
            }
            //c = c.OrderBy(item => item.Item1).ToArray();
            //var lms = c.Select(p => p.Item1).ToArray();
            //var vals = c.Select(p => p.Item2).ToArray();
            //var spd = new IrregularSPD(lms, vals, MaxSpectralSamples, dLambda);
            RegularSPD spd = new RegularSPD(v, SampledSpectrum.sampledLambdaStart, SampledSpectrum.sampledLambdaEnd, MaxSpectralSamples);
            //RgbSpectrum pixV = new RgbSpectrum();
            //ColorFactory.SSEToRgb(spd, ref pixV);
            var pixV = spd.ToRgb();
            return pixV;
        }
Exemple #2
0
 public static void SSEToRgb(RegularSPD spd, ref RgbSpectrum res)
 {
     var X = SampledSpectrum.CIE_X;
     var Y = SampledSpectrum.CIE_Y;
     var Z = SampledSpectrum.CIE_Z;
     var vals = spd.GetValues();
     var f_y = 1f / SampledSpectrum.yint;
     SampledSpectrum.XYZToRGB(f_y * SSE.VectorDot(vals, X, vals.Length),
                              f_y * SSE.VectorDot(vals, Y, vals.Length),
                              f_y * SSE.VectorDot(vals, Z, vals.Length),
                              out res.c1, out res.c2, out res.c3);
 }
Exemple #3
0
 public MatteMaterial(RegularSPD col)
 {
     Kd = col;
 }
Exemple #4
0
 public static RegularSPD CreateRegularFromRegular(float[] wl)
 {
     var spd = new RegularSPD(wl, SampledSpectrum.CIEstart, SampledSpectrum.CIEend, wl.Length);
     return spd;
 }
Exemple #5
0
        public static RegularSPD CreateRegular(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 RegularSPD(val, SampledSpectrum.CIEstart, SampledSpectrum.CIEend, val.Length);
            return spd;
        }