Exemplo n.º 1
0
        public void RefractedColor()
        {
            var world   = new DefaultWorld();
            var sphereA = world.Shapes[0];

            sphereA.Material.Ambient = 1;
            sphereA.Material.Pattern = new TestPattern();

            var sphereB = world.Shapes[1];

            sphereB.Material.Transparency    = 1;
            sphereB.Material.RefractiveIndex = 1.5f;

            var ray           = new Ray(new Point(0, 0, 0.1f), Vector.UnitY);
            var intersections = new Intersections(
                new Intersection(-0.9899f, sphereA),
                new Intersection(-0.4899f, sphereB),
                new Intersection(0.4899f, sphereB),
                new Intersection(0.9899f, sphereA));
            var info = new IntersectionInfo(intersections, intersections[2], ray);

            var actual = world.RefractedColor(info, 5);

            Assert.Equal(new Color(0, 0.9978715f, 0.047472f), actual);
        }
Exemplo n.º 2
0
        public void RefractedColorOpaqueSurface()
        {
            var world         = new DefaultWorld();
            var sphere        = world.Shapes[0];
            var ray           = new Ray(new Point(0, 0, -5), Vector.UnitZ);
            var intersections = new Intersections(new Intersection(4, sphere), new Intersection(6, sphere));
            var info          = new IntersectionInfo(intersections, intersections[0], ray);

            var actual = world.RefractedColor(info, 5);

            Assert.Equal(Color.Black, actual);
        }
Exemplo n.º 3
0
        public void RefractedColorTotalInternalReflection()
        {
            var world  = new DefaultWorld();
            var sphere = world.Shapes[0];

            sphere.Material.Transparency    = 1;
            sphere.Material.RefractiveIndex = 1.5f;

            var ray           = new Ray(new Point(0, 0, MathF.Sqrt(2) / 2), Vector.UnitY);
            var intersections = new Intersections(new Intersection(-MathF.Sqrt(2) / 2, sphere), new Intersection(MathF.Sqrt(2) / 2, sphere));
            var info          = new IntersectionInfo(intersections, intersections[1], ray);

            var actual = world.RefractedColor(info, 5);

            Assert.Equal(Color.Black, actual);
        }
Exemplo n.º 4
0
        public void RefractedColorMaxRecursiveDepth()
        {
            var world  = new DefaultWorld();
            var sphere = world.Shapes[0];

            sphere.Material.Transparency    = 1;
            sphere.Material.RefractiveIndex = 1.5f;

            var ray           = new Ray(new Point(0, 0, -5), Vector.UnitZ);
            var intersections = new Intersections(new Intersection(4, sphere), new Intersection(6, sphere));
            var info          = new IntersectionInfo(intersections, intersections[0], ray);

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

            Assert.Equal(Color.Black, actual);
        }