Beispiel #1
0
 public SphereAreaLight(LightsourceInfo frameLight)
 {
     this.Position = (Point)frameLight.Position;
     this.Power = new RgbSpectrum(frameLight.Spectra);
     this.Spectra = SPD_Data.FromSampled(SPD_Data.D5000, SpectrumType.Illuminant);
     //new SampledSpectrum(ref this.Power, SpectrumType.Illuminant);
 }
Beispiel #2
0
 public MeshLight(FrameLightsource lightsource)
 {
     MeshName = lightsource.Parameters.Get<string>(FrameLightsource.AreaLightGeometryName);
     LightName = MeshName;
     spectra = SPD_Data.FromSampled(SPD_Data.A, SpectrumType.Illuminant);
     gain = lightsource.Parameters.Get<RgbSpectrum>(FrameLightsource.LightsourcePower);
 }
Beispiel #3
0
 public DirectionalLight(FrameLightsource frameLight)
 {
     this.Position = (Point)frameLight.Parameters.Get<Vector>(FrameLightsource.DirLightDirection);
     this.Power = frameLight.Parameters.Get<RgbSpectrum>(FrameLightsource.LightsourcePower);
     this.Spectra = SPD_Data.FromSampled(SPD_Data.D5000, SpectrumType.Illuminant);
     //new SampledSpectrum(ref this.Power, SpectrumType.Illuminant);
 }
Beispiel #4
0
 public DirectionalLight(Vector pos, RgbSpectrum power, SampledSpectrum spd)
 {
     this.Direction = pos;
     this.Power = power;
     this.Spectra = SPD_Data.FromSampled(SPD_Data.D5000, SpectrumType.Illuminant);
     //lightSpectra = GlobalConfiguration.Instance.SpectralRendering ? Spectra.ToArray() : this.Power.ToArray();
 }
Beispiel #5
0
 public static void SSEToRgb(ref SampledSpectrum spd, ref RgbSpectrum res)
 {
     var X = SampledSpectrum.X;
     var Y = SampledSpectrum.Y;
     var Z = SampledSpectrum.Z;
     var f_y = 1f / SampledSpectrum.yint;
     SampledSpectrum.XYZToRGB(f_y * SSE.Dot(ref spd, ref X), f_y * SSE.Dot(ref spd, ref Y), f_y * SSE.Dot(ref spd, ref Z), out res.c1, out res.c2, out res.c3);
 }
Beispiel #6
0
 public MeshLight(FrameLightsource lightsource)
 {
     MeshName = lightsource.Parameters.Get<string>(FrameLightsource.AreaLightGeometryName);
     LightName = MeshName;
     spectra = SPD_Data.FromSampled(SPD_Data.D5000, SpectrumType.Illuminant);//FromFile(@"F:\3D\spds\cie.stdillum.F10.spd")
     gain = lightsource.Parameters.Get<RgbSpectrum>(FrameLightsource.LightsourcePower);
     infoGain = new RgbSpectrumInfo(gain);
 }
Beispiel #7
0
 public void SampledSpectrumTest()
 {
     var src = new RgbSpectrum(0.5f, 0.5f, 0.5f);
     var ss = new SampledSpectrum(ref src, SpectrumType.Illuminant);
     var color = ss.ToRgb().ToColor();
     Assert.IsTrue(color.R < 129);
     Assert.IsTrue(color.G < 129);
     Assert.IsTrue(color.B < 129);
 }
Beispiel #8
0
        private RgbSpectrumInfo getSpectrum()
        {
            if (EmissionSpectra.Length > 3)
            {
                var c = new SampledSpectrum(EmissionSpectra);
                return ColorFactory.SSEToRgbInfo(ref c); 
            }

            return new RgbSpectrumInfo(EmissionSpectra);
        }
Beispiel #9
0
 public static RgbSpectrumInfo SSEToRgbInfo(ref SampledSpectrum spd)
 {
     var X = SampledSpectrum.X;
     var Y = SampledSpectrum.Y;
     var Z = SampledSpectrum.Z;
     var f_y = 1f / SampledSpectrum.yint;
     float[] rgb;
     float[] xyz = { f_y * SSE.Dot(ref spd, ref X), f_y * SSE.Dot(ref spd, ref Y), f_y * SSE.Dot(ref spd, ref Z) };
     SampledSpectrum.XYZToRGB(xyz, out rgb);
     return new RgbSpectrumInfo(rgb);
 }
