Exemplo n.º 1
0
        public void TestInterpolatedEmissiveWorldTriangle()
        {
            Triangle triangle = new Triangle( new Point( 0.0f, 0.0f, 3.0f ),
                                              new Point( 1.0f, 0.0f, 3.0f ),
                                              new Point( 1.0f, 1.0f, 3.0f ) );

            BarycentricInterpolatedEmissiveMaterial I = new BarycentricInterpolatedEmissiveMaterial( new Color3( 1.0f, 0.0f, 0.0f ),
                                                                                                     new Color3( 0.0f, 1.0f, 0.0f ),
                                                                                                     new Color3( 0.0f, 0.0f, 1.0f ) );

            SimpleObject so = new SimpleObject( triangle, null, new EmissiveMaterialBase[] { I, I }, null, null, null );

            ListScene scene = new ListScene();
            scene.Add( so );

            Framebuffer fb = new Framebuffer( Color3.Black, 500, 500 );

            Cameras.Pinhole( scene, RenderMethod.RecursiveRayTrace,
                             fb, 0, 0.0001f, 0, 1.0f, true,
                             1.0f, 1.0f, 1.0f,
                             new Point( 0.0f, 0.0f, -2.0f ),
                             new Vector( 0.0f, 0.0f, 1.0f ),
                             new Vector( 0.0f, 1.0f, 0.0f ),
                             1, 1, false );

            Assert.IsTrue( Pfm.Compare( fb, 0.01f, 0.02f, "..\\..\\TestImages\\TestInterpolatedEmissiveWorldTriangle.pfm" ) );
        }
Exemplo n.º 2
0
        public void TestMirrorPhongCheckerboardSpheres()
        {
            // Create Shapes
            Sphere s1 = new Sphere( new Point( 0.0f, 1.0f, 0.0f ), 1.0f );
            Sphere s2 = new Sphere( new Point( -1.0f, 0.5f, 1.5f ), 0.5f );
            InfinitePlane p1 = new InfinitePlane( new Point( 0.0f, 0.0f, 0.0f ), new Vector( 0.0f, 1.0f, 0.0f ) );

            // Create Lights
            List<PhongLight> Lights = new List<PhongLight>();

            Lights.Add( new PointPhongLight( new Point( -2.0f, 2.5f, 0.0f ),
                                             Color3.Black,
                                             new Color3( 0.49f, 0.07f, 0.07f ),
                                             new Color3( 0.49f, 0.07f, 0.07f ) ) );

            Lights.Add( new PointPhongLight( new Point( 1.5f, 2.5f, 1.5f ),
                                             Color3.Black,
                                             new Color3( 0.07f, 0.07f, 0.49f ),
                                             new Color3( 0.07f, 0.07f, 0.49f ) ) );

            Lights.Add( new PointPhongLight( new Point( 1.5f, 2.5f, -1.5f ),
                                             Color3.Black,
                                             new Color3( 0.07f, 0.49f, 0.07f ),
                                             new Color3( 0.07f, 0.49f, 0.07f ) ) );

            Lights.Add( new PointPhongLight( new Point( 0.0f, 3.5f, 0.0f ),
                                             Color3.Black,
                                             new Color3( 0.21f, 0.21f, 0.35f ),
                                             new Color3( 0.21f, 0.21f, 0.35f ) ) );

            // Create Materials
            CheckerboardPhongDirectMaterial checkerboardDirect = new CheckerboardPhongDirectMaterial( Color3.Black, Color3.Black, Color3.White, 150.0f,
                                                                                                      Color3.Black, Color3.White, Color3.White, 150.0f,
                                                                                                      Lights );

            CheckerboardSpecularIndirectMaterial checkerboardIndirect = new CheckerboardSpecularIndirectMaterial( new Color3( 0.1f, 0.1f, 0.1f ),
                                                                                                                  new Color3( 0.7f, 0.7f, 0.7f ) );

            PhongDirectMaterial sphereDirect = new PhongDirectMaterial( Color3.Black, Color3.White, new Color3( 0.5f, 0.5f, 0.5f ), 50.0f, Lights );

            PerfectSpecularIndirectMaterial sphereIndirect = new PerfectSpecularIndirectMaterial( new Color3( 0.6f, 0.6f, 0.6f ) );

            // Create Objects
            SimpleObject so1 = new SimpleObject( s1, s1.CreateNormals(), null, new DirectlyLitMaterialBase[] { sphereDirect, sphereDirect }, new IndirectlyLitMaterialBase[] { sphereIndirect, sphereIndirect }, null );
            SimpleObject so2 = new SimpleObject( s2, s2.CreateNormals(), null, new DirectlyLitMaterialBase[] { sphereDirect, sphereDirect }, new IndirectlyLitMaterialBase[] { sphereIndirect, sphereIndirect }, null );
            SimpleObject so3 = new SimpleObject( p1, p1.CreateNormals(), null, new DirectlyLitMaterialBase[] { checkerboardDirect, checkerboardDirect }, new IndirectlyLitMaterialBase[] { checkerboardIndirect, checkerboardIndirect }, null );

            // Create Scene
            ListScene scene = new ListScene();
            scene.Add( so1 );
            scene.Add( so2 );
            scene.Add( so3 );

            // Trace
            Framebuffer fb = new Framebuffer( Color3.Black, 500, 500 );

            Point LensLocation = new Point( 3.0f, 2.0f, 4.0f );
            Point LookAt = new Point( -1.0f, 0.45f, 0.0f );

            Cameras.Pinhole( scene, RenderMethod.RecursiveRayTrace,
                             fb, 5, 0.0001f, 0, 1.0f, true,
                             1.3f, 1.0f, 1.0f,
                             LensLocation,
                             LookAt - LensLocation,
                             new Vector( 0.0f, 1.0f, 0.0f ),
                             1, 1, false );

            Assert.IsTrue( Pfm.Compare( fb, 0.1f, 0.02f, "..\\..\\TestImages\\TestMirrorPhongCheckerboardSpheres.pfm" ) );
        }
