示例#1
0
        public VolumeScene(double aspect)
        {
            var red   = new Lambertian(ConstantTexture.Create(0.65, 0.05, 0.05));
            var white = new Lambertian(ConstantTexture.Create(0.73, 0.73, 0.73));
            var green = new Lambertian(ConstantTexture.Create(0.12, 0.45, 0.12));
            var light = new DiffuseLight(ConstantTexture.Create(7, 7, 7));
            var box1  = new Translate(new RotateY(new Box(Vec3.Create(0), Vec3.Create(165), white), -18), Vec3.Create(130, 0, 65));
            var box2  = new Translate(new RotateY(new Box(Vec3.Create(0), Vec3.Create(165, 330, 165), white), 15), Vec3.Create(265, 0, 295));

            IHitable[] hitables =
            {
                new FlipNormals(new YZRect(0,  555,                                    0, 555, 555, green)),
                new YZRect(0,                  555,                                    0, 555,   0, red),
                new XZRect(113,                443,                                  127, 432, 554, light),
                new FlipNormals(new XZRect(0,  555,                                    0, 555, 555, white)),
                new XZRect(0,                  555,                                    0, 555,   0, white),
                new FlipNormals(new XYRect(0,  555,                                    0, 555, 555, white)),
                new ConstantMedium(box1,      0.01, new ConstantTexture(Vec3.Create(1))),
                new ConstantMedium(box2,      0.01, new ConstantTexture(Vec3.Create(0))),
            };
            World = new BVHNode(hitables, 0, 1);
            var    lookFrom      = Vec3.Create(278, 278, -800);
            var    lookAt        = Vec3.Create(278, 278, 0);
            double dist_to_focus = 10;
            double aderpture     = 0;
            double vfov          = 40;

            Camera = Camera.CreateLookAt(lookFrom, lookAt, Vec3.Create(0, 1, 0), vfov, aspect, aderpture, dist_to_focus);
        }
        public TestScene2(double aspect)
        {
            double R = Math.Cos(Math.PI / 4);

            IHitable[] hitables =
            {
                new Sphere(Vec3.Create(-R, 0, -1), R, new Lambertian(ConstantTexture.Create(1, 0, 0))),
                new Sphere(Vec3.Create(R,  0, -1), R, new Lambertian(ConstantTexture.Create(0, 0, 1)))
            };
            World  = new BVHNode(hitables, 0, 1);
            Camera = Camera.CreateByVerticalFiled(90, aspect);
        }
 public MaterialsScene(double aspect)
 {
     IHitable[] hitables =
     {
         new Sphere(Vec3.Create(0,  -100.5, 0),   100, new Lambertian(ConstantTexture.Create(0.8, 0.8, 0.0))),
         new Sphere(Vec3.Create(0,       0, 0),   0.5, new Lambertian(ConstantTexture.Create(0.1, 0.2, 0.5))),
         new Sphere(Vec3.Create(1,       0, 0),   0.5, new Metal(ConstantTexture.Create(0.8,      0.6,   0.2),0.3)),
         new Sphere(Vec3.Create(-1,      0, 0),   0.5, new Dielectric(1.5)),
         new Sphere(Vec3.Create(-1,      0, 0), -0.45, new Dielectric(1.5))
     };
     World  = new BVHNode(hitables, 0, 1);
     Camera = Camera.CreateLookAt(Vec3.Create(0.25, 0.5, 2.2), Vec3.Create(0.1, 0.0, 0), Vec3.Create(0, 1, 0), 45, aspect, 0, 1);
 }
示例#4
0
 public TestScene1(double aspect)
 {
     IHitable[] hitables =
     {
         new Sphere(Vec3.Create(0,      0, -1),   0.5, new Lambertian(ConstantTexture.Create(0.5, 0.1, 0.1))),
         new Sphere(Vec3.Create(0, -100.5, -1), 100.0, new Lambertian(ConstantTexture.Create(0.1, 0.1, 0.1)))
     };
     World  = new BVHNode(hitables, 0, 1);
     Camera = Camera.CreateByVerticalFiled(90, aspect);
     World  = new BVHNode(hitables, 0, 1);
     Camera = new Camera(
         Vec3.Create(-2, -1, -1),
         Vec3.Create(4, 0, 0),
         Vec3.Create(0, 2, 0),
         Vec3.Create(0, 0, 0),
         0, 0, 0);
 }
