コード例 #1
0
ファイル: RayTracer.cs プロジェクト: BenitoJedai/Braille
        private Color TraceRay(Ray ray, Scene scene, int depth)
        {
            ISect isect = Intersections(ray, scene).MinByOrDefault(isec => isec.Dist);

            if (isect == null)
            {
                return(Color.Background);
            }
            return(Shade(isect, scene, depth));
        }
コード例 #2
0
ファイル: RayTracer.cs プロジェクト: BenitoJedai/Braille
        private double TestRay(Ray ray, Scene scene)
        {
            ISect isect = Intersections(ray, scene).MinByOrDefault(isec => isec.Dist);

            if (isect == null)
            {
                return(0);
            }
            return(isect.Dist);
        }
コード例 #3
0
        private Color TraceRay(Ray ray, Scene scene, int depth)
        {
            var   isects = Intersections(ray, scene);
            ISect isect  = isects.FirstOrDefault();

            if (isect == null)
            {
                return(Color.Background);
            }
            return(Shade(isect, scene, depth));
        }
コード例 #4
0
        private double TestRay(Ray ray, Scene scene)
        {
            var   isects = Intersections(ray, scene);
            ISect isect  = isects.FirstOrDefault();

            if (isect == null)
            {
                return(0);
            }
            return(isect.Dist);
        }
コード例 #5
0
        private Color Shade(ISect isect, Scene scene, int depth)
        {
            var   d          = isect.Ray.Dir;
            var   pos        = Vector.Plus(Vector.Times(isect.Dist, isect.Ray.Dir), isect.Ray.Start);
            var   normal     = isect.Thing.Normal(pos);
            var   reflectDir = Vector.Minus(d, Vector.Times(2 * Vector.Dot(normal, d), normal));
            Color ret        = Color.DefaultColor;

            ret = Color.Plus(ret, GetNaturalColor(isect.Thing, pos, normal, reflectDir, scene));
            if (depth >= MaxDepth)
            {
                return(Color.Plus(ret, Color.Make(.5, .5, .5)));
            }
            return(Color.Plus(ret, GetReflectionColor(isect.Thing, Vector.Plus(pos, Vector.Times(.001, reflectDir)), normal, reflectDir, scene, depth)));
        }
コード例 #6
0
ファイル: RayTracer.cs プロジェクト: okagawa/dashboard
 private Color Shade(ISect isect, Scene scene, int depth)
 {
     var d = isect.Ray.Dir;
     var pos = Vector.Plus(Vector.Times(isect.Dist, isect.Ray.Dir), isect.Ray.Start);
     var normal = isect.Thing.Normal(pos);
     var reflectDir = Vector.Minus(d, Vector.Times(2 * Vector.Dot(normal, d), normal));
     Color ret = Color.DefaultColor;
     ret = Color.Plus(ret, GetNaturalColor(isect.Thing, pos, normal, reflectDir, scene));
     if (depth >= MaxDepth) {
         return Color.Plus(ret, Color.Make(.5, .5, .5));
     }
     return Color.Plus(ret, GetReflectionColor(isect.Thing, Vector.Plus(pos, Vector.Times(.001, reflectDir)), normal, reflectDir, scene, depth));
 }