Exemplo n.º 3
0
        public void TestPhongSphere()
        {
            Color3 a = new Color3( 0.0f, 0.0f, 0.0f );
            Color3 ds = new Color3( 1.0f, 1.0f, 1.0f );
            Vector dir = new Vector( 0.0f, 0.0f, -1.0f );

            Color3 am = new Color3( 0.2f, 0.2f, 0.2f );
            Color3 dsm = new Color3( 0.8f, 0.8f, 0.8f );

            Point center = new Point( 0.0f, 0.0f, 3.3f );

            Sphere sphere = new Sphere( center, 1.0f );

            PhongDirectMaterial mat = new PhongDirectMaterial( am, dsm, Color3.Black, 0.0f, new PhongLight[] { new DirectionalPhongLight( dir, a, ds, ds, false ) } );

            SimpleObject so = new SimpleObject( sphere, sphere.CreateNormals(), null, new DirectlyLitMaterialBase[] { mat, mat }, null, null );

            ListScene scene = new ListScene();
            scene.Add( so );

            Framebuffer fb = new Framebuffer( Color3.Black, 500, 500 );

            Cameras.Pinhole( scene, RenderMethod.RecursiveRayTrace,
                             fb, 0, 0.0001f, 0, 1.0f, true,
                             1.0f, 1.0f, 1.0f,
                             new Point( 0.0f, 0.0f, -2.0f ),
                             new Vector( 0.0f, 0.0f, 1.0f ),
                             new Vector( 0.0f, 1.0f, 0.0f ),
                             1, 1, false );

            Assert.IsTrue( Pfm.Compare( fb, 0.01f, 0.02f, "..\\..\\TestImages\\TestPhongSphere.pfm" ) );
        }
Exemplo n.º 4
0
        public void TestRedEmissiveWorldSphere()
        {
            Sphere sphere = new Sphere( new Point( 0.0f, 0.0f, 3.0f ), 1.0f );
            ConstantEmissiveMaterial s = new ConstantEmissiveMaterial( new Color3( 1.0f, 0.0f, 0.0f ) );

            SimpleObject so = new SimpleObject( sphere, null, new EmissiveMaterialBase[] { s, s }, null, null, null );

            ListScene scene = new ListScene();
            scene.Add( so );

            Framebuffer fb = new Framebuffer( Color3.Black, 500, 500 );

            Cameras.Pinhole( scene, RenderMethod.RecursiveRayTrace,
                             fb, 0, 0.0001f, 0, 1.0f, true,
                             1.0f, 1.0f, 1.0f,
                             new Point( 0.0f, 0.0f, -2.0f ),
                             new Vector( 0.0f, 0.0f, 1.0f ),
                             new Vector( 0.0f, 1.0f, 0.0f ),
                             1, 1, false );

            Assert.IsTrue( Pfm.Compare( fb, 0.01f, 0.02f, "..\\..\\TestImages\\TestRedEmissiveWorldSphere.pfm" ) );
        }
Exemplo n.º 5
0
        public void TestMirrorPhongSphere()
        {
            Sphere s1 = new Sphere( new Point( 1.0f, 0.0f, 3.0f ), 1.0f );
            Sphere s2 = new Sphere( new Point( -1.0f, 0.0f, 3.0f ), 1.0f );

            ConstantEmissiveMaterial es = new ConstantEmissiveMaterial( new Color3( 1.0f, 0.0f, 0.0f ) );
            IndirectlyLitMaterialBase Mirror = new PerfectSpecularIndirectMaterial( Color3.White );

            EmissiveMaterialBase[] array1 = new EmissiveMaterialBase[] { es, null };
            IndirectlyLitMaterialBase[] array2 = new IndirectlyLitMaterialBase[] { Mirror, null };

            SimpleObject so1 = new SimpleObject( s1, null, array1, null, null, null );
            SimpleObject so2 = new SimpleObject( s2, s2.CreateNormals(), null, null, array2, null );

            ListScene scene = new ListScene();
            scene.Add( so1 );
            scene.Add( so2 );

            Framebuffer fb = new Framebuffer( Color3.Black, 500, 500 );

            Cameras.Pinhole( scene, RenderMethod.RecursiveRayTrace,
                             fb, 1, 0.0001f, 0, 1.0f, true,
                             1.0f, 1.0f, 1.0f,
                             new Point( 0.0f, 0.0f, -2.0f ),
                             new Vector( 0.0f, 0.0f, 1.0f ),
                             new Vector( 0.0f, 1.0f, 0.0f ),
                             1, 1, false );

            Assert.IsTrue( Pfm.Compare( fb, 0.01f, 0.02f, "..\\..\\TestImages\\TestMirrorPhongSphere.pfm" ) );
        }