Beispiel #10
0
 public TriangleLight(IRayEngineScene sc, string meshName, RgbSpectrum gain = new RgbSpectrum())
 {
     this.scene = (RayEngineScene)sc;
     this.meshName = meshName;
     this.Gain = (RgbSpectrumInfo)gain;
     //cie.stdillum.F1.spd
     //@"F:\3D\spds\cie.stdillum.F1.spd"
     //cie.stdillum.A.spd
     //macbeth-1.spd
     //FromFile(@"F:\3D\spds\cie.stdillum.F9.spd")
     spectra = SPD_Data.FromSampled(SPD_Data.FromFile(@"F:\3D\spds\cie.stdillum.D5000.spd"), SpectrumType.Illuminant);
 }
 public override void InitPath(IPathProcessor buffer)
 {
     base.InitPath(buffer);
     this.scene = pathIntegrator.Scene;
     this.Radiance = new SampledSpectrum(0f);
     this.Throughput = new SampledSpectrum(1f);
     this.PathState = PathTracerPathState.EyeVertex;
     if (this.secRays == null)
         this.secRays = new SpectralShadowRayInfo[scene.ShadowRaysPerSample];
     this.Sample = pathIntegrator.Sampler.GetSample(null);
     pathIntegrator.Scene.Camera.GetRay(Sample.imageX, Sample.imageY, out this.PathRay);
     this.RayIndex = -1;
     this.pathWeight = 1.0f;
     this.tracedShadowRayCount = 0;
     this.depth = 0;
     this.specularBounce = true;
 }
Beispiel #12
0
        public static void ChromaticityToSpectrum(float Y, float x, float y, out SampledSpectrum s)
        {
            float X, Z;

            Y = Math.Abs(Y);

            if (!y.NearEqual(0f))
                X = (x / y) * Y;
            else
                X = 0f;

            if (!y.NearEqual(0f) && !Y.NearEqual(0f))
                Z = (1f - x - y) / y * Y;
            else
                Z = 0f;

            var lum = RgbSpectrum.FromXYZ(new[] { X, Y, Z });

            s = ColorFactory.FromRgb(ref lum, SpectrumType.Illuminant);
            
        }
Beispiel #13
0
 public Radiance Mul(ref SampledSpectrum f)
 {
     spectra = spectra * f;
     return this;
 }
Beispiel #14
0
 public Radiance Add(ref SampledSpectrum f)
 {
     spectra = spectra + f;
     return this;
 }
Beispiel #15
0
 public Radiance Mul(RgbSpectrum f, SpectrumType type)
 {
     spectra = spectra * new SampledSpectrum(ref f, type);
     return this;
 }
Beispiel #16
0
 public Radiance Add(ref RgbSpectrum f, SpectrumType type)
 {
     spectra = spectra + new SampledSpectrum(ref f, type);
     return this;
 }
Beispiel #17
0
 public Radiance Mul(float f)
 {
     spectra = spectra * f;
     return this;
 }
Beispiel #18
0
 public LightMaterial(SampledSpectrum spd)
 {
     var color = ColorManager.Instance.Convert(spd, SpectrumType.Illuminant);
     emissionTexture = TextureFactory.Instance.CreateConstTexture(color);
 }
Beispiel #19
0
 public static RgbSpectrum Convert(ref SampledSpectrum ss)
 {
     return ss.ToRgb();
 }
Beispiel #20
0
        static void v1()
        {
            var a = new SampledSpectrum(0.25f);
            var b = new SampledSpectrum(0.25f);
            var r = new SampledSpectrum(1f);

            SSE.MulSSE(ref a, ref  b, ref r);
        }
Beispiel #21
0
 public Radiance()
 {
     spectra = SampledSpectrum.ZeroSpectrum();
 }
