예제 #1
0
        static Hitable CornellBox()
        {
            var      red      = new Lambertian(new vec3(0.65f, 0.05f, 0.05f));
            var      white    = new Lambertian(new vec3(0.73f, 0.73f, 0.73f));
            var      green    = new Lambertian(new vec3(0.12f, 0.45f, 0.15f));
            Material aluminum = new Metal(new vec3(0.8f, 0.85f, 0.88f), 0.3f);

            var light = new DiffuseLight(new SolidTexture(new vec3(15, 15, 15)));
            int i     = 0;

            Hitable[] hitables = new Hitable[8];
            hitables[i++] = new YZRect(555, 0, 555, 0, 555, green, true);
            hitables[i++] = new YZRect(0, 0, 555, 0, 555, red);
            var lightRect = new XZRect(554, 213, 343, 227, 332, light, true);

            hitables[i++] = lightRect;
            hitables[i++] = new XZRect(0, 0, 555, 0, 555, aluminum);
            hitables[i++] = new XZRect(555, 0, 555, 0, 555, white, true);
            hitables[i++] = new XYRect(555, 0, 555, 0, 555, white, true);

            //Hitable box = new Box(new vec3(0, 0, 0), new vec3(165, 165, 165), white);
            //box = new Tranlate(new RotateY(box, -18), new vec3(130, 0, 65));
            //hitables[i++] = box;
            Sphere sp = new Sphere(new vec3(190, 90.5f, 190), 90f, new Dieletric(1.6f));

            hitables[i++] = sp;
            Hitable box2 = new Box(new vec3(0, 0, 0), new vec3(165, 330, 165), white);

            box2          = new Tranlate(new RotateY(box2, 15), new vec3(265, 0, 295));
            hitables[i++] = box2;
            _lightPDf     = new LightPDF(lightRect);
            _spherePDF    = new SpherePDF(sp);
            return(new HitList(hitables.Where(p => p != null).ToArray()));
        }
예제 #2
0
        public Box(vec3 min, vec3 max, Material mat)
        {
            _aabb = new AABB(min, max);
            var sides = new Hitable[6];

            sides[0]  = new XZRect(max.y, min.x, max.x, min.z, max.z, mat);
            sides[1]  = new XZRect(min.y, min.x, max.x, min.z, max.z, mat, true);
            sides[2]  = new YZRect(max.x, min.y, max.y, min.z, max.z, mat);
            sides[3]  = new YZRect(min.x, min.y, max.y, min.z, max.z, mat, true);
            sides[4]  = new XYRect(max.z, min.x, max.x, min.y, max.y, mat);
            sides[5]  = new XYRect(min.z, min.x, max.x, min.y, max.y, mat, true);
            _sideList = new HitList(sides);
        }
예제 #3
0
        static Hitable FinalTest()
        {
            int nb = 20;

            Hitable[] list    = new Hitable[30];
            Hitable[] boxlist = new Hitable[10000];
            Material  ground  = new Lambertian(new SolidTexture(new vec3(0.48f, 0.83f, 0.53f)));
            int       b       = 0;

            for (int i = 0; i < nb; i++)
            {
                for (int j = 0; j < nb; j++)
                {
                    float w  = 100;
                    float x0 = -1000 + i * w;
                    float z0 = -1000 + j * w;
                    float y0 = 0;
                    float x1 = x0 + w;
                    float y1 = 100 * (Exten.rand01() + 0.01f);
                    float z1 = z0 + w;
                    boxlist[b++] = new Box(new vec3(x0, y0, z0), new vec3(x1, y1, z1), ground);
                }
            }
            int l = 0;

            list[l++] = new BVHNode(boxlist, 0, b, 0, 1);
            Material light = new DiffuseLight(new SolidTexture(new vec3(7, 7, 7)));

            list[l++] = new XZRect(554, 123, 423, 147, 412, light);
            vec3 center = new vec3(400, 400, 200);

            //public Sphere(vec3 c, vec3 c1, float r, Material m, float time1, float time2)
            list[l++] = new Sphere(center, center + new vec3(30, 0, 0), 50, new Lambertian(new SolidTexture(new vec3(0.7f, 0.3f, 0.1f))), 0, 1);
            list[l++] = new Sphere(new vec3(260, 150, 45), 50, new Dieletric(1.5f));
            list[l++] = new Sphere(new vec3(0, 150, 145), 50, new Metal(new vec3(0.8f, 0.8f, 0.9f), 10.0f));
            Hitable boundary = new Sphere(new vec3(360, 150, 145), 70, new Dieletric(1.5f));

            list[l++] = boundary;
            boundary  = new Sphere(new vec3(0, 0, 0), 5000, new Dieletric(1.5f));
            Texture pertext = new NoiseTexture(new Noise());

            list[l++] = new Sphere(new vec3(220, 280, 300), 80, new Lambertian(pertext));
            return(new HitList(list.Where(arg => arg != null).ToArray()));
        }
예제 #4
0
 public LightPDF(XZRect rc)
 {
     _lightArea = rc;
 }