示例#1
0
        private static void TestCase05()
        {
            // The refracted color with an opaque surface
            World w                   = new DefaultWorld();
            Shape shape               = w.Shapes[0];
            Ray   r                   = new Ray(Tuple.Point(0, 0, -5), Tuple.Vector(0, 0, 1));
            List <Intersection> xs    = Intersection.Aggregate(new Intersection(4, shape), new Intersection(6, shape));
            Computation         comps = new Computation(xs[0], r, xs);
            LightingModel       l     = new PhongReflection();
            Tuple c                   = l.RefractedColor(w, comps, 5);

            Assert.Equal(Tuple.Color(0, 0, 0), c);
        }
示例#2
0
        private static void TestCase07()
        {
            // The refracted color under total internal reflection
            World w     = new DefaultWorld();
            Shape shape = w.Shapes[0];

            shape.Material.Transparency    = 1;
            shape.Material.RefractiveIndex = 1.5f;
            Ray r = new Ray(Tuple.Point(0, 0, Sqrt(2) / 2), Tuple.Vector(0, 1, 0));
            List <Intersection> xs    = Intersection.Aggregate(new Intersection(-Sqrt(2) / 2, shape), new Intersection(Sqrt(2) / 2, shape));
            Computation         comps = new Computation(xs[1], r, xs);
            LightingModel       l     = new PhongReflection();
            Tuple c = l.RefractedColor(w, comps, 5);

            Assert.Equal(Tuple.Color(0, 0, 0), c);
        }
示例#3
0
        private static void TestCase06()
        {
            // The refracted color at the maximum recursive depth
            World w     = new DefaultWorld();
            Shape shape = w.Shapes[0];

            shape.Material.Transparency    = 1;
            shape.Material.RefractiveIndex = 1.5f;
            Ray r = new Ray(Tuple.Point(0, 0, -5), Tuple.Vector(0, 0, 1));
            List <Intersection> xs    = Intersection.Aggregate(new Intersection(4, shape), new Intersection(6, shape));
            Computation         comps = new Computation(xs[0], r, xs);
            LightingModel       l     = new PhongReflection();
            Tuple c = l.RefractedColor(w, comps, 0);

            Assert.Equal(Tuple.Color(0, 0, 0), c);
        }
示例#4
0
        private static void TestCase08()
        {
            // The refracted color with a refracted ray
            World w = new DefaultWorld();
            Shape A = w.Shapes[0];

            A.Material.Ambient = 1;
            A.Material.Pattern = new PositionPattern();
            Shape B = w.Shapes[1];

            B.Material.Transparency    = 1;
            B.Material.RefractiveIndex = 1.5f;
            Ray r = new Ray(Tuple.Point(0, 0, 0.1f), Tuple.Vector(0, 1, 0));
            List <Intersection> xs = Intersection.Aggregate(new Intersection(-0.9899f, A),
                                                            new Intersection(-0.4899f, B),
                                                            new Intersection(0.4899f, B),
                                                            new Intersection(0.9899f, A));
            Computation   comps = new Computation(xs[2], r, xs);
            LightingModel l     = new PhongReflection();
            Tuple         c     = l.RefractedColor(w, comps, 5);

            Assert.Equal(Tuple.Color(0, 0.99888f, 0.04725f), c);
        }