Beispiel #22
0
        public static SampledSpectrum BaseFromRgb(float[] rgb, SpectrumType type = SpectrumType.Reflectance)
        {
            var r = new SampledSpectrum(0f);
            if (type == SpectrumType.Reflectance)
            {
                // Convert reflectance spectrum to RGB
                if (rgb[0] <= rgb[1] && rgb[0] <= rgb[2])
                {
                    // Compute reflectance _SampledSpectrum_ with _rgb[0]_ as minimum
                    //r += rgb[0] * rgbRefl2SpectWhite;
                    r.MAdd(ref SampledSpectrum.rgbRefl2SpectWhite, rgb[0]);
                    if (rgb[1] <= rgb[2])
                    {
                        r.MAdd(ref SampledSpectrum.rgbRefl2SpectCyan, (rgb[1] - rgb[0]));
                        r.MAdd(ref SampledSpectrum.rgbRefl2SpectBlue, (rgb[2] - rgb[1]));
                        //r += (rgb[1] - rgb[0]) * rgbRefl2SpectCyan;
                        //r += (rgb[2] - rgb[1]) * rgbRefl2SpectBlue;
                    }
                    else
                    {
                        //r += (rgb[2] - rgb[0]) * rgbRefl2SpectCyan;
                        //r += (rgb[1] - rgb[2]) * rgbRefl2SpectGreen;

                        r.MAdd(ref SampledSpectrum.rgbRefl2SpectCyan, (rgb[2] - rgb[0]));
                        r.MAdd(ref SampledSpectrum.rgbRefl2SpectGreen, (rgb[1] - rgb[2]));
                    }
                }
                else if (rgb[1] <= rgb[0] && rgb[1] <= rgb[2])
                {
                    // Compute reflectance _SampledSpectrum_ with _rgb[1]_ as minimum
                    //r += rgb[1] * rgbRefl2SpectWhite;
                    r.MAdd(ref SampledSpectrum.rgbRefl2SpectWhite, rgb[1]);

                    if (rgb[0] <= rgb[2])
                    {
                        //r += (rgb[0] - rgb[1]) * rgbRefl2SpectMagenta;
                        //r += (rgb[2] - rgb[0]) * rgbRefl2SpectBlue;

                        r.MAdd(ref  SampledSpectrum.rgbRefl2SpectMagenta, (rgb[0] - rgb[1]));
                        r.MAdd(ref  SampledSpectrum.rgbRefl2SpectBlue, (rgb[2] - rgb[0]));
                    }
                    else
                    {
                        //r += (rgb[2] - rgb[1]) * rgbRefl2SpectMagenta;
                        //r += (rgb[0] - rgb[2]) * rgbRefl2SpectRed;
                        r.MAdd(ref SampledSpectrum.rgbRefl2SpectMagenta, (rgb[2] - rgb[1]));
                        r.MAdd(ref SampledSpectrum.rgbRefl2SpectRed, (rgb[0] - rgb[2]));
                    }
                }
                else
                {
                    // Compute reflectance _SampledSpectrum_ with _rgb[2]_ as minimum
                    //r += rgb[2] * rgbRefl2SpectWhite;
                    r.MAdd(ref  SampledSpectrum.rgbRefl2SpectWhite, rgb[2]);

                    if (rgb[0] <= rgb[1])
                    {
                        //r += (rgb[0] - rgb[2]) * rgbRefl2SpectYellow;
                        //r += (rgb[1] - rgb[0]) * rgbRefl2SpectGreen;
                        r.MAdd(ref  SampledSpectrum.rgbRefl2SpectYellow, (rgb[0] - rgb[2]));
                        r.MAdd(ref  SampledSpectrum.rgbRefl2SpectGreen, (rgb[1] - rgb[0]));
                    }
                    else
                    {
                        //r += (rgb[1] - rgb[2]) * rgbRefl2SpectYellow;
                        //r += (rgb[0] - rgb[1]) * rgbRefl2SpectRed;

                        r.MAdd(ref SampledSpectrum.rgbRefl2SpectYellow, (rgb[1] - rgb[2]));
                        r.MAdd(ref SampledSpectrum.rgbRefl2SpectRed, (rgb[0] - rgb[1]));
                    }
                }
                r *= .94f;
            }
            else
            {
                // Convert illuminant spectrum to RGB
                if (rgb[0] <= rgb[1] && rgb[0] <= rgb[2])
                {
                    // Compute illuminant _SampledSpectrum_ with _rgb[0]_ as minimum
                    //r += rgb[0] * rgbIllum2SpectWhite;
                    r.MAdd(ref SampledSpectrum.rgbIllum2SpectWhite, rgb[0]);
                    if (rgb[1] <= rgb[2])
                    {
                        //r += (rgb[1] - rgb[0]) * rgbIllum2SpectCyan;
                        //r += (rgb[2] - rgb[1]) * rgbIllum2SpectBlue;
                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectCyan, (rgb[1] - rgb[0]));
                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectBlue, (rgb[2] - rgb[1]));

                    }
                    else
                    {
                        // r += (rgb[2] - rgb[0]) * rgbIllum2SpectCyan;
                        //r += (rgb[1] - rgb[2]) * rgbIllum2SpectGreen;

                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectCyan, (rgb[2] - rgb[0]));
                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectGreen, (rgb[1] - rgb[2]));
                    }
                }
                else if (rgb[1] <= rgb[0] && rgb[1] <= rgb[2])
                {
                    // Compute illuminant _SampledSpectrum_ with _rgb[1]_ as minimum
                    //r += rgb[1] * rgbIllum2SpectWhite;
                    r.MAdd(ref SampledSpectrum.rgbIllum2SpectWhite, rgb[1]);

                    if (rgb[0] <= rgb[2])
                    {
                        //r += (rgb[0] - rgb[1]) * rgbIllum2SpectMagenta;
                        //r += (rgb[2] - rgb[0]) * rgbIllum2SpectBlue;

                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectMagenta, (rgb[0] - rgb[1]));
                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectBlue, (rgb[2] - rgb[0]));
                    }
                    else
                    {
                        //r += (rgb[2] - rgb[1]) * rgbIllum2SpectMagenta;
                        //r += (rgb[0] - rgb[2]) * rgbIllum2SpectRed;

                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectMagenta, (rgb[2] - rgb[1]));
                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectRed, (rgb[0] - rgb[2]));
                    }
                }
                else
                {
                    // Compute illuminant _SampledSpectrum_ with _rgb[2]_ as minimum
                    //r += rgb[2] * rgbIllum2SpectWhite;
                    r.MAdd(ref SampledSpectrum.rgbIllum2SpectWhite, rgb[2]);

                    if (rgb[0] <= rgb[1])
                    {
                        //r += (rgb[0] - rgb[2]) * rgbIllum2SpectYellow;
                        //r += (rgb[1] - rgb[0]) * rgbIllum2SpectGreen;

                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectYellow, (rgb[0] - rgb[2]));
                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectGreen, (rgb[1] - rgb[0]));
                    }
                    else
                    {
                        //r += (rgb[1] - rgb[2]) * rgbIllum2SpectYellow;
                        //r += (rgb[0] - rgb[1]) * rgbIllum2SpectRed;

                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectYellow, (rgb[1] - rgb[2]));
                        r.MAdd(ref SampledSpectrum.rgbIllum2SpectRed, (rgb[0] - rgb[1]));
                    }
                }
                r *= .86445f;
            }
            r.ClampSelf();
            return r;
        }
 private void SampleEnvironment(ref Vector vector, out SampledSpectrum result)
 {
     result = ColorFactory.FromRgb(this.LightSampler.SampleEnvironment(-vector), SpectrumType.Illuminant);
 }
        private void SplatScatteringPoint(ScatteringPoint point, SampleBuffer sb)
        {
            switch (point.HitType)
            {
                case IntersectionType.Environment:
                    SampledSpectrum env;
                    this.SampleEnvironment(ref point.IncomingDirection, out env);
                    this.Radiance += Throughput * env;
                    break;
            }

        }
