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


C# Sample.GetLazyValue方法代码示例

本文整理汇总了C#中Sample.GetLazyValue方法的典型用法代码示例。如果您正苦于以下问题:C# Sample.GetLazyValue方法的具体用法?C# Sample.GetLazyValue怎么用?C# Sample.GetLazyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sample的用法示例。


在下文中一共展示了Sample.GetLazyValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSample

        public Sample GetSample(Sample prevSample = null)
        {
            totalSamples++;

            if (prevSample == null)
            {
                var ns = new PsSample(this);

                ns.imageX = ns.GetLazyValue() * screenWidth;
                ns.imageY = ns.GetLazyValue() * screenHeight;
                ns.pass = pass;
                return ns;
            }
            prevSample.imageX = prevSample.GetLazyValue() * screenWidth;
            prevSample.imageY = prevSample.GetLazyValue() * screenHeight;
            
            prevSample.pass = pass;
            (prevSample as PsSample).MutationsCount = 0;
            (prevSample as PsSample).CurrentDim = 0;
            (prevSample as PsSample).MaxDimPrev = 0;

            return prevSample;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:23,代码来源:PsMltSampler.cs

示例2: GetLazyValue

 public float GetLazyValue(Sample sample)
 {
     return sample.GetLazyValue(pass);
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:4,代码来源:MCMCSampler.cs

示例3: GetSample

        public Sample GetSample(Sample prevSample)
        {

            TotalSamples++;

            if (!warmUpcomplete)
            {
                var wmsample = new Sample(this);
                var rx = wmsample.GetLazyValue();
                var ry = wmsample.GetLazyValue();
                wmsample.imageX = rx * screenWidth;
                wmsample.imageY = ry * screenHeight;


                warmUpcomplete = TotalSamples >= screenWidth * screenHeight * WarmupPasses;

                return wmsample;
            }
#if VERBOSE
            if (TotalSamples == screenWidth * screenHeight * WarmupPasses+1)
            {
                Tracer.TraceLine("T{0} Warmup complete", tIdx);
                var sampleBlocks = new HashSet<SampleBlock>();
                foreach (var sampleBlock in blocks)
                {
                    if (!sampleBlocks.Contains(sampleBlock) && (sampleBlock.BlockError(Film) > ErrorStop))
                    {
                        sampleBlock.CachedError = sampleBlock.BlockError(Film);
                        sampleBlocks.Add(sampleBlock);
                    }
                }

                this.blocks = sampleBlocks.ToList();
                Tracer.TraceLine("T{0} duplicate removal complete", tIdx);

                Classify(blocks);
                Tracer.TraceLine("T{0} classification complete", tIdx);

            }
#endif
            CurrentBlock.TotalSamples++;


            if (blocks.Count == 0)
            {
                this.Init(Width, Height);
                Tracer.TraceLine("Adaptive sampling complete! Start another iteration");
                return null;
            }
            currentBlockSample++;

            if (currentBlockSample >= CurrentBlock.SamplesInBlock(ImportantBlockSamples))
            {
                blockIndex++;
                currentBlockSample= 0;
            }

            if (blockIndex >= blocks.Count)
            {
                blockIndex = Math.Min(tIdx, blocks.Count - 1);
            }
            CurrentBlock = blocks[blockIndex];
            if (CurrentBlock.TotalSamples >= CurrentBlock.SamplesPerIteration * CurrentBlock.BlockWidth * CurrentBlock.BlockHeight)
            {
                var blockError = CurrentBlock.BlockError(this.Film);

                if (blockError > ErrorSplit)
                {
                    this.SplitBlock(CurrentBlock);
                }
                else if (blockError < ErrorStop)
                {
#if VERBOSE
                    Tracer.TraceLine("{0} Block is ready", blockIndex);
                    Tracer.TraceLine("Rem block {0} block error {1} ", blocks[blockIndex].ToString(), blockError,
                                     blocks[blockIndex].BlockWidth, blocks[blockIndex].BlockHeight);
#endif
                    this.TotalSamples += this.CurrentBlock.SamplerPerBlock;
#if VERBOSE
                    Tracer.TraceLine("Block Count " + blocks.Count);
#endif
                }
                else if (subBlocks.Count < 65535)
                {

                    foreach (var block in blocks)
                    {
                        var proposalB = block.Split(block.SamplesPerIteration);
                        foreach (var proposalBlock in proposalB)
                        {
                            if (proposalBlock.BlockError(Film) > block.BlockError(Film))
                            {
                                //this.blocks.AddRange(proposalBlock.Split(CurrentBlock.SamplesPerIteration));
                                subBlocks.Add(proposalBlock);
                            }
                            else
                            {
                                //this.blocks.Add(proposalBlock);
                                //this.blocks.AddRange(proposalBlock.Split(proposalBlock.SamplesPerIteration * 2));
                                subBlocks.AddRange(proposalBlock.Split(proposalBlock.SamplesPerIteration));
//.........这里部分代码省略.........
开发者ID:HungryBear,项目名称:rayden,代码行数:101,代码来源:AdaptiveBlockSampler.cs

示例4: GenerateLiRays

        public override void GenerateLiRays(IRayEngineScene scn, Sample sample, ref RayData ray, VolumeComputation comp)
        {
            comp.Reset();
            var scene = (RayEngineScene)(scn);

            var sigs = sig_s;
            comp.EmittedLight = lightEmission;
            float t0, t1;
            if (!region.Intersect(ray, out t0, out t1))
                return;

            if (sigs.IsBlack() || (scene.Lights.Length < 1))
            {
                float distance = t1 - t0;
                comp.EmittedLight = lightEmission * distance;
            }
            else
            {
                // Prepare for volume integration stepping
                float distance = t1 - t0;
                var nSamples = MathLab.Ceil2UInt(distance / stepSize);

                float step = distance / nSamples;
                RgbSpectrum Tr = new RgbSpectrum(1f);
                RgbSpectrum Lv = new RgbSpectrum();
                var p = ray.Point(t0);
                float offset = sample.GetLazyValue();
                t0 += offset * step;

                //Vector pPrev;
                for (var i = 0; i < nSamples; ++i, t0 += step)
                {
                    //pPrev = p;
                    p = ray.Point(t0);
                    Sigma_s(ref p, out sigs);
                    //sigs = NoiseProvider.Instance.Noise3D(((Vector)p).Normalize());
                    Lv += lightEmission;
                    if (!sigs.IsBlack() && (scene.Lights.Length) > 0)
                    {
                        // Select the light to sample
                        float lightStrategyPdf;
                        var light = scene.Lights[scene.SampleLights(sample.GetLazyValue(), out lightStrategyPdf)];

                        // Select a point on the light surface
                        float lightPdf;
                        Normal fakeNorml = new Normal(0f, 0f, 1f);
                        LightSample ls = new LightSample();
                        light.EvaluateShadow(ref p, ref fakeNorml, sample.GetLazyValue(),
                                                                sample.GetLazyValue(), sample.GetLazyValue(), ref ls);


                        var lightColor = (RgbSpectrumInfo)(ls.Spectrum);
                        lightPdf = ls.Pdf;
                        comp.Rays[comp.RayCount] = ls.LightRay;

                        if ((lightPdf > 0f) && !lightColor.IsBlack())
                        {
                            comp.ScatteredLight[comp.RayCount] =(RgbSpectrum)(Tr * sigs * lightColor * MathLab.Exp(-distance) *
                                                                 ((Density(ref p) * step) / (4f * MathLab.M_PI * lightPdf * lightStrategyPdf)));
                            comp.RayCount++;
                        }
                    }

                    comp.EmittedLight = Lv * step;
                }
            }
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:67,代码来源:SingleScatteringIntegrator.cs

示例5: CreateEyeVertex

 public PathVertexData CreateEyeVertex(ICamera camera, Sample sample)
 {
     IRay ray;
     camera.GetRay(sample.imageX, sample.imageY, out ray);
     return new PathVertexData()
         {
             Flags = (byte)PathVertexType.Camera,
             CameraPoint = ray.Origin,
             CameraDirection = ray.Direction,
             Lens = new UV(sample.GetLazyValue(), sample.GetLazyValue()),
             Time = sample.GetLazyValue()
         };
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:13,代码来源:VertexFactory.cs

示例6: CreateLightVertex

 public PathVertexData CreateLightVertex(Sample Sample)
 {
     LightSample ls;
     var light = context.Scene.Lights[context.Scene.SampleLights(Sample.GetLazyValue())];
     light.EvaluatePhoton(context.Scene, Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), Sample.GetLazyValue(), out ls);
     var ray = ls.LightRay;
     var weight = ls.Pdf * (1f / context.Scene.Lights.Length);
     var thr = (RgbSpectrum)(ls.Spectrum) * weight;
     return new PathVertexData
         {
             Flags = (byte)PathVertexType.Light,
             Emission = thr,
             HitPoint = ray.Org,
             OutgoingDirection = ray.Dir,
             
         };
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:17,代码来源:VertexFactory.cs

示例7: CreatePathVertex

            public PathVertex CreatePathVertex(ref RayData ray, ref RayHit rayHit, Sample Sample)
            {
                PathVertex result = null;
                bool missed = rayHit.Index == 0xffffffffu;
                if (missed)
                {
                    if (scene.EnvironmentMap == null)
                    {
                        result = new EnvironmentPathVertex() { IncomingDirection = -ray.Dir };
                    }
                    else
                    {
                        result = new ImplicitLightVertex() { IncomingDirection = -ray.Dir, Light = scene.EnvironmentMap };
                    }
                    return result;
                }
                var hitInfo = surfaceSampler.GetIntersection(ref ray, ref rayHit);
                var hitPoint = ray.Point(rayHit.Distance);

                var currentTriangleIndex = (int)rayHit.Index;
                if (hitInfo.IsLight)
                {
                    var lt = scene.GetLightByIndex(currentTriangleIndex);
                    result = new ImplicitLightVertex()
                        {
                            IncomingDirection = -ray.Dir,
                            Light = lt,
                            HitItemId = currentTriangleIndex,
                            Point = hitPoint
                        };
                }
                else
                {
                    Vector wo = -ray.Dir;
                    float fPdf;
                    Vector wi;
                    bool specularBounce;
                    float u0 = Sample.GetLazyValue(), u1 = Sample.GetLazyValue(), u2 = Sample.GetLazyValue(), u3 = Sample.GetLazyValue();


                    var bsdf = hitInfo.MMaterial;
                    var throughput = RgbSpectrum.Unit;

                    RgbSpectrum f = bsdf.Sample_f(ref wo, out wi, ref hitInfo.Normal,
                                                               ref hitInfo.ShadingNormal, ref throughput,
                                                               u0, u1, u2, ref hitInfo.TextureData,
                                                               out fPdf, out specularBounce);
                    result = new GeometryVertex()
                        {
                            BsdfSampleWeight = fPdf,
                            GeometryNormal = hitInfo.Normal,
                            ShadingNormal = hitInfo.ShadingNormal,
                            HitItemId = currentTriangleIndex,
                            IncomingDirection = wo,
                            OutgoingDirection = wi,
                            Point = hitPoint,
                            Sample = f,
                            u0 = u0,
                            u1 = u1,
                            u2 = u2,
                            u3 = u3,
                            SampledBsdf = bsdf
                        };

                }
                return result;
            }
开发者ID:HungryBear,项目名称:rayden,代码行数:67,代码来源:MltPathTracerPath.cs

示例8: CreateLightVertex

            public ExplicitLightVertex CreateLightVertex(Sample sample, GeometryVertex vertex)
            {

                int currentLightIndex = scene.SampleLights(sample.GetLazyValue());
                var light = scene.Lights[currentLightIndex];

                var ls = new LightSample();
                light.EvaluateShadow(ref vertex.Point, ref vertex.GeometryNormal, sample.GetLazyValue(), sample.GetLazyValue(), sample.GetLazyValue(), ref ls);
                if (ls.Pdf <= 0f)
                {
                    throw new Exception();
                }
                /*
                secRays[tracedShadowRayCount].color = new RgbSpectrum(ls.Spectrum);
                secRays[tracedShadowRayCount].pdf = ls.Pdf;
                secRays[tracedShadowRayCount].shadowRay = ls.LightRay;

                Vector lwi = secRays[tracedShadowRayCount].shadowRay.Dir;
                RgbSpectrum fs;
                hitInfo.MMaterial.f(
                    ref secRays[tracedShadowRayCount].shadowRay.Dir,
                    ref wo, ref hitInfo.ShadingNormal, out fs, BrdfType.Diffuse);
                secRays[tracedShadowRayCount].color *= lightTroughtput *
                                                       Vector.AbsDot(ref hitInfo.ShadingNormal, ref lwi) *
                                                       fs;
                */
                return new ExplicitLightVertex()
                    {
                        
                    };
            }
开发者ID:HungryBear,项目名称:rayden,代码行数:31,代码来源:MltPathTracerPath.cs


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