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


C# Normal类代码示例

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


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


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