• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Normal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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 | BrdfType.Refractive;

            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.AbsDot(ref n, ref wi));
            // Using 0.01 instead of 0.0 to cut down fireflies
            if (dp <= 0.0001f)
            {
                result.Pdf /= 1000f;
                //    return new RgbSpectrum(0f);
            }
            else
            {
                result.Pdf /= dp;
            }

            result.F=  KdOverPI;
            result.Wi = wi;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:34,代码来源:TranslucentMaterial.cs


示例2: f

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


示例3: 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


示例4: EvalBrdf

        private void EvalBrdf(ref Vector wo, ref Vector wi, ref Normal N, out RgbSpectrum fs)
        {
            float cosThetaO = Vector.AbsDot(ref N, ref wo);
            //AbsCosTheta(wo);
            float cosThetaI = Vector.AbsDot(ref N, ref wi);
            //AbsCosTheta(wi);
            if (Math.Abs(cosThetaI - 0f) < Epsilon || Math.Abs(cosThetaO - 0f) < Epsilon)
            {
                fs = new RgbSpectrum(0f, 0f, 0f);
                return;
                //return new RgbSpectrum(1f, 0f, 0f);
            }
            Vector wh = wi + wo;
            if (wh.IsZero())
            {
                fs = new RgbSpectrum(0f);
                return;
            }
            //return new RgbSpectrum(1f, 0f, 0f);
            wh = wh.Normalize();
            float cosThetaH = Vector.Dot(ref wi, ref wh);
            var F = fresnel.Evaluate(cosThetaH);

            fs = (R0 * distr.D(ref wh) * G(ref N, ref wo, ref wi, ref wh) * F / (4f * cosThetaI * cosThetaO));
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:25,代码来源:DistributionBsdf.cs


示例5: Sample

 public override void Sample(ref Vector wi, ref Normal n, float u0, float u1, float lambda, out Vector dir, out float f)
 {
     var nl = n.ToVec();
     dir = Geometry.Reflect(ref wi, ref n);
         //new Vector(wi - nl * 2f * nl&wi);
     f = 1f;
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:Brdf.cs


示例6: Update

    // Update is called once per frame
    void Update()
    {
        if (!_fadeInDone)
        {
            _lerp += Time.deltaTime / Duration;
            _renderer.material.color = Color.Lerp(_startColor, _endColor, _lerp);
            if (_lerp >= 1)
            {
                _fadeInDone = true;
            }
        }

        if (_fadeOut)
        {
            _lerp += Time.deltaTime / Duration;
            _renderer.material.color = Color.Lerp(_endColor, _startColor, _lerp);
            if (_lerp >= 1)
            {
                Destroy(gameObject);
            }
        }

        Vector3 up = _transform.InverseTransformDirection(Vector3.up);
        Closest = new Normal() { Value = -1, Direction = new Vector3(99, 99, 99) };
        float angle = 360;
        foreach (var normal in _normals)
        {
            var a = Vector3.Angle(normal.Direction, up);
            if (a < angle)
            {
                Closest = normal;
                angle = a;
            }
        }
    }
开发者ID:Johannesolof,项目名称:DoDGame,代码行数:36,代码来源:BaseDice.cs


示例7: GlossyReflection

        public static Vector GlossyReflection(Vector wo, float exponent, Normal shadN, float u0, float u1) {
            var shadeN = shadN;
            float phi = 2f * MathLab.M_PI * u0;
            float cosTheta = (float)MathLab.Pow(1f - u1, exponent);
            float sinTheta = MathLab.Sqrt(1f - cosTheta * cosTheta);
            float x = (float)Math.Cos(phi) * sinTheta;
            float y = (float)Math.Sin(phi) * sinTheta;
            float z = cosTheta;

            Vector dir = -wo;
            float dp = Vector.Dot(ref shadeN, ref dir);
            Vector w = dir - (2f * dp) * shadeN.ToVec();

            Vector u;
            if (Math.Abs(shadeN.x) > .1f) {
                var a = new Vector(0f, 1f, 0f);
                u = Vector.Cross(ref a, ref w);
            }
            else {
                Vector a = new Vector(1f, 0f, 0f);
                u = Vector.Cross(ref a, ref w);
            }
            u = u.Normalize();
            Vector v = Vector.Cross(ref w, ref u);

            return x * u + y * v + z * w;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:27,代码来源:BxDFBase.cs


示例8: EvaluateShadow

        public void EvaluateShadow(ref Point point, ref Normal n, float u0, float u1, float u2, ref LightSample[] result, float ltProb = 0f)
        {

            switch (scene.LightSamplingStrategy)
            {
                case LightSamplingStrategy.UniformOneLight:
                    if (result == null)
                        result = new LightSample[scene.ShadowRaysPerSample];
                    for (int i = 0; i < scene.ShadowRaysPerSample; i++)
                    {
                        int currentLightIndex = scene.SampleLights(ltProb <= 0f ? rnd.NextFloat() : ltProb);
                        var light = scene.Lights[currentLightIndex];
                        var ls = result[i]??new LightSample();
                        ls.LightIndex = currentLightIndex;
                        light.EvaluateShadow(ref point, ref n, u0, u1, u2, ref ls);
                        //ls.Pdf *= (scene.ShadowRaysPerSample);
                        result[i] = ls;
                    }
                    break;
                case LightSamplingStrategy.UniformAllLights:
                    {
                        var sm = new List<LightSample>();

                        foreach (var light in scene.Lights)
                        {
                            var ls = new LightSample();
                            light.EvaluateShadow(ref point, ref n, u0, u1, u2, ref ls);
                            if (ls.Pdf > 0f)
                                sm.Add(ls);
                        }
                        result = sm.ToArray();
                    }
                    break;
            }
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:35,代码来源:LightSampler.cs


示例9: Sample_f

        public override void Sample_f(ref Vector wo, ref Normal geoNormal, ref Normal shadeN, float lambda, ref SurfaceTextureData surfaceData, float u0, float u1, float u2, out BsdfSampleData result)
        {
            EvalParams(ref surfaceData, lambda);
            Vector dir =
                MC.CosineSampleHemisphere(u0, u1);
            result = new BsdfSampleData { Pdf = dir.z*MathLab.INVPI, Type = BrdfType.Diffuse}; // TODO Lambda weight
            Vector v1, v2;
            Normal n = geoNormal;
            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));
            // Using 0.01 instead of 0.0 to cut down fireflies
            if (dp <= 0.0001f)
            {
                result.Pdf = 0f;
                result.F = new RgbSpectrum();
                result.Lambda = 0f;
            }
            else
            {
                result.Pdf /= dp;
                result.F = surfaceData.Diffuse * MathLab.INVPI;
                result.Lambda = Kd.Sample(lambda)*MathLab.INVPI;
            }
            result.Wi = wi;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:33,代码来源:MatteMaterial.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: 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


示例12: GetBsdf

        public BaseBxdf GetBsdf(ref RayData pathRay, ref RayHit hit, ref MediumInfo med, bool fromLight, float u0)
        {
            var currentTriangleIndex = (int) hit.Index;
            bool isLight = scene.IsLight(currentTriangleIndex);

            var mesh = scene.GetMeshByTriangleIndex(currentTriangleIndex);
            if (mesh == null)
            //|| mesh.MeshName.Equals("COL254_01", StringComparison.InvariantCultureIgnoreCase))
            {
                //ii.Color = new RgbSpectrum(1f);
                //Debugger.Break();
                throw new ApplicationException("Invalid triangle index " + currentTriangleIndex + " Mesh not found");
            }
            UV TexCoords;
            Normal normal = new Normal(), shadeN = new Normal();

            mesh.InterpolateTriUV(currentTriangleIndex, hit.U, hit.V, out TexCoords);
            //normal = -scene.Triangles[currentTriangleIndex].ComputeNormal(scene.Vertices).Normalize();

            mesh.InterpolateTriangleNormal((int)hit.Index, hit.U, hit.V, ref normal);
            //normal = -normal;
            shadeN = (Normal.Dot(ref pathRay.Dir, ref normal) > 0f) ? -normal : normal;


            var bsdf =  mesh.Material.GetBsdf(ref pathRay, ref hit, ref normal, ref shadeN, ref TexCoords, ref med, fromLight,u0);
            bsdf.SetLight(isLight);
            return bsdf;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:28,代码来源:SurfaceSampler.cs


示例13: coefficient

        float mReflectCoeff;     //!< Fresnel reflection coefficient (for glass) 

        Bsdf(
        Ray aRay,
        ref Normal normal,
        Material Material,
        SceneGeometryInfo aScene)
        {
            Setup(aRay, ref normal, Material, aScene);
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:10,代码来源:Bsdf.cs


示例14: G

 public static float G(ref Normal N, ref Vector wo, ref Vector wi, ref Vector wh)
 {
     float NdotWh = Vector.AbsDot(ref N, ref wh);
     float NdotWo = Vector.AbsDot(ref N, wo);
     float NdotWi = Vector.AbsDot(ref N, wi);
     float WOdotWh = Vector.AbsDot( ref wo, ref wh);
     return Math.Min(1f, Math.Min(2f * NdotWh * NdotWo / WOdotWh, 2f * NdotWh * NdotWi / WOdotWh));
 } 
开发者ID:HungryBear,项目名称:rayden,代码行数:8,代码来源:DistrubutionBsdf.cs


示例15: Sample_f

 public override RgbSpectrum Sample_f(ref Vector wo, out Vector wi, ref Normal N, ref Normal shadeN, float u0, float u1, float u2, out float pdf, out bool specularBounce)
 {
     specularBounce = false;
     distr.Sample_f(ref wo, out wi, u1, u2, out pdf);
     if(!SameHemisphere(ref wo, ref wi))
         return RgbSpectrum.ZeroSpectrum();
     return f(ref wo, ref wi, ref N); 
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:8,代码来源:DistrubutionBsdf.cs


示例16: TaxaNormalContaTest

 public void TaxaNormalContaTest()
 {
     Normal target = new Normal();
     decimal esperado = decimal.Parse("10.00");
     decimal retornado;
     target.Tarifa = esperado;
     retornado = target.Tarifa;
     Assert.AreEqual(esperado, retornado);
 }
开发者ID:allanolv,项目名称:SistemaBancario,代码行数:9,代码来源:ContaNormalTest.cs


示例17: ContaNormalContaTest

 public void ContaNormalContaTest()
 {
     Normal target = new Normal();
     int esperado = int.Parse("030");
     int retornado;
     target.NumeroDaconta = esperado;
     retornado = target.NumeroDaconta;
     Assert.AreEqual(esperado, retornado);
 }
开发者ID:allanolv,项目名称:SistemaBancario,代码行数:9,代码来源:ContaNormalTest.cs


示例18: f

        public override void f(ref Vector wo, ref Vector wi, ref Normal N, ref RgbSpectrum in_fs, out RgbSpectrum fs)
        {
            float c = 1f - Vector.Dot(ref wo, ref N);
            float Re = R0 + (1f - R0) * c * c * c * c * c;

            float P = .25f + .5f * Re;

            fs = KdiffOverPI * (1f - Re) / (1f - P);
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:9,代码来源:AlloyMaterial.cs


示例19: 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) {
     Vector dir = -wo;
     float dp = Normal.Dot(ref shadeN, ref dir);
     result.Lambda = 0f;
     result.Wi = dir - (2f * dp) * shadeN.ToVec();
     result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
     result.Pdf = 1f;
     result.F = Kr;            
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:9,代码来源:MirrorMaterial.cs


示例20: Sample

        public void Sample(ref Vector wo, ref Normal N, ref Normal shadeN, float u0, float u1, float u2,float u3,
                           out BsdfSample sample, BxDFType type = BxDFType.AllTypes) {
            sample = new BsdfSample();
            var fl = type;
            int matchingComps = NumComponents(fl);
            if (matchingComps == 0) {
                sample.Pdf = 0f;
                sample.Wi = Vector.Zero;
                sample.Spectrum = new RgbSpectrum(0f).ToArray();
            }
            int which = (int)Math.Min((u0 * matchingComps),
                matchingComps - 1);
            BxDFBase bxdf = null;
            int count = which;
            for (int i = 0; i < Bxdfs.Length; ++i)
                if (Bxdfs[i].Type.HasFlag(fl))
                    if (count-- == 0) {
                        bxdf = Bxdfs[i];
                        break;
                    }
            Vector wi = new Vector();
            var pdf = 0f;
            bxdf.Sample(ref wo, ref N, ref shadeN, u1,  u2, u3, out sample, type);
            wi = sample.Wi;
            pdf = sample.Pdf;
            var sampled = bxdf.Type;
            if (pdf > 0f && pdf < MathLab.Epsilon) sample.Spectrum = new float[3]{0f,0f,0f};
            //if (sampledTy != null) sampledType = bxdf.Type;
            //wiW = LocalToWorld(wi);

            if ((!bxdf.Type.HasFlag(BxDFType.Specular)) && matchingComps > 1) {
                for (int i = 0; i < Bxdfs.Length; ++i) {
                    if (Bxdfs[i] != bxdf && (Bxdfs[i].Type.HasFlag(fl)))
                        pdf += Bxdfs[i].Pdf(ref wo, ref wi, fl);
                }
            }
            if (matchingComps > 1) pdf /= matchingComps;
            // Compute value of BSDF for sampled direction
            if (bxdf.Type.HasFlag(BxDFType.Specular))
            //if ((bxdf.Type & BxDFType.BSDF_SPECULAR) == 0)
            {
                var f = RgbSpectrum.ZeroSpectrum();
                if ((Vector.Dot(ref N,ref wi)) * Vector.Dot(ref N, ref wo) > 0f)
                // ignore BTDFs
                {
                    fl = fl & ~BxDFType.Transmission;
                }
                else
                    // ignore BRDFs
                    fl = (fl & ~BxDFType.Reflection);
                for (int i = 0; i < Bxdfs.Length; ++i)
                    if ((Bxdfs[i].Type.HasFlag(fl)))
                        f +=  new RgbSpectrum(Bxdfs[i].Eval(ref wo, ref wi, ref N));
                sample.Spectrum = (f/pdf).ToArray();
            }
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:56,代码来源:Material.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NormalDistribution类代码示例发布时间:2022-05-24
下一篇:
C# Norm类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap