当前位置: 首页>>代码示例>>C#>>正文


C# Primitives.RgbSpectrum类代码示例

本文整理汇总了C#中RayDen.Library.Core.Primitives.RgbSpectrum的典型用法代码示例。如果您正苦于以下问题:C# RgbSpectrum类的具体用法?C# RgbSpectrum怎么用?C# RgbSpectrum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RgbSpectrum类属于RayDen.Library.Core.Primitives命名空间,在下文中一共展示了RgbSpectrum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitPath

        public override void InitPath(IPathProcessor buffer)
        {
            base.InitPath(buffer);
            MaxRaysPerPath = 1;
            this.scene = pathIntegrator.Scene;
            var pssSampler = (PsMltSampler)this.pathIntegrator.Sampler;

            this.Radiance = new RgbSpectrum(0f);
            this.Throughput = new RgbSpectrum(1f);
            if (this.Sample == null || this.Sample.LargeStep || pssSampler.BurnInPhase ||this.Sample.MutationsCount > (pssSampler.MaxMutations))
            {
                this.Sample = (PsSample)pssSampler.GetSample(this.Sample);
            }
            else
            {
                this.Sample.imageX = MC.Mutate(this.Sample.imageX, pssSampler.NextFloat(), pssSampler.NextFloat(),2.0f/(2000),0.1f);
                this.Sample.imageY = MC.Mutate(this.Sample.imageY, pssSampler.NextFloat(), pssSampler.NextFloat(), 2.0f / (2000), 0.1f);
                pssSampler.TotalSamples++;
            }
            IRay ray;
            pathIntegrator.Scene.Camera.GetRay(Sample.imageX, Sample.imageY, out ray);
            this.PathRay = (RayData)ray;
            this.RayIndex = -1;
            this.pathWeight = 1.0f;
            this.tracedShadowRayCount = 0;
            this.depth = 0;
            this.specularBounce = true;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:28,代码来源:PssPathSampler.cs

示例2: InitPath

        public override void InitPath(IPathProcessor buffer)
        {
            base.InitPath(buffer);
            this.scene = pathIntegrator.Scene;
            this.PathState = PathTracerPathState.EyeVertex;
            if (this.secRays == null)
                this.secRays = new ConnectRayInfo[MaxEyeRays];
            this.RayIndex = -1;
            this.pathWeight = 1.0f;
            this.tracedShadowRayCount = 0;
            this.depth = 0;
            this.specularBounce = true;
            this.Radiance = new RgbSpectrum(0f);

            this.Sample = pathIntegrator.Sampler.GetSample(null);
            LightSample ls;
            var light = scene.Lights[scene.SampleLights(Sample.GetLazyValue())];
            light.EvaluatePhoton(scene, Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), out ls);
            PathRay = ls.LightRay;
            var lightPdf = ls.Pdf;
            Throughput = (RgbSpectrum)(ls.Spectrum);
            //* scene.Lights.Length) / lightPdf;

            //buffer.Scene.Camera.GetRay(Sample.imageX, Sample.imageY, out this.PathRay);
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:25,代码来源:LightTracerPathSampler.cs

示例3: CanonicalGlassMaterial

 public CanonicalGlassMaterial(RgbSpectrum r, RgbSpectrum s, MediumInfo m)
 {
     Kr = r;
     Kt = s;
     Medium = m;
     fresnel = new FresnelDielectric(1f, m.IoR);
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:CanonicalGlassMaterial.cs

示例4: MeshLight

 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);
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:MeshLight.cs

示例5: f

 public override void f(ref Vector WO, ref Vector WI, ref Normal N, ref RgbSpectrum in_fs, out RgbSpectrum fs)
 {
     CreateFrame(ref N);
     var lwo = WorldToLocal(ref WO);
     var lwi = WorldToLocal(ref WI);
     EvalBrdf(out fs, ref lwo, ref lwi);
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:RegularHalfangleBRDF.cs

示例6: EvalBrdf

        private void EvalBrdf(out RgbSpectrum fs,ref  Vector wo, ref Vector wi)
        {

            Vector wh = wo + wi;

            if (wh.z < 0f)
            {
                wo = -wo;
                wi = -wi;
                wh = -wh;
            }
            if (wh.x.NearZero() && wh.y.NearZero() && wh.z.NearZero())
            {
                fs = RgbSpectrum.ZeroSpectrum();
                return;
            }
            wh = Vector.Normalize(wh);
            float whTheta = SphericalTheta(ref wh);
            float whCosPhi = CosPhi(ref wh), whSinPhi = SinPhi(ref wh);
            float whCosTheta = CosTheta(ref wh), whSinTheta = SinTheta(ref wh);
            Vector whx = new Vector(whCosPhi*whCosTheta, whSinPhi*whCosTheta, -whSinTheta);
            Vector why = new Vector(-whSinPhi, whCosPhi, 0);
            Vector wd = new Vector(Vector.Dot(ref wi, ref whx), Vector.Dot(ref wi, ref why), Vector.Dot(ref wi, ref wh));

            // Compute _index_ into measured BRDF tables
            float wdTheta = SphericalTheta(ref wd), wdPhi = SphericalPhi(ref wd);
            if (wdPhi > MathLab.M_PI) wdPhi -= MathLab.M_PI;

            // Compute indices _whThetaIndex_, _wdThetaIndex_, _wdPhiIndex_
            int whThetaIndex = REMAP(MathLab.Sqrt(Math.Max(0f, whTheta/(MathLab.M_PI/2f))),
                                     1f, nThetaH);
            int wdThetaIndex = REMAP(wdTheta, MathLab.M_PI/2f, nThetaD);
            int wdPhiIndex = REMAP(wdPhi, MathLab.M_PI, nPhiD);
            int index = wdPhiIndex + nPhiD*(wdThetaIndex + whThetaIndex*nThetaD);

            //try {

                /*int rIndex = index;
                int gIndex = index + 1;
                int bIndex = index + 2;*/
                
                int rIndex = index;
                int gIndex = index + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D/2;
                int bIndex = index + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D;
                
                /*
                int rIndex = 3*index;
                int gIndex = 3*index + 1;//BRDF_SAMPLING_RES_THETA_H * BRDF_SAMPLING_RES_THETA_D * BRDF_SAMPLING_RES_PHI_D / 2;
                int bIndex = 3*index + 2;//BRDF_SAMPLING_RES_THETA_H * BRDF_SAMPLING_RES_THETA_D * BRDF_SAMPLING_RES_PHI_D;
                */
                fs = new RgbSpectrum((float) (brdf[Math.Min(rIndex, brdf.Length-1)]*RED_SCALE),
                                     (float) (brdf[Math.Min(gIndex, brdf.Length-1)]*GREEN_SCALE),
                                     (float) (brdf[Math.Min(bIndex, brdf.Length-1)]*BLUE_SCALE));
                /*
            }
            catch (IndexOutOfRangeException ex)
            {
                fs = new RgbSpectrum(0f);
            }*/
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:60,代码来源:RegularHalfangleBRDF.cs

示例7: InitPath

        public override void InitPath(IPathProcessor buffer)
        {
            base.InitPath(buffer);
            this.scene = pathIntegrator.Scene;

            this.Radiance = new RgbSpectrum(0f);
            this.PathState = BDPTSamplerState.InitPath;
            if (this.connectRays == null)
                this.connectRays = new ConnectRayInfo[scene.MaxPathDepth * scene.MaxPathDepth];
            lightPath = new VertexInfo[MaxLightDepth];
            this.Sample = pathIntegrator.Sampler.GetSample(null);
            lightVertices = 0;

            //Init eye ray
            this.EyeThroughput = new RgbSpectrum(1f);
            pathIntegrator.Scene.Camera.GetRay(Sample.imageX, Sample.imageY, out this.PathRay);
            this.RayIndex = -1;
            this.LightRayIndex = -1;
            this.eyePdf = 1f;

            //Init light path
            LightSample ls;
            var light = scene.Lights[scene.SampleLights(Sample.GetLazyValue())];
            light.EvaluatePhoton(scene, Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), out ls);
            LightRay = ls.LightRay;
            lightPdf = ls.Pdf * (1f / scene.Lights.Length);
            LightThroughput = (RgbSpectrum)(ls.Spectrum);


            this.tracedConnectRayCount = 0;
            this.eyeDepth = 0;
            this.lightDepth = 0;
            this.eyeStop = false;
            this.lightStop = false;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:35,代码来源:BDPathSampler.cs

示例8: Photon

        public Photon(ref Point pt, ref Vector dir, ref RgbSpectrum power)
        {
            var dirx = MathLab.Clamp(dir.z, -1f, 1f);

            int theta = Convert.ToInt32(Math.Acos(dirx) * (256.0d / Math.PI));
            if (theta > 255)
                theta = 255;

            Theta = (byte)theta;

            int phi = Convert.ToInt32(Math.Atan2(dir.y, dir.x) * (256.0d / 2.0 * Math.PI));


            if (phi > 255)
                phi = 255;
            else

                if (phi < 0)
                    phi = phi + 256;

            Phi = (byte)phi;
            Position = pt;
            Power = power;
            Plane = 0;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:25,代码来源:Photon.cs

示例9: SphereAreaLight

 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);
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:SphereAreaLight.cs

示例10: Sample_f

        public override void Sample_f(ref Vector wo, ref Normal N, ref Normal shadeN, ref RgbSpectrum in_f, float u0, float u1, float u2, ref SurfaceTextureData surfaceData, out BsdfSampleData result)
        {
            result.Lambda = 0f;

            Vector dir =
                MC.CosineSampleHemisphere(u0, u1);
            result.Pdf = dir.z * MathLab.INVPI;
            result.Type = BrdfType.Diffuse;
            Vector v1, v2;
            Normal n = N;
            Vector.CoordinateSystem(ref n, out v1, out v2);

            dir = new Vector(
                v1.x * dir.x + v2.x * dir.y + n.x * dir.z,
                v1.y * dir.x + v2.y * dir.y + n.y * dir.z,
                v1.z * dir.x + v2.z * dir.y + n.z * dir.z);

            var wi = dir;

            float dp = (Normal.Dot(ref shadeN, ref wi));
            if (dp <= 0.01f)
            {
                result.Pdf = 0f;
                result.F = new RgbSpectrum();
            }
            else
            {
                result.Pdf /= dp;
                result.F = surfaceData.Diffuse*MathLab.INVPI;
            }
            result.Wi = wi;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:32,代码来源:MatteMaterial.cs

示例11: InitPath

        public override void InitPath(IPathProcessor buffer)
        {
            base.InitPath(buffer);
            scene = pathIntegrator.Scene;

            this.Sample = new Sample(pathIntegrator.Sampler);
            this.RayIndex = -1;
            float lspdf;

            int li = scene.SampleLights(this.Sample.GetLazyValue(), out lspdf);
            var ls = new LightSample();
            bool done = false;
            while (!done)
            {
                scene.Lights[li].EvaluatePhoton(
                    scene,
                    Sample.GetLazyValue(),
                    Sample.GetLazyValue(),
                    Sample.GetLazyValue(),
                    Sample.GetLazyValue(),
                    Sample.GetLazyValue(),
                    out ls);

                done = ls.Pdf > 0f;

            }

            var pathWeight =  (ls.Pdf *  lspdf);

            this.ThroughtPut = ((RgbSpectrum)(ls.Spectrum) / pathWeight);
            this.PathRay = ls.LightRay;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:32,代码来源:PPMPhotonPath.cs

示例12: Sample_f

        public override void Sample_f(ref Vector wo, ref Normal N, ref Normal shadeN, ref RgbSpectrum in_f, float u0, float u1, float u2, ref SurfaceTextureData surfaceData, out BsdfSampleData result) {
            EvalParams(ref surfaceData);

            bool into = (Normal.Dot(ref N, ref shadeN) > 0f);
            result = new BsdfSampleData();
            result.Type = this.Type;

            if (!into) {
                // No internal reflections
                result.Wi = (-wo);
                result.Pdf = 1f;
                result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
                result.F =  Krefl;
            }
            else {
                // RR to choose if reflect the ray or go trough the glass
                float comp = u0 * totFilter;
                if (comp > transFilter) {
                    Vector mwo = -wo;
                    result.Wi = mwo - (2f * Vector.Dot(ref N, ref mwo)) * N.ToVec();
                    result.Pdf = reflPdf;
                    result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
                    result.F = Krefrct;
                }
                else {
                    result.Wi = -wo;
                    result.Pdf = transPdf;
                    result.F = Krefrct;
                    result.Type = transmitionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
                }
            }

        }
开发者ID:HungryBear,项目名称:rayden,代码行数:33,代码来源:ArchGlassMaterial.cs

示例13: InitPath

 public override void InitPath(IPathProcessor buffer)
 {
     base.InitPath(buffer);
     this.scene = pathIntegrator.Scene;
     this.Radiance = new RgbSpectrum(0f);
     this.Throughput = new RgbSpectrum(1f);
     this.PathState = PathTracerPathState.EyeVertex;
     if (this.secRays == null)
         this.secRays = new ShadowRayInfo[scene.ShadowRayCount];
     if (this.volumeComp == null)
     {
         this.volumeComp = scene.GetVolumeComputation();
     }
     else
     {
         this.volumeComp.Reset();
     }
     this.Sample = pathIntegrator.Sampler.GetSample(null);
     IRay ray;
     pathIntegrator.Scene.Camera.GetRay(Sample.imageX, Sample.imageY, out ray);
     this.PathRay = (RayData)ray;
     this.RayIndex = -1;
     this.pathWeight = 1.0f;
     this.tracedShadowRayCount = 0;
     this.depth = 0;
     this.specularBounce = true;
     this.rayID = (int)(Sample.imageX + Sample.imageY * 640f);
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:28,代码来源:VolumePathTracerPath.cs

示例14: InitPath

        public override void InitPath(IPathProcessor buffer)
        {
            //Choose lightsource
            //Sample it
            base.InitPath(buffer);
            this.Sample = new Sample(pathIntegrator.Sampler);
            this.RayIndex = -1;
            float lspdf;

            int li = scene.SampleLights(this.Sample.GetLazyValue(), out lspdf);
            RayData ray;

            var ls = new LightSample();
            bool done = false;
            while (!done)
            {
                scene.Lights[li].EvaluatePhoton(
                    scene,
                    Sample.GetLazyValue(),
                    Sample.GetLazyValue(),
                    Sample.GetLazyValue(),
                    Sample.GetLazyValue(),
                    Sample.GetLazyValue(),
                    out ls);

                done = ls.Pdf > 0f;

            }

            this.pathWeight = 10000 /(ls.Pdf * lspdf);
            ls.Spectrum.Mul(pathWeight);
            this.ThroughtPut = new RgbSpectrum(ls.Spectrum.ToArray());
            this.PathRay = ls.LightRay;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:34,代码来源:PPMLightPath.cs

示例15: FrDiel

        public static RgbSpectrum FrDiel(float coso, float cost, RgbSpectrum etao, RgbSpectrum etat)
        {
            RgbSpectrum Rparl = ((etat * coso) - (etao * cost)) / ((etat * coso) + (etao * cost));
            RgbSpectrum Rperp = ((etao * coso) - (etat * cost)) / ((etao * coso) + (etat * cost));

            return (Rparl * Rparl + Rperp * Rperp) / 2f;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:BxDF.cs


注:本文中的RayDen.Library.Core.Primitives.RgbSpectrum类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。