示例#1
0
        public void ReflectedColorForNonReflectiveMaterial()
        {
            var w     = new DefaultWorld();
            var r     = new Ray(Vector4.CreatePosition(0, 0, 0), Vector4.CreateDirection(0, 0, 1));
            var shape = w.Objects[1];

            shape.Material.Ambient = 1;
            var i     = new Intersection(1, shape);
            var comps = i.Precompute(r);
            var c     = w.GetReflectedColor(comps, 5);

            Assert.Equal(Color.Black, c);
        }
示例#2
0
        public void ReflectedColorAtMaxRecursiveDepth()
        {
            var w     = new DefaultWorld();
            var plane = new Plane();

            plane.Material.Reflective = 0.5;
            plane.Transform           = Transform.Translate(0, -1, 0);
            w.Objects.Add(plane);
            var r = new Ray(
                Vector4.CreatePosition(0, 0, -3),
                Vector4.CreateDirection(0, -Math.Sqrt(2) / 2, Math.Sqrt(2) / 2));
            var i     = new Intersection(Math.Sqrt(2), plane);
            var comps = i.Precompute(r);
            var c     = w.GetReflectedColor(comps, 0);

            Assert.Equal(Color.Black, c);
        }
示例#3
0
        public void ReflectedColorForReflectiveMaterial()
        {
            var w     = new DefaultWorld();
            var plane = new Plane();

            plane.Material.Reflective = 0.5;
            plane.Transform           = Transform.Translate(0, -1, 0);
            w.Objects.Add(plane);
            var r = new Ray(
                Vector4.CreatePosition(0, 0, -3),
                Vector4.CreateDirection(0, -Math.Sqrt(2) / 2, Math.Sqrt(2) / 2));
            var          i        = new Intersection(Math.Sqrt(2), plane);
            var          comps    = i.Precompute(r);
            var          c        = w.GetReflectedColor(comps, 5);
            var          expected = new Color(0.19032, 0.2379, 0.14274);
            const double eps      = 0.0001;
            var          comparer = Color.GetEqualityComparer(eps);

            Assert.Equal(expected, c, comparer);
        }