Beispiel #25
0
        static void Main(string[] args)
        {

            int itemCount = 1000;
            int iters = 100000;
            Random rand = new Random();
            int[] ints = Enumerable.Range(0, itemCount).Select(cc => rand.Next()).ToArray();
            HashSet<int> hs = new HashSet<int>(ints);
            List<int> lst = ints.ToList();
            bool contains = false;
            string result = string.Empty;
            result = PerformanceMeasurementController.Test(delegate
            {
                var index = rand.Next(0, itemCount - 1);
                contains = hs.Contains(index) != true;
            }, "HashSet search\r\n", iters);
            Console.WriteLine("Time "+result);

            result = PerformanceMeasurementController.Test(delegate
            {
                var index = rand.Next(0, itemCount - 1);
                contains = lst.BinarySearch(index) > 0;
            }, "List search\r\n", iters);
            Console.WriteLine("Time " + result);

            result = PerformanceMeasurementController.Test(delegate
            {
                var index = rand.Next(0, itemCount - 1);
                for (int j = 0; j < itemCount; j++)
                {
                    if (ints[j] == index)
                    {
                        contains = true;
                        break;
                    }
                }
            }, "Array enum search\r\n", iters);
            Console.WriteLine("Time " + result);

            return;

            IRandomProvider rp = new BaseQMCSequence();
            int i = 100;
            while (i!=0)
            {
                Console.WriteLine("{0}  {1:F6},  {2:F6},  {3:F6},  {4:F6}", i, rp.NextFloat(),rp.NextFloat(),rp.NextFloat(),rp.NextFloat());
                i--;
            }
            Console.WriteLine(rp.GetType().Name);
            return;
            /*
            RgbSpectrum c1 = new RgbSpectrum(0.5f, 0.7f, 1.55f);
            RgbSpectrum c2 = new RgbSpectrum(1.5f, 0.4f, 11f);
            RgbSpectrum c3 = new RgbSpectrum(0);

            
            SSE.MaddSse(ref c1, ref c2, 4f, ref c3);

            Console.WriteLine("SSE Version - {0}", c3);
            Console.WriteLine("CPU Version - {0}", (c1+c2)*4f);



            return;
            */

            v1();
            v1();
            v1();

            var res = new SampledSpectrum(1.9f);
            var rs = new SampledSpectrum(1.9f);

            var rgb_1 = ColorFactory.SSEToRgb(ref res);
            var rgb_2 = res.ToRgb();

            Console.WriteLine("SSE:{0} / Norm {1}", rgb_1, rgb_2);

            SSE.ClampSSE(ref res, ref rs);
            var maxIterations = 5;
            var testIterations = 1;
            var iterations = 100000000;
            var rnd = new FastRandom();

            var s1 = new SampledSpectrum(rnd.NextFloat());
            var s2 = new SampledSpectrum(rnd.NextFloat());
            var s3 = SampledSpectrum.UnitSpectrum();
            RgbSpectrum r3;
            float rx = 0f;
            float[][] rgb = Enumerable.Repeat(new[] {rnd.NextFloat(), rnd.NextFloat(), rnd.NextFloat()}, 1000).ToArray();

            var testActions = new[]
                {
                    //new Tuple<string, Action>("Spectral mul cpu", () =>
                    //{
                    //    s3 = s1*s2;
                    //}),

                    //new Tuple<string, Action>("Spectral mul sse", () =>
                    //{
                    //    SSE.MulSSE(ref s1, ref s2, ref s3);
                    //}),

                    new Tuple<string, Action>("Dot SSE", () =>
                    {
                        rx = SSE.Dot(ref s1, ref s2);
                    }),

                    new Tuple<string, Action>("Dot avx", () =>
                    {
                        rx = AVX.Dot(ref s1, ref s2);
                    }),

                    /*
                    new Tuple<string, Action>("to Rgb  cpu", () =>
                    {
                        r3 = s1.ToRgb();
                    }),

                    new Tuple<string, Action>("to Rgb  sse", () =>
                    {
                        r3 = ColorFactory.SSEToRgb(ref s1);
                    }),*/

                    //new Tuple<string, Action>("Rgb madd cpu", () =>
                    //{
                    //    var r1 = new RgbSpectrum(rnd.NextFloat());
                    //    var r2 = new RgbSpectrum(rnd.NextFloat());
                    //    var r4 = new RgbSpectrum(rnd.NextFloat());

                    //    r3 = (r1 + r2+r4+r1) * (1f / 3f);

                    //    //SSE.MaddSse(ref r1, ref c2, 4f, ref c3);

                    //}), 

                    //new Tuple<string, Action>("Rgb madd sse", () =>
                    //{
                    //    var r1 = new RgbSpectrum(rnd.NextFloat());
                    //    var r2 = new RgbSpectrum(rnd.NextFloat());
                    //    var r4 = new RgbSpectrum(rnd.NextFloat());


                    //    SSE.AverageSSE(ref r1, ref r2, ref r4,ref r1, ref r3);

                    //}), 

                    /*
                    new Tuple<string, Action>    (" SSE to rgb ", () =>
                        {
                            foreach (var f in rgb)
                            {
                                ColorFactory.SSEFromRgb(f, SpectrumType.Illuminant);
                                
                            }
                        }),
                         new Tuple<string, Action>    (" AVX to rgb ", () =>
                        {
                            foreach (var f in rgb)
                            {
                                ColorFactory.AVXFromRgb(f, SpectrumType.Illuminant);
                            }
                        }),
                        new Tuple<string, Action>(" CPU to rgb ", () =>
                        {
                            foreach (var f in rgb)
                            {
                                ColorFactory.BaseFromRgb(f, SpectrumType.Illuminant);

                            }
                        }),
                     */ 
/*

                          new Tuple<string, Action>    (" Normal sqrt ", () =>
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                var f = rnd.NextFloat();
                                res[0] = MathLab.Sqrt(f);
                            }
                        }),
                        new Tuple<string, Action>(" SSE sqrt    ", () =>
                        {
                            SSE. VSqrt();
                        }),*/
                        /*
                    new Tuple<string, Action>("Current NextFloat :",  () =>
                        {
                            var rnd = new FastRandom();
                            rnd.NextFloat();
                            for (var i = 0; i < iterations; i++)
                            {
                                rnd.NextFloat();
                            }
                        }),
                    new Tuple<string, Action>("Halton : ",  () =>
                        {
                            var qmc = new HaltonSequence();
                            for (var i = 0; i < iterations; i++)
                            {
                                //rnd.NextDouble();
                                qmc.NextFloat();
                            }
                        }),
                    new Tuple<string, Action>("VanDerCorrupt : ",  () =>
                        {
                            var qmc = new BaseQMCSequence();
                            for (var i = 0; i < iterations; i++)
                            {
                                //rnd.NextDouble();
                                qmc.NextFloat();
                            }
                        }),*/

                };
        @test:

            Console.WriteLine("Converting 1000 float triplets to SampledSpectrum");
            Console.WriteLine("Running test for {0} iterations per test . {1} test iteration", iterations, testIterations);
            //TestExpressions();
            foreach (var testAction in testActions)
            {
                Tuple<string, Action> action = testAction;
                Console.WriteLine(PerformanceMeasurementController.Test(() => action.Item2(), 8,testAction.Item1, iterations));
            }
            testIterations++;
            if (testIterations > maxIterations)
                return;
            goto @test;


            /*
            QualitySettingsInfo qs = new QualitySettingsInfo() { SamplesPerPixel = 32, ShadowRaysPerLight = 1, TextureSamplingQuality = TextureSamplingQuality.Linear, SuperSamplingSize = 1 };
            OutputSettingsInfo os = new OutputSettingsInfo() { FilePath = @"G:\Git", Width = 640, Height = 480, GammaCorrection = true, BitsPerPixel = 32, ToneMap = false, ToneMapValue = 1.5f };

            var qs_s = SerializationService.Serialize(qs, typeof(QualitySettingsInfo), typeof(TextureSamplingQuality));
            var os_s = SerializationService.Serialize(os, typeof(OutputSettingsInfo));
            Console.WriteLine(qs_s);
            Console.WriteLine(os_s);*/

            /*
            var f = new [] {0.25f, 0.15f, 0.15f, 0.45f};
            float[] cdf = new float[f.Length+1];
            float c;
            MC.ComputeStep1dCDF(f, 4, cdf, out c);
            Console.WriteLine();
            return;
           */
            //CreateFrame(@"F:\Dev\Frames\RDF\", "cornell_service", @"F:\Dev\Scenes\OasisCornell\");
            //CreateFrame(@"F:\Dev\Frames\RDF\", "decostreet", @"F:\3D\Models\decostreet\");
            //            CreateFrame(@"F:\Dev\Frames\RDF\", "tmp", @"F:\3D\Models\decostreet\");
            /*
            GlobalConfiguration.Instance.OpenConfig(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Global.Config.xml");
            GlobalConfiguration.Instance.Add("TextureFindPaths", new string[3] { @"C:\Dev\", @"F:\3d\HDRi\", @"F:\3d\Textures\" });
            GlobalConfiguration.Instance.SaveConfig(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Global.Config.xml");


            //CreateFrame(@"F:\Dev\Frames\CompressedDataFrames\DecoStreet\", "decostreet", @"F:\Dev\Frames\CompressedDataFrames\DecoStreet\");
            return;
            //
            //CreateFrame(@"F:\Dev\Frames\RDF\", "cornell_service");
            using (var frame = ArchiveFrameService.OpenArchive(@"F:\Dev\Frames\CompressedDataFrames\OasisCornell\OasisCornell.cdf",
                                                @"F:\Temp\RayDenTemp\OasisCornell"))
                Console.WriteLine("Frame opened {0}", frame.Frame.FrameName);
             * */
        }