示例#5
0
        public CoverSceneRT1Motion(double aspect)
        {
            var             sampler  = new Random();
            List <IHitable> hitables = new List <IHitable>();

            hitables.Add(new Sphere(Vec3.Create(0, -1000, 0), 1000, new Lambertian(CheckerTexture.Create(0.2, 0.3, 0.1, 0.9, 0.9, 0.9))));
            for (int a = -11; a < 11; ++a)
            {
                for (int b = -11; b < 11; ++b)
                {
                    double choos_mat = sampler.NextDouble();
                    Vec3   center    = Vec3.Create(a + 0.9 * sampler.NextDouble(), 0.2, b + 0.9 * sampler.NextDouble());
                    if ((center - Vec3.Create(4, 0.2, 0)).Length > 0.9)
                    {
                        if (choos_mat < 0.8) // diffuse
                        {
                            hitables.Add(new MovingSphere(center, center + Vec3.Create(0, 0.5, 0) * sampler.NextDouble(), 0, 1, 0.2,
                                                          new Lambertian(ConstantTexture.Create(sampler.NextDouble() * sampler.NextDouble(), sampler.NextDouble() * sampler.NextDouble(), sampler.NextDouble() * sampler.NextDouble()))));
                        }
                        else if (choos_mat < 0.9) // metal
                        {
                            hitables.Add(new Sphere(center, 0.2,
                                                    new Metal(ConstantTexture.Create(0.5 * (1 + sampler.NextDouble()), 0.5 * (1 + sampler.NextDouble()), 0.5 * (1 + sampler.NextDouble())), 0.5 * sampler.NextDouble())));
                        }
                        else // glass
                        {
                            hitables.Add(new Sphere(center, 0.2, new Dielectric(1.5)));
                        }
                    }
                }
            }
            hitables.Add(new Sphere(Vec3.Create(0, 1, 0), 1, new Dielectric(1.5)));
            hitables.Add(new Sphere(Vec3.Create(-4, 1, 0), 1, new Lambertian(ConstantTexture.Create(0.4, 0.2, 0.1))));
            hitables.Add(new Sphere(Vec3.Create(4, 1, 0), 1, new Metal(ConstantTexture.Create(0.7, 0.6, 0.5), 0)));
            double time0 = 0;
            double time1 = 1;

            World = new BVHNode(hitables.ToArray(), time0, time1);
            var    lookFrom      = Vec3.Create(12, 2, 3);
            var    lookAt        = Vec3.Create(0, 0, 0);
            double dist_to_focus = 10;
            double aderpture     = 0.1;

            Camera = Camera.CreateLookAt(lookFrom, lookAt, Vec3.Create(0, 1, 0), 20, aspect, aderpture, dist_to_focus, time0, time1);
        }
        public DefocusBlurScene(double aspect)
        {
            IHitable[] hitables =
            {
                new Sphere(Vec3.Create(0,  -100.5, -1),   100, new Lambertian(ConstantTexture.Create(0.8, 0.8, 0.0))),
                new Sphere(Vec3.Create(0,       0, -1),   0.5, new Lambertian(ConstantTexture.Create(0.1, 0.2, 0.5))),
                new Sphere(Vec3.Create(1,       0, -1),   0.5, new Metal(ConstantTexture.Create(0.8,      0.6,   0.2),0.3)),
                new Sphere(Vec3.Create(-1,      0, -1),   0.5, new Dielectric(1.5)),
                new Sphere(Vec3.Create(-1,      0, -1), -0.45, new Dielectric(1.5))
            };
            World = new BVHNode(hitables, 0, 1);
            var    lookFrom      = Vec3.Create(3, 3, 2);
            var    lookAt        = Vec3.Create(0, 0, -1);
            var    dist_to_focus = (lookFrom - lookAt).Length;
            double aderpture     = 2;

            Camera = Camera.CreateLookAt(lookFrom, lookAt, Vec3.Create(0, 1, 0), 25, aspect, aderpture, dist_to_focus);
        }
        public SimpleLightScene(double aspect)
        {
            var perlin_texture = NoiseTexture.Create(4, NoiseTexture.Type.SIN_Z);

            IHitable[] hitables =
            {
                new Sphere(Vec3.Create(0, -1000, 0), 1000, new Lambertian(perlin_texture)),
                new Sphere(Vec3.Create(0,     2, 0),    2, new Lambertian(perlin_texture)),
                new Sphere(Vec3.Create(0,     7, 0),    2, new DiffuseLight(ConstantTexture.Create(4,                                         4, 4))),
                new XYRect(3,                 5,  1,    3,                                        -2,new DiffuseLight(ConstantTexture.Create(4,     4, 4)))
            };
            World = new BVHNode(hitables, 0, 1);
            var    lookFrom      = Vec3.Create(25, 4, 5);
            var    lookAt        = Vec3.Create(0, 2, 0);
            double dist_to_focus = 10;
            double aderpture     = 0;

            Camera = Camera.CreateLookAt(lookFrom, lookAt, Vec3.Create(0, 1, 0), 20, aspect, aderpture, dist_to_focus);
        }
