Exemplo n.º 1
0
        public void LightWorld()
        {
            Texture     perlinTex = new NoiseTexture(6.3);
            GeoMaterial redlight  = new DiffuseLight(new ConstantTexture(new SColor(0.98, 0.1, 0.08)));
            GeoMaterial bluelight = new DiffuseLight(new ConstantTexture(new SColor(0.05, 0.05, 1)));

            List <GeometryObject> list = new List <GeometryObject>();

            list.Add(new Sphere(new Point3D(-2, 3, -3), 1.5, redlight));
            list.Add(new Sphere(new Point3D(-2.2, 3.2, 2.8), 1.5, bluelight));
            list.Add(new Sphere(new Point3D(0, 0, 2.2), 1, new Metal(new ConstantTexture(new SColor(1, 1, 1)))));
            list.Add(new Sphere(new Point3D(0, 0, 0), 1, new Lambert(new ConstantTexture(new SColor(1, 1, 1)))));
            list.Add(new Sphere(new Point3D(0, 0, -2), 1, new Dielectric(1.5)));
            list.Add(new Sphere(new Point3D(0, 0, -2), -0.18, new Dielectric(1.5)));
            list.Add(new Sphere(new Point3D(0, -1000, 0), 999, new Dielectric(1.5)));
            AddGeoObj(new bvh_node(list));
        }
Exemplo n.º 2
0
        public void PerlinSphere()
        {
            Texture prlText            = new NoiseTexture(3.0);
            List <GeometryObject> list = new List <GeometryObject>();
            Sphere a = new Sphere(new Point3D(0, -1000, 0), 1000);

            a.GeoMaterial = new Lambert(prlText);
            list.Add(a);
            Sphere b = new Sphere(new Point3D(0, 2, 0), 2);

            b.GeoMaterial = new Lambert(prlText);
            //list.Add(b);

            Sphere       c            = new Sphere(new Point3D(0, 2, 0), 2);
            Bitmap       bitmap       = new Bitmap(@"C:\Users\cdd13\Desktop\学习\桌面程序开发\光线追踪素材\材质\EarthHighRes.jpg");
            ImageTexture imageTexture = new ImageTexture(new Bitmap(@"C:\Users\cdd13\Desktop\学习\桌面程序开发\光线追踪素材\材质\EarthHighRes.jpg"));

            c.GeoMaterial = new Lambert(imageTexture);
            list.Add(c);

            geometrys.Add(new GlobalGeometryList(list));
        }
Exemplo n.º 3
0
        public void Build_World()
        {
            List <GeometryObject> list = new List <GeometryObject>();
            Sphere         sphere      = new Sphere(new Point3D(0, -1000, 0), 1000);
            CheckerTexture texture     = new CheckerTexture(new ConstantTexture(new SColor(0.2, 0.3, 0.1)),
                                                            new ConstantTexture(new SColor(0.9, 0.9, 0.9)));
            NoiseTexture noiseTexture = new NoiseTexture();

            //sphere.GeoMaterial = new Lambert(noiseTexture);
            sphere.GeoMaterial = new Lambert(texture);
            list.Add(sphere);

            /*
             * for (int a0 = -11; a0 < 11; ++a0)
             * {
             *  for (int b0 = -11; b0 < 11; ++b0)
             *  {
             *      double chose_mat = Form2.random();
             *      Point3D center = new Point3D(a0 + 0.9 * Form2.random(), 0.2, b0 + 0.9 * Form2.random());
             *      if ((center - new Point3D(4, 0.2, 0)).Magnitude() > 0.9)
             *      {
             *          if (chose_mat < 0.8)
             *          {
             *              Sphere tmp = new Sphere(center, 0.2);
             *              tmp.GeoMaterial = new Lambert(
             *                  new ConstantTexture(new SColor(Form2.random() * Form2.random(), Form2.random() * Form2.random(), Form2.random() * Form2.random())));
             *              list.Add(tmp);
             *          }
             *          else if (chose_mat < 0.95)
             *          {
             *              Sphere tmp = new Sphere(center, 0.2);
             *              tmp.GeoMaterial = new Metal(
             *                  new ConstantTexture(new SColor(0.5 * (1 + Form2.random()), 0.5 * (1 + Form2.random()), 0.5 * (1 + Form2.random()))), 0.5 + Form2.random());
             *              list.Add(tmp);
             *          }
             *          else
             *          {
             *              Sphere tmp = new Sphere(center, 0.2);
             *              tmp.GeoMaterial = new Dielectric(1.5);
             *              list.Add(tmp);
             *          }
             *      }
             *  }
             * }
             */
            Sphere a = new Sphere(new Point3D(0, 1, 0), 1);

            a.GeoMaterial = new Dielectric(1.5);
            list.Add(a);
            Sphere b = new Sphere(new Point3D(-4, 1, 0), 1);

            b.GeoMaterial = new Lambert(
                new ConstantTexture(new SColor(0.4, 0.2, 0.1)));
            list.Add(b);
            Sphere c = new Sphere(new Point3D(4, 1, 0), 1);

            c.GeoMaterial = new Metal(
                new ConstantTexture(new SColor(0.7, 0.6, 0.5)), 0);
            list.Add(c);
            AddGeoObj(new bvh_node(list));
        }