Beispiel #26
0
 public Radiance(float f)
 {
     spectra = new SampledSpectrum(f);
 }
Beispiel #27
0
 public SphereAreaLight(FrameLightsource frameLight)
 {
     this.Radius = 6f;
     this.Position = (Point)frameLight.Parameters.Get<Vector>(FrameLightsource.PointLightPosition);
     this.Power = frameLight.Parameters.Get<RgbSpectrum>(FrameLightsource.LightsourcePower) * 2.5f;
     this.Spectra = SPD_Data.FromSampled(SPD_Data.Al_k, SpectrumType.Illuminant);
     //new SampledSpectrum(ref this.Power, SpectrumType.Illuminant);
 }
Beispiel #28
0
 public Radiance(ref RgbSpectrum s, SpectrumType t)
 {
     spectra = new SampledSpectrum(ref s, t);
 }
Beispiel #29
0
 public Radiance Add(float f)
 {
     spectra = spectra + f;
     return this;
 }
Beispiel #30
0
        public static SampledSpectrum FromRgb(ref RgbSpectrumInfo rgb, SpectrumType type = SpectrumType.Reflectance)
        {
            var r = new SampledSpectrum(0f);
            if (type == SpectrumType.Reflectance)
            {
                // Convert reflectance spectrum to RGB
                if (rgb.c1 <= rgb.c2 && rgb.c1 <= rgb.c3)
                {
                    // Compute reflectance _SampledSpectrum_ with _rgb.c1_ as minimum
                    //r += rgb.c1 * rgbRefl2SpectWhite;
                    SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectWhite, rgb.c1, ref r);

                    //SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectWhite, rgb.c1);
                    if (rgb.c2 <= rgb.c3)
                    {
                        SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectCyan, (rgb.c2 - rgb.c1), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectBlue, (rgb.c3 - rgb.c2), ref r);
                        //r += (rgb.c2 - rgb.c1) * rgbRefl2SpectCyan;
                        //r += (rgb.c3 - rgb.c2) * rgbRefl2SpectBlue;
                    }
                    else
                    {
                        //r += (rgb.c3 - rgb.c1) * rgbRefl2SpectCyan;
                        //r += (rgb.c2 - rgb.c3) * rgbRefl2SpectGreen;

                        SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectCyan, (rgb.c3 - rgb.c1), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectGreen, (rgb.c2 - rgb.c3), ref r);
                    }
                }
                else if (rgb.c2 <= rgb.c1 && rgb.c2 <= rgb.c3)
                {
                    // Compute reflectance _SampledSpectrum_ with _rgb.c2_ as minimum
                    //r += rgb.c2 * rgbRefl2SpectWhite;
                    SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectWhite, rgb.c2, ref r);

                    if (rgb.c1 <= rgb.c3)
                    {
                        //r += (rgb.c1 - rgb.c2) * rgbRefl2SpectMagenta;
                        //r += (rgb.c3 - rgb.c1) * rgbRefl2SpectBlue;

                        SSE.MAddSSE(ref  SampledSpectrum.rgbRefl2SpectMagenta, (rgb.c1 - rgb.c2), ref r);
                        SSE.MAddSSE(ref  SampledSpectrum.rgbRefl2SpectBlue, (rgb.c3 - rgb.c1), ref r);
                    }
                    else
                    {
                        //r += (rgb.c3 - rgb.c2) * rgbRefl2SpectMagenta;
                        //r += (rgb.c1 - rgb.c3) * rgbRefl2SpectRed;
                        SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectMagenta, (rgb.c3 - rgb.c2), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectRed, (rgb.c1 - rgb.c3), ref r);
                    }
                }
                else
                {
                    // Compute reflectance _SampledSpectrum_ with _rgb.c3_ as minimum
                    //r += rgb.c3 * rgbRefl2SpectWhite;
                    SSE.MAddSSE(ref  SampledSpectrum.rgbRefl2SpectWhite, rgb.c3, ref r);

                    if (rgb.c1 <= rgb.c2)
                    {
                        //r += (rgb.c1 - rgb.c3) * rgbRefl2SpectYellow;
                        //r += (rgb.c2 - rgb.c1) * rgbRefl2SpectGreen;
                        SSE.MAddSSE(ref  SampledSpectrum.rgbRefl2SpectYellow, (rgb.c1 - rgb.c3), ref r);
                        SSE.MAddSSE(ref  SampledSpectrum.rgbRefl2SpectGreen, (rgb.c2 - rgb.c1), ref r);
                    }
                    else
                    {
                        //r += (rgb.c2 - rgb.c3) * rgbRefl2SpectYellow;
                        //r += (rgb.c1 - rgb.c2) * rgbRefl2SpectRed;

                        SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectYellow, (rgb.c2 - rgb.c3), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbRefl2SpectRed, (rgb.c1 - rgb.c2), ref r);
                    }
                }
                SSE.MulSSE(ref r, .94f, ref r);

                //r *= .94f;
            }
            else
            {
                // Convert illuminant spectrum to RGB
                if (rgb.c1 <= rgb.c2 && rgb.c1 <= rgb.c3)
                {
                    // Compute illuminant _SampledSpectrum_ with _rgb.c1_ as minimum
                    //r += rgb.c1 * rgbIllum2SpectWhite;
                    SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectWhite, rgb.c1, ref r);
                    if (rgb.c2 <= rgb.c3)
                    {
                        //r += (rgb.c2 - rgb.c1) * rgbIllum2SpectCyan;
                        //r += (rgb.c3 - rgb.c2) * rgbIllum2SpectBlue;
                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectCyan, (rgb.c2 - rgb.c1), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectBlue, (rgb.c3 - rgb.c2), ref r);

                    }
                    else
                    {
                        // r += (rgb.c3 - rgb.c1) * rgbIllum2SpectCyan;
                        //r += (rgb.c2 - rgb.c3) * rgbIllum2SpectGreen;

                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectCyan, (rgb.c3 - rgb.c1), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectGreen, (rgb.c2 - rgb.c3), ref r);
                    }
                }
                else if (rgb.c2 <= rgb.c1 && rgb.c2 <= rgb.c3)
                {
                    // Compute illuminant _SampledSpectrum_ with _rgb.c2_ as minimum
                    //r += rgb.c2 * rgbIllum2SpectWhite;
                    SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectWhite, rgb.c2, ref r);

                    if (rgb.c1 <= rgb.c3)
                    {
                        //r += (rgb.c1 - rgb.c2) * rgbIllum2SpectMagenta;
                        //r += (rgb.c3 - rgb.c1) * rgbIllum2SpectBlue;

                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectMagenta, (rgb.c1 - rgb.c2), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectBlue, (rgb.c3 - rgb.c1), ref r);
                    }
                    else
                    {
                        //r += (rgb.c3 - rgb.c2) * rgbIllum2SpectMagenta;
                        //r += (rgb.c1 - rgb.c3) * rgbIllum2SpectRed;

                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectMagenta, (rgb.c3 - rgb.c2), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectRed, (rgb.c1 - rgb.c3), ref r);
                    }
                }
                else
                {
                    // Compute illuminant _SampledSpectrum_ with _rgb.c3_ as minimum
                    //r += rgb.c3 * rgbIllum2SpectWhite;
                    SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectWhite, rgb.c3, ref r);

                    if (rgb.c1 <= rgb.c2)
                    {
                        //r += (rgb.c1 - rgb.c3) * rgbIllum2SpectYellow;
                        //r += (rgb.c2 - rgb.c1) * rgbIllum2SpectGreen;

                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectYellow, (rgb.c1 - rgb.c3), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectGreen, (rgb.c2 - rgb.c1), ref r);
                    }
                    else
                    {
                        //r += (rgb.c2 - rgb.c3) * rgbIllum2SpectYellow;
                        //r += (rgb.c1 - rgb.c2) * rgbIllum2SpectRed;

                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectYellow, (rgb.c2 - rgb.c3), ref r);
                        SSE.MAddSSE(ref SampledSpectrum.rgbIllum2SpectRed, (rgb.c1 - rgb.c2), ref r);
                    }
                }
                SSE.MulSSE(ref r, .86445f, ref r);
                //r *= .86445f;
            }
            //SSE.ClampSSE(ref r, ref r);
            //r.ClampSelf();
            return r;
        }