示例#8
0
        public CoverSceneRT2(double aspect)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            //string[] names = assembly.GetManifestResourceNames();
            var resource_stream  = assembly.GetManifestResourceStream("rt_2_the_next_week.raytrace.Resource.worldmap1.png");
            var worldmap_texture = Texture.Create(resource_stream);
            var perlin_texture   = NoiseTexture.Create(0.05, NoiseTexture.Type.SIN_Z);
            var hitables         = new List <IHitable>();
            var sampler          = new Random();
            var white            = new Lambertian(ConstantTexture.Create(0.73, 0.73, 0.73));
            var ground           = new Lambertian(ConstantTexture.Create(0.48, 0.83, 0.53));
            var light            = new DiffuseLight(ConstantTexture.Create(7, 7, 7));
            var emat             = new Lambertian(worldmap_texture);
            var boxList1         = new List <IHitable>();
            var nb = 20;

            for (int i = 0; i < nb; i++)
            {
                for (int j = 0; j < nb; j++)
                {
                    double w     = 100;
                    var    v_min = Vec3.Create(-1000 + i * w, 0, -1000 + j * w);
                    var    v_max = Vec3.Create(v_min.X + w, 100 * (sampler.NextDouble() + 0.01), v_min.Z + w);
                    boxList1.Add(new Box(v_min, v_max, ground));
                }
            }
            var boxList2 = new List <IHitable>();
            int ns       = 1000;

            for (int i = 0; i < ns; ++i)
            {
                boxList2.Add(new Sphere(Vec3.Create(165 * sampler.NextDouble(), 165 * sampler.NextDouble(), 165 * sampler.NextDouble()), 10, white));
            }
            hitables.Add(new BVHNode(boxList1.ToArray(), 0, 1));
            hitables.Add(new XZRect(123, 423, 147, 412, 554, light));
            var center = Vec3.Create(400, 400, 200);

            hitables.Add(new MovingSphere(center, center + Vec3.Create(30, 0, 0), 0, 1, 50,
                                          new Lambertian(new ConstantTexture(Vec3.Create(0.7, 0.3, 0.1)))));
            hitables.Add(new Sphere(Vec3.Create(260, 150, 45), 50, new Dielectric(1.5)));
            hitables.Add(new Sphere(Vec3.Create(0, 150, 145), 50,
                                    new Metal(new ConstantTexture(Vec3.Create(0.8, 0.8, 0.9)), 10)));
            var boundary1 = new Sphere(Vec3.Create(360, 150, 145), 70, new Dielectric(1.5));

            hitables.Add(boundary1);
            hitables.Add(new ConstantMedium(boundary1, 0.2, new ConstantTexture(Vec3.Create(0.2, 0.4, 0.5))));
            var boundary2 = new Sphere(Vec3.Create(0), 5000, new Dielectric(1.5));

            hitables.Add(new ConstantMedium(boundary2, 0.0001, new ConstantTexture(Vec3.Create(1.0, 1.0, 1.0))));
            hitables.Add(new Sphere(Vec3.Create(400, 200, 400), 100, emat));
            hitables.Add(new Sphere(Vec3.Create(220, 280, 300), 80, new Lambertian(perlin_texture)));
            hitables.Add(new Translate(new RotateY(new BVHNode(boxList2.ToArray(), 0, 1), 15), Vec3.Create(-100, 270, 395)));
            World = new BVHNode(hitables.ToArray(), 0, 1);
            var    lookFrom      = Vec3.Create(478, 278, -600);
            var    lookAt        = Vec3.Create(278, 278, 0);
            double dist_to_focus = 10;
            double aderpture     = 0;
            double vfov          = 40;

            Camera = Camera.CreateLookAt(lookFrom, lookAt, Vec3.Create(0, 1, 0), vfov, aspect, aderpture, dist_to_focus);
        }