コード例 #1
0
ファイル: WorldTests.cs プロジェクト: tdaines/RayTracer
        public void ReflectedColorNonReflectiveMaterial()
        {
            var world = new DefaultWorld();
            var ray   = new Ray(Point.Zero, Vector.UnitZ);
            var shape = world.Shapes[1];

            shape.Material.Ambient = 1;

            var intersection = new Intersection(1, shape);
            var info         = new IntersectionInfo(new Intersections(intersection), intersection, ray);

            var actual = world.ReflectedColor(info, 0);

            Assert.Equal(Color.Black, actual);
        }
コード例 #2
0
ファイル: WorldTests.cs プロジェクト: tdaines/RayTracer
        public void ReflectedColorMaxRecursiveDepth()
        {
            var world = new DefaultWorld();
            var plane = new Plane(
                Matrix4x4.Translation(0, -1, 0),
                new Material(reflective: 0.5f));

            world.Shapes.Add(plane);

            var ray          = new Ray(new Point(0, 0, -3), new Vector(0, -MathF.Sqrt(2) / 2, MathF.Sqrt(2) / 2));
            var intersection = new Intersection(MathF.Sqrt(2), plane);
            var info         = new IntersectionInfo(new Intersections(intersection), intersection, ray);

            var actual = world.ReflectedColor(info, 0);

            Assert.Equal(Color.Black, actual);
        }
コード例 #3
0
ファイル: WorldTests.cs プロジェクト: tdaines/RayTracer
        public void ReflectedColorReflectiveMaterial()
        {
            var world = new DefaultWorld();
            var plane = new Plane(
                Matrix4x4.Translation(0, -1, 0),
                new Material(reflective: 0.5f));

            world.Shapes.Add(plane);

            var ray          = new Ray(new Point(0, 0, -3), new Vector(0, -MathF.Sqrt(2) / 2, MathF.Sqrt(2) / 2));
            var intersection = new Intersection(MathF.Sqrt(2), plane);
            var info         = new IntersectionInfo(new Intersections(intersection), intersection, ray);

            var actual = world.ReflectedColor(info, 1);

            Assert.Equal(new Color(0.19049118f, 0.23811397f, 0.1428684f), actual);
        }