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

C# Math.ShadeRec类代码示例

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

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



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

示例1: GetColor

        public override Vector3 GetColor(ShadeRec sr)
        {
            float x = sr.LocalHitPoint.X;
            float y = sr.LocalHitPoint.Y;
            float z = sr.LocalHitPoint.Z;
            float x_size = b.X / num_x_checkers;   	// in radians - azimuth angle
            float z_size = a.Z / num_z_checkers;
            int i_phi = MathHelper.Floor(x / x_size);
            int i_theta = MathHelper.Floor(z / z_size);
            float f_phi = x / x_size - i_phi;
            float f_theta = z / z_size - i_theta;
            float phi_line_width = 0.5f * x_line_width;
            float theta_line_width = 0.5f * z_line_width;
            bool in_outline = (f_phi < phi_line_width || f_phi > 1.0 - phi_line_width) ||
                                (f_theta < theta_line_width || f_theta > 1.0 - theta_line_width);

            if ((i_phi + i_theta) % 2 == 0)
            {
                if (!in_outline)
                    return (color1);
            }
            else
            {
                if (!in_outline)
                    return (color2);
            }
            return (line_color);
        }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:28,代码来源:RectangleChecker.cs


示例2: Hit

 public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr)
 {
     if (bbox.Hit(ray))
         return base.Hit(ray, ref tmin, ref sr);
     else 
         return false;
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:7,代码来源:Group.cs


示例3: Global_Shade

 public override Vector3 Global_Shade(ShadeRec sr)
 {
     if (sr.Depth == 1)
         return (Vector3.Zero);
     else
         return ls * t.GetColor(sr);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:7,代码来源:SV_Emissive.cs


示例4: Area_Light_Shade

        public override Vector3 Area_Light_Shade(ShadeRec sr)
        {
            Vector3 wo = -sr.Ray.Direction;
            Vector3 L = ambient.RHO(sr, wo) * sr.World.AmbientLight.L(sr);
            int num_lights = sr.World.Lights.Count;
            for (int j = 0; j < num_lights; j++)
            {
                Light light_ptr = sr.World.Lights[j];
                Vector3 wi = light_ptr.GetDirection(sr);	//compute_direction ?
                wi.Normalize();
                float ndotwi = Vector3.Dot(sr.Normal, wi);
                float ndotwo = Vector3.Dot(sr.Normal, wo);
                if (ndotwi > 0.0 && ndotwo > 0.0)
                {
                    bool in_shadow = false;

                    if (sr.World.Lights[j].Shadows)
                    {
                        Ray shadow_ray = new Ray(sr.HitPoint, wi);
                        in_shadow = light_ptr.InShadow(shadow_ray, sr);
                    }
                    if (!in_shadow)
                        L += diffuse.F(sr, wo, wi) * light_ptr.L(sr) * light_ptr.G(sr) * ndotwi / sr.World.Lights[j].PDF(sr);
                }
            }
            return (L);
        }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:27,代码来源:SV_Matte.cs


示例5: GetColor

 public override Vector3 GetColor(ShadeRec sr)
 {
     float x = sr.LocalHitPoint.X - center.X;
     float y = sr.LocalHitPoint.Y - center.Y;
     float z = sr.LocalHitPoint.Z - center.Z;
     float phi = MathHelper.Atan2(x, z);
     float phi_size = 2 * MathHelper.PI / num_angular_checkers;
     float theta_size = radius / num_radial_checkers;
     float ra = MathHelper.Sqrt(x * x + z * z) / radius;
     int i_phi = MathHelper.Floor(phi / phi_size);
     int i_theta = MathHelper.Floor(ra / theta_size);
     float f_phi = phi / phi_size - i_phi;
     float f_theta = ra / theta_size - i_theta;
     float phi_line_width = 0.5f * angular_line_width;
     float theta_line_width = 0.5f * radial_line_width;
     bool in_outline = (f_phi < phi_line_width || f_phi > 1.0 - phi_line_width) ||
                         (f_theta < theta_line_width || f_theta > 1.0 - theta_line_width);
     if ((i_phi + i_theta) % 2 == 0)
     {
         if (!in_outline)
             return (color1);
     }
     else
     {
         if (!in_outline)
             return (color2);
     }
     return (line_color);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:29,代码来源:DiskChecker.cs


示例6: Hit

 public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr)
 {
     Vector3 v0 = (Mesh.Vertices[index0]);
     Vector3 v1 = (Mesh.Vertices[index1]);
     Vector3 v2 = (Mesh.Vertices[index2]);
     float a = v0.X - v1.X, b = v0.X - v2.X, c = ray.Direction.X, d = v0.X - ray.Position.X;
     float e = v0.Y - v1.Y, f = v0.Y - v2.Y, g = ray.Direction.Y, h = v0.Y - ray.Position.Y;
     float i = v0.Z - v1.Z, j = v0.Z - v2.Z, k = ray.Direction.Z, l = v0.Z - ray.Position.Z;
     float m = f * k - g * j, n = h * k - g * l, p = f * l - h * j;
     float q = g * i - e * k, s = e * j - f * i;
     float inv_denom = 1.0f / (a * m + b * q + c * s);
     float e1 = d * m - b * n - c * p;
     float beta = e1 * inv_denom;
     if (beta < 0.0)
         return (false);
     float r = e * l - h * i;
     float e2 = a * n + d * q + c * r;
     float gamma = e2 * inv_denom;
     if (gamma < 0.0)
         return (false);
     if (beta + gamma > 1.0)
         return (false);
     float e3 = a * p - b * r + d * s;
     float t = e3 * inv_denom;
     if (t < MathHelper.Epsilon)
         return (false);
     tmin = t;
     sr.Normal = interpolate_normal(beta, gamma); // for smooth shading
     sr.LocalHitPoint = ray.Position + t * ray.Direction;
     return (true);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:31,代码来源:SmoothMeshTriangle.cs


示例7: Sample_F

 public override Vector3 Sample_F(ShadeRec sr, Vector3 wo, ref Vector3 wi, ref float pdf)
 {
     float ndotwo = Vector3.Dot(sr.Normal, wo);
     wi = -wo + 2.0f * sr.Normal * ndotwo;
     pdf = Vector3.AbsDot(sr.Normal, wi);
     return kr * cr.GetColor(sr);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:7,代码来源:SV_PerfectSpecular.cs


示例8: Area_Light_Shade

 public override Vector3 Area_Light_Shade(ShadeRec sr)
 {
     Vector3 wo = -sr.Ray.Direction;
     Vector3 L = ambient.RHO(sr, wo) * sr.World.AmbientLight.L(sr);
     int num_lights = sr.World.Lights.Count;
     for (int j = 0; j < num_lights; j++)
     {
         Vector3 wi = sr.World.Lights[j].GetDirection(sr);
         float ndotwi = Vector3.Dot(sr.Normal, wi);
         if (ndotwi > 0.0)
         {
             if (Shadows)
             {
                 bool in_shadow = false;
                 if (sr.World.Lights[j].Shadows)
                 {
                     Ray shadowRay = new Ray(sr.HitPoint, wi);
                     in_shadow = sr.World.Lights[j].InShadow(shadowRay, sr);
                 }
                 if (!in_shadow)
                     L += (diffuse.F(sr, wo, wi)
                               + specular.F(sr, wo, wi)) * sr.World.Lights[j].L(sr) * ndotwi * sr.World.Lights[j].G(sr) / sr.World.Lights[j].PDF(sr);
             }
             else
             {
                 L += (diffuse.F(sr, wo, wi)
                               + specular.F(sr, wo, wi)) * sr.World.Lights[j].L(sr) * ndotwi * sr.World.Lights[j].G(sr) / sr.World.Lights[j].PDF(sr);
             }
         }
     }
     return (L);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:32,代码来源:Phong.cs


示例9: Area_Light_Shade

 public override Vector3 Area_Light_Shade(ShadeRec sr)
 {
     if (Vector3.Dot(-sr.Normal, sr.Ray.Direction) > 0.0f)		//here may be ConcaveSphere not support
         return (Radiance * Color);
     else
         return (Vector3.Zero);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:7,代码来源:Emissive.cs


示例10: HitObjects

        public ShadeRec HitObjects(Ray ray)
        {
            ShadeRec sr = new ShadeRec(this);
            float t = 0;
            Vector3 normal = Vector3.Zero;
            Vector3 local_hit_point = Vector3.Zero;
            float tmin = float.MaxValue;
            int num_objects = Objects.Count;

            for (int j = 0; j < num_objects; j++)
            {
                if (Objects[j].Hit(ray, ref t, ref sr) && (t < tmin))
                {
                    sr.Hit_an_object = true;
                    tmin = t;
                    sr.Material = Objects[j].GetMaterial();
                    sr.HitPoint = ray.Position + t * ray.Direction;
                    normal = sr.Normal;
                    local_hit_point = sr.LocalHitPoint;
                }
            }
            if (sr.Hit_an_object)
            {
                sr.T = tmin;
                sr.Normal = normal;
                sr.LocalHitPoint = local_hit_point;
            }
            return (sr);
        }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:29,代码来源:World.cs


示例11: Shade

 public override Vector3 Shade(ShadeRec sr)
 {
     if (Vector3.Dot(-sr.Normal, sr.Ray.Direction) > 0.0f)
         return (Radiance * Color);
     else
         return (Vector3.Zero);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:7,代码来源:Emissive.cs


示例12: Sample_F

 public override Vector3 Sample_F(ShadeRec sr, Vector3 wo, ref Vector3 wi, ref float pdf)
 {
     float ndotwo = Vector3.Dot(sr.Normal, wo);
     wi = -wo + 2.0f * sr.Normal * ndotwo;
     pdf = MathHelper.Abs(Vector3.Dot(sr.Normal, wi));
     return (ReflectionCoefficient * Color);  
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:7,代码来源:PerfectSpecular.cs


示例13: Hit

        public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr)
        {
            if (!bbox.Hit(ray))
                return false;
            float t = 0;
            Vector3 normal = new Vector3(), local_hit_point = Vector3.Zero;
            bool hit = false;
            tmin = float.MaxValue;
            int num_objects = Objects.Count;
            for (int j = 0; j < num_objects; j++)
                if (Objects[j].Hit(ray, ref t,ref sr) && (t < tmin))
                {
                    hit = true;
                    tmin = t;
                    Material = Objects[j].GetMaterial();
                    normal = sr.Normal;
                    local_hit_point = sr.LocalHitPoint;
                }

            if (hit)
            {
                sr.T = tmin;
                sr.Normal = normal;
                sr.LocalHitPoint = local_hit_point;
            }

            return (hit);
        }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:28,代码来源:Compound.cs


示例14: Hit

        public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr)
        {
            if (!bbox.Hit(ray))
                return (false);
            float t = Vector3.Dot((center - ray.Position), normal) / Vector3.Dot(ray.Direction, normal);
            if (t <= MathHelper.Epsilon)
                return (false);

            Vector3 p = ray.Position + t * ray.Direction;
            float v = center.DistanceSquared(p);
            if (v < w_squared && v > i_squared)
            {

                double phi =MathHelper.Atan2(p.X, p.Z);
                if (phi < 0.0)
                    phi += MathHelper.TwoPI;
                if (phi <= max_azimuth && phi >= min_azimuth)
                {
                    tmin = t;
                    sr.Normal = normal;
                    sr.LocalHitPoint = p;
                    return (true);
                }
                else
                    return false;
            }
            else
                return (false);
        }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:29,代码来源:PartAnnulus.cs


示例15: Hit

 public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr)
 {
     float t;
     Vector3 temp = ray.Position - center;
     float a = Vector3.Dot(ray.Direction, ray.Direction);
     float b = 2.0f * Vector3.Dot(temp, ray.Direction);
     float c = Vector3.Dot(temp, temp) - radius * radius;
     float disc = b * b - 4.0f * a * c;
     if (disc < 0.0)
         return (false);
     else
     {
         float e = MathHelper.Sqrt(disc);
         float denom = 2.0f * a;
         t = (-b - e) / denom;
         if (t > MathHelper.BigEpsilon)
         {
             tmin = t;
             sr.Normal = -(temp + t * ray.Direction) / radius;
             sr.LocalHitPoint = ray.Position + t * ray.Direction;
             return (true);
         }
         t = (-b + e) / denom;
         if (t > MathHelper.BigEpsilon)
         {
             tmin = t;
             sr.Normal = -(temp + t * ray.Direction) / radius;
             sr.LocalHitPoint = ray.Position + t * ray.Direction;
             return (true);
         }
     }
     return (false);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:33,代码来源:ConcaveSphere.cs


示例16: GetColor

 public override Vector3 GetColor(ShadeRec sr)
 {
     float x = sr.LocalHitPoint.X;
     float y = sr.LocalHitPoint.Y;
     float z = sr.LocalHitPoint.Z;
     float ph = y;
     float phi = MathHelper.Atan2(x, z);
     if (phi < 0.0)
         phi += 2.0f * MathHelper.PI;
     float phi_size = 2.0f * MathHelper.PI / num_horizontal_checkers;   	// in radians - azimuth angle
     float theta_size = h / num_vertical_checkers;   		// in radians - polar angle
     int i_phi = MathHelper.Floor(phi / phi_size);
     int i_theta = MathHelper.Floor(ph / theta_size);
     float f_phi = phi / phi_size - i_phi;
     float f_theta = ph / theta_size - i_theta;
     float phi_line_width = 0.5f * vertical_line_width;
     float theta_line_width = 0.5f * horizontal_line_width;
     bool in_outline = (f_phi < phi_line_width || f_phi > 1.0 - phi_line_width) ||
                         (f_theta < theta_line_width || f_theta > 1.0 - theta_line_width);
     if ((i_phi + i_theta) % 2 == 0)
     {
         if (!in_outline)
             return (color1);
     }
     else
     {
         if (!in_outline)
             return (color2);
     }
     return (line_color);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:31,代码来源:ConeChecker.cs


示例17: trace

        internal static ShadeRec trace(Tracer tr, Ray ray)
        {
            ShadeRec sr = new ShadeRec(tr.World);
            float t = 0;
            Vector3 normal = Vector3.Zero;
            Vector3 local_hit_point = Vector3.Zero;
            float tmin = float.MaxValue;
            int num_objects = tr.World.Objects.Count;
            for (int j = 0; j < num_objects; j++)
                if (tr.World.Objects[j].Hit(ray, ref t, ref sr) && (t < tmin))
                {
                    sr.Hit_an_object = true;
                    tmin = t;
                    sr.Material = tr.World.Objects[j].Material;
                    sr.HitPoint = ray.Position + t * ray.Direction;
                    normal = sr.Normal;
                    local_hit_point = sr.LocalHitPoint;
                }

            if (sr.Hit_an_object)
            {
                sr.T = tmin;
                sr.Normal = normal;
                sr.LocalHitPoint = local_hit_point;
            }
            return sr;
        }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:27,代码来源:MultipleObjects.cs


示例18: Hit

 public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr)
 {
     if (box.Hit(ray))
     {
         return m.Hit(ray, ref tmin, ref sr);
     }
     return false;
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:8,代码来源:HeightMap.cs


示例19: Path_Shade

 public override Vector3 Path_Shade(ShadeRec sr)
 {
     Vector3 wo = -sr.Ray.Direction;
     Vector3 wi = Vector3.Zero;
     float pdf = 0;
     Vector3 fr = reflective.Sample_F(sr, wo, ref wi, ref pdf);
     Ray reflected_ray = new Ray(sr.HitPoint, wi);
     return (fr * sr.World.Tracer.TraceRay(reflected_ray, sr.Depth + 1) * (sr.Normal * wi) / pdf);
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:9,代码来源:Reflective.cs


示例20: GetDirection

 public override Vector3 GetDirection(ShadeRec sr)
 {
     float r = Radius;
     Vector3 new_location = Vector3.Zero;
     new_location.X = Location.X + r * (2.0f * MathHelper.RandomFloat()  - 1.0f);
     new_location.Y = Location.Y + r * (2.0f * MathHelper.RandomFloat() - 1.0f);
     new_location.Z = Location.Z + r * (2.0f * MathHelper.RandomFloat() - 1.0f);
     return (Vector3.Normalize(new_location - sr.LocalHitPoint));
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:9,代码来源:FakeSphericalLight.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Disruptor.Sequence类代码示例发布时间:2022-05-24
下一篇:
C# Entity.UserInfo类代码示例发布时间: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