Ejemplo n.º 1
0
    public void build()
    {
        DestroyRenderAreaTexture();

        texture = new Texture2D(200, 200);
        GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture;
        vp = new ViewPlane(texture.width, texture.height, 1.0f, 256);
        background_color = Constants.black;

        tracer_ptr = new RayCastTracer(this);

        Jittered        jit    = new Jittered(256);
        AmbientOccluder ambocl = new AmbientOccluder();

        ambocl.scale_radiance(1.0f);
        ambocl.set_color(Constants.white);
        ambocl.set_minAmount(Constants.black);
        ambocl.SetSampler(jit);
        set_ambient_light(ambocl);


        PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera();

        pinhole_ptr1.set_eye(new Vector3(0, 0, 500));
        pinhole_ptr1.set_lookat(Vector3.zero);
        pinhole_ptr1.set_view_distance(600.0f);
        pinhole_ptr1.compute_uvw();
        set_camera(pinhole_ptr1);

        Directional directional = new Directional();

        directional.set_color(new Color(1, 1, 1, 1));
        directional.set_direction(new Vector3(-1, -1, 0));
        directional.cast_shadows = true;
        directional.scale_radiance(3.0f);
        add_light(directional);

        Matte mat_ptr = new Matte();

        mat_ptr.set_ka(0.25f);
        mat_ptr.set_kd(0.65f);
        mat_ptr.set_cd(new Color(1, 1, 0, 1));

        Sphere sphere = new Sphere();

        sphere.sphereCenter = new Vector3(0, 0, 0);
        sphere.sphereRad    = 20.0f;
        sphere.set_material(mat_ptr);

        Instance sphereInst = new Instance(sphere);

        sphereInst.set_material(mat_ptr);


        add_object(sphereInst);

        sphereInst.set_identity();
        sphereInst.Shear(1.15f, 0.6f, 1.2f, 1.8f, 2.2f, 2.4f);
        render_scene();
    }
Ejemplo n.º 2
0
    public void build()
    {
        DestroyRenderAreaTexture();

        texture = new Texture2D(200, 200);
        GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture;
        vp = new ViewPlane(texture.width, texture.height, 1.0f, 100);
        background_color = Constants.black;

        tracer_ptr = new AreaLightTracer(this);

        Ambient ambLight = new Ambient();

        ambLight.set_color(new Color(1, 1, 1, 1));
        ambLight.scale_radiance(1.0f);
        set_ambient_light(ambLight);

        PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera();

        set_camera(pinhole_ptr1);

        Emissive ems = new Emissive();

        ems.scale_radiance(40.0f);
        ems.set_ce(new Color(1, 0, 0, 1));

        //Create Sky Object
        Sky sky = new Sky();

        sky.sphereCenter = new Vector3(0, 0, 0);
        sky.sphereRad    = 20000.0f;
        sky.set_material(ems);
        add_object(sky);

        //Create Environment Light
        Environment envLight = new Environment();

        envLight.set_material(ems);
        envLight.SetSampler(new Regular(100));
        add_light(envLight);


        Matte mat_ptr = new Matte();

        mat_ptr.set_ka(0.25f);
        mat_ptr.set_kd(0.65f);
        mat_ptr.set_cd(new Color(1, 1, 0, 1));

        Sphere sphere = new Sphere();

        sphere.sphereCenter = new Vector3(-20, 0, 0);
        sphere.sphereRad    = 30.0f;
        sphere.set_material(mat_ptr);


        add_object(sphere);

        render_scene();
    }
Ejemplo n.º 3
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 1;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 20),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          3600);

            Camera = pinhole;

            Directional l = new Directional();

            l.SetDirection(-10, 20, 20);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = false;
            AddLight(l);

            int numSpheres = 1000000;

            double volume = 0.1 / numSpheres;
            double radius = Math.Pow(0.75 * volume / Math.PI, 0.333333);

            Grid grid = new Grid();

            Rnd.SetRandSeed(15);

            for (int j = 0; j < numSpheres; j++)
            {
                Matte matte = new Matte();
                matte.SetKa(0.25f);
                matte.SetKd(0.75f);
                matte.SetColor(new Vec3(Rnd.RandDouble(),
                                        Rnd.RandDouble(),
                                        Rnd.RandDouble()));

                Sphere sphere = new Sphere();
                sphere.Radius = radius;
                sphere.SetCenter(1.0f - 2.0f * (float)Rnd.RandDouble(),
                                 1.0f - 2.0f * (float)Rnd.RandDouble(),
                                 1.0f - 2.0f * (float)Rnd.RandDouble());
                sphere.Material = matte;
                grid.AddObject(sphere);
            }

            grid.SetupCells();

            AddObject(grid);
        }
Ejemplo n.º 4
0
        private void CreateWalls()
        {
            //chão
            Matte m1 = new Matte();

            m1.SetColor(new Vec3(0.4, 0.3, 0.3));
            m1.SetKa(0.2f);
            m1.SetKd(0.7f);
            Plane p1 = new Plane(new Vec3(0, -324, 0), new Vec3(0, 1, 0));

            p1.Material = m1;

            //fundos
            Matte m2 = new Matte();

            m2.SetColor(new Vec3(0.6, 0.5, 0.5));
            m2.SetKa(0.2f);
            m2.SetKd(1.0f);
            Plane p2 = new Plane(new Vec3(0, 0, -2419), new Vec3(0, 0, 1));

            p2.Material = m2;

            //esquerda
            Matte m3 = new Matte();

            m3.SetColor(new Vec3(0.5, 0.5, 0.6));
            m3.SetKa(0.2f);
            m3.SetKd(1.0f);
            Plane p3 = new Plane(new Vec3(-1296, 0, 0), new Vec3(1, 0, 0));

            p3.Material = m3;

            //direita
            Matte m4 = new Matte();

            m4.SetColor(new Vec3(0.5, 0.5, 0.6));
            m4.SetKa(0.2f);
            m4.SetKd(1.0f);
            Plane p4 = new Plane(new Vec3(1296, 0, 0), new Vec3(-1, 0, 0));

            p4.Material = m4;

            //teto
            Matte m5 = new Matte();

            m5.SetColor(new Vec3(0.7, 0.7, 0.7));
            m5.SetKa(0.2f);
            m5.SetKd(0.7f);
            Plane p5 = new Plane(new Vec3(0, 820, 0), new Vec3(0, -1, 0));

            p5.Material = m5;

            AddObject(p1);
            AddObject(p2);
            AddObject(p3);
            AddObject(p4);
            AddObject(p5);
        }
        public override void Build()
        {
            int numSamples = 4;

            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = numSamples;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            MultiJittered sampler = new MultiJittered(numSamples);

            sampler.Generate();

            AmbientOccluder occluder = new AmbientOccluder();

            occluder.ScaleRadiance = 1.0;
            occluder.Color         = ColorUtils.WHITE;
            occluder.MinAmount     = 0.0;
            occluder.Sampler       = sampler;
            AmbientLight           = occluder;

            Pinhole pinhole = new Pinhole(new Vec3(25.0, 20.0, 45.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          5000.0f);

            pinhole.ComputeUVW();
            Camera = pinhole;

            Matte matte = new Matte();

            matte.SetKa(0.75f);
            matte.SetKd(0.0f);
            matte.SetColor(1.0f, 0.7f, 0.0f);

            Sphere s = new Sphere(new Vec3(0, 1, 0), 1);

            s.Material = matte;
            AddObject(s);

            matte = new Matte();
            matte.SetKa(0.75f);
            matte.SetKd(0.0f);
            matte.SetColor(ColorUtils.WHITE);

            Plane p = new Plane(new Vec3(0, 0, 0), new Vec3(0, 1, 0));

            p.Material = matte;
            AddObject(p);
        }
Ejemplo n.º 6
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 500.0),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          2000.0f);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(0, 100, -20);
            l.ScaleRadiance = 20.0f;
            l.Shadows       = false;
            AddLight(l);

            Triangle t = new Triangle(new Vec3(0, 50, 0),
                                      new Vec3(-50, -50, 0),
                                      new Vec3(50, -50, 0));
            Matte matte = new Matte();

            matte.SetKa(0.2f);
            matte.SetKd(0.5f);
            matte.SetColor(new Vec3(0.8, 0.6, 0.2));

            t.Material = matte;
            t.Shadows  = false;

            AddObject(t);
        }
Ejemplo n.º 7
0
    public void build()
    {
        DestroyRenderAreaTexture();

        texture = new Texture2D(200, 200);
        GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture;
        vp           = new ViewPlane(texture.width, texture.height, 1.0f, 1);
        vp.max_depth = 5;

        tracer_ptr = new GlobalTracer(this);

        Ambient amblight = new Ambient();

        amblight.scale_radiance(1.0f);
        amblight.set_color(new Color(1, 1, 1, 1));
        set_ambient_light(amblight);


        PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera();

        pinhole_ptr1.set_eye(new Vector3(0, 0, 500));
        pinhole_ptr1.set_lookat(Vector3.zero);
        pinhole_ptr1.set_view_distance(600.0f);
        pinhole_ptr1.compute_uvw();
        set_camera(pinhole_ptr1);

        Directional directional = new Directional();

        directional.set_color(new Color(1, 1, 1, 1));
        directional.set_direction(new Vector3(-1, -1, 0));
        directional.cast_shadows = false;
        directional.scale_radiance(3.0f);
        add_light(directional);

        Reflective mat_ptr = new Reflective();

        mat_ptr.set_kr(1.0f);
        mat_ptr.set_exp(1.0f);
        mat_ptr.set_cr(sphere_1_col);

        Sphere sphere = new Sphere();

        sphere.sphereCenter = new Vector3(0, 0, 0);
        sphere.sphereRad    = 1.0f;
        sphere.set_material(mat_ptr);

        Instance sphereInst = new Instance(sphere);

        sphereInst.set_material(mat_ptr);
        add_object(sphereInst);

        sphereInst.set_identity();
        sphereInst.Scale(20, 20, 20);
        sphereInst.Translate(60.0f, 20.0f, 0);

        Matte mat_ptr1 = new Matte();

        mat_ptr1.ambient_brdf.Set_Sampler(100, 0.5f);
        mat_ptr1.diffuse_brdf.Set_Sampler(100, 0.5f);
        mat_ptr1.set_ka(1.0f);
        mat_ptr1.set_kd(1);
        mat_ptr1.set_cd(plane_col);


        Plane p = new Plane();

        p.planeNormal       = new Vector3(0, 1, 0);
        p.planePassThrghPnt = new Vector3(0, -20, 0);
        p.set_material(mat_ptr1);
        add_object(p);

        Emissive mat_ptr2 = new Emissive();

        mat_ptr2.scale_radiance(1);
        mat_ptr2.set_ce(sphere_2_col);

        Sphere sphere1 = new Sphere();

        sphere1.sphereCenter = new Vector3(0, 0, 0);
        sphere1.sphereRad    = 1.0f;
        sphere1.set_material(mat_ptr2);

        Instance sphereInst1 = new Instance(sphere1);

        sphereInst1.set_material(mat_ptr2);
        add_object(sphereInst1);

        sphereInst1.set_identity();
        sphereInst1.Scale(20, 20, 20);
        sphereInst1.Translate(-60.0f, 20.0f, 0);

        render_scene();
    }
Ejemplo n.º 8
0
        public override void Build()
        {
            vp                = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples     = 64;
            vp.ShowOutOfGamut = 2;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new AreaLighting(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 500.0),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          2000.0f);

            Camera = pinhole;

            Emissive emissive = new Emissive();

            emissive.ScaleRadiance = 40.0f;
            emissive.Ce            = ColorUtils.WHITE;

            MultiJittered sampler = new MultiJittered(256);

            sampler.Generate();

            Rectangle rectangle = new Rectangle(new Vec3(100.0, 100.0, 200.0),
                                                new Vec3(216.0, 0.0, 0.0),
                                                new Vec3(0.0, 0.0, 216.0));

            rectangle.Shadows = false;

            RectangularLamp lamp = new RectangularLamp(rectangle, emissive);

            lamp.Sampler = sampler;
            AddObject(lamp);

            AreaLight areaLight = new AreaLight();

            areaLight.Object  = lamp;
            areaLight.Shadows = true;
            AddLight(areaLight);

            Vec3 lightGreen = new Vec3(0.65f, 1.0f, 0.30f);
            Vec3 green      = new Vec3(0.0f, 0.6f, 0.3f);
            Vec3 darkGreen  = new Vec3(0.0f, 0.41f, 0.41f);

            Vec3 yellow     = new Vec3(1.0f, 1.0f, 0.0f);
            Vec3 darkYellow = new Vec3(0.61f, 0.61f, 0.0f);

            Vec3 lightPurple = new Vec3(0.65f, 0.3f, 1.0f);
            Vec3 darkPurple  = new Vec3(0.5f, 0.0f, 1.0f);

            Vec3 brown  = new Vec3(0.71f, 0.40f, 0.16f);
            Vec3 orange = new Vec3(1.0f, 0.75f, 0.0f);

            Matte matte = new Matte();

            matte.SetKa(0.2f);
            matte.SetKd(0.5f);
            matte.SetColor(ColorUtils.WHITE);

            Plane p = new Plane(new Vec3(0, -85, 0), new Vec3(0, 1, 0));

            p.Material = matte;
            AddObject(p);

            Matte m = new Matte();

            //Plastic *m = new Plastic();
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            //m.SetKs(0.1f);
            //m.SetExp(8.0f);
            m.SetColor(ColorUtils.WHITE);

            Sphere s = new Sphere(new Vec3(5, 3, 0), 30);

            s.Material = m;

            AddObject((Sphere)s.Clone());

            s.SetCenter(45, -7, -60);
            s.Radius = 20;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(40, 43, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, 28, -15);
            s.Radius = 20;
            m.SetColor(orange);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-25, -7, -35);
            s.Radius = 27;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(20, -27, -35);
            s.Radius = 25;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(35, 18, -35);
            s.Radius = 22;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-57, -17, -50);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-47, 16, -80);
            s.Radius = 23;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-15, -32, -60);
            s.Radius = 22;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-35, -37, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(10, 43, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -7, -80);
            s.Radius = 10;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-40, 48, -110);
            s.Radius = 18;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-10, 53, -120);
            s.Radius = 18;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-55, -52, -100);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, -52, -100);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, -57, -120);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, -27, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(50, -47, -120);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(70, -42, -150);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, 73, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(66, 21, -130);
            s.Radius = 13;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(72, -12, -140);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(64, 5, -160);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, 38, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-73, -2, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -62, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(25, 63, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-60, 46, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-30, 68, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(58, 56, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-63, -39, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(46, 68, -200);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-3, -72, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject(s);
        }
        public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 144;
            vp.MaxDepth   = 10;

            backgroundColor = new Vec3(0.15);
            tracer          = new AreaLighting(this);

            AmbientOccluder a = new AmbientOccluder();

            a.ScaleRadiance = 0.5;
            a.MinAmount     = 0.05;
            a.Sampler       = new MultiJittered(vp.NumSamples);
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(75, 40, 100),
                                          new Vec3(-10, 39, 0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          360, 3.0f);

            Camera = pinhole;

            Rectangle rectangle = new Rectangle(new Vec3(75, 40, 100),
                                                new Vec3(0, 50, 0),
                                                new Vec3(50, 0, -50));
            Emissive        e    = new Emissive(ColorUtils.WHITE, 20);
            RectangularLamp lamp = new RectangularLamp(rectangle, e);

            lamp.Sampler = new MultiJittered(vp.NumSamples);
            lamp.Shadows = false;

            AddObject(lamp);

            AreaLight light = new AreaLight();

            light.Object = lamp;

            AddLight(light);

            Reflective reflective1 = new Reflective();

            reflective1.SetKa(0.25f);
            reflective1.SetKd(0.5f);
            reflective1.SetColor(0.75f, 0.75f, 0.0f);
            reflective1.SetSpecularColor(ColorUtils.WHITE);
            reflective1.SetKs(0.15f);
            reflective1.SetExp(100.0f);
            reflective1.SetKr(0.75f);
            reflective1.SetReflectiveColor(ColorUtils.WHITE);

            double radius = 23.0;
            Sphere s1     = new Sphere(new Vec3(38, radius, -25), radius);

            s1.Material = reflective1;
            AddObject(s1);

            Matte matte1 = new Matte();

            matte1.SetKa(0.45f);
            matte1.SetKd(0.75f);
            matte1.SetColor(0.75f, 0.25f, 0.0f);

            Sphere s2 = new Sphere(new Vec3(-7, 10, 42), 20);

            s2.Material = matte1;
            AddObject(s2);

            Reflective reflective2 = new Reflective();

            reflective2.SetKa(0.35f);
            reflective2.SetKd(0.75f);
            reflective2.SetColor(ColorUtils.BLACK);
            reflective2.SetSpecularColor(ColorUtils.WHITE);
            reflective2.SetKs(0.0f);
            reflective2.SetExp(1.0f);
            reflective2.SetKr(0.75f);
            reflective2.SetReflectiveColor(ColorUtils.WHITE);

            Sphere s3 = new Sphere(new Vec3(-30, 59, 35), 20);

            s3.Material = reflective2;
            AddObject(s3);

            //cylinder
            Reflective reflective3 = new Reflective();

            reflective3.SetKa(0.35f);
            reflective3.SetKd(0.5f);
            reflective3.SetColor(0.0f, 0.5f, 0.75f);
            reflective3.SetSpecularColor(ColorUtils.WHITE);
            reflective3.SetKs(0.2f);
            reflective3.SetExp(100.0f);
            reflective3.SetKr(0.75f);
            reflective3.SetReflectiveColor(ColorUtils.WHITE);

            float b  = 0.0f;
            float t  = 85f;
            float cr = 22f;

            SolidCylinder cylinder = new SolidCylinder(b, t, cr);

            cylinder.Material = reflective3;
            AddObject(cylinder);

            //box
            Matte matte2 = new Matte();

            matte2.SetKa(0.15f);
            matte2.SetKd(0.5f);
            matte2.SetColor(0.75f, 1.0f, 0.75f);

            Box box = new Box(new Vec3(-35, 0, -110),
                              new Vec3(-25, 60, 65));

            box.Material = matte2;
            AddObject(box);

            //plane
            Matte matte3 = new Matte();

            matte3.SetKa(0.30f);
            matte3.SetKd(0.9f);
            matte3.SetColor(ColorUtils.WHITE);

            Plane plane = new Plane(new Vec3(),
                                    new Vec3(0, 1, 0));

            plane.Material = matte3;

            AddObject(plane);
        }
Ejemplo n.º 10
0
        public override void Build()
        {
            vp = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            //vp.NumSamples = 4096;
            vp.NumSamples = 400;
            vp.MaxDepth   = 10;

            backgroundColor = ColorUtils.BLACK;

            tracer = new GlobalTrace(this);
            //tracer = new PathTrace(this);

            Ambient ambient = new Ambient();

            ambient.ScaleRadiance = 0;
            AmbientLight          = ambient;

            Pinhole camera = new Pinhole();

            camera.SetEye(27.6, 27.4, -80);
            camera.SetLookat(27.6, 27.4, 0.0);
            camera.ViewPlaneDistance = 1200;
            Camera = camera;

            Vec3 p0;
            Vec3 a, b;
            Vec3 normal;

            // box dimensions

            double width  = 55.28;     // x direction
            double height = 54.88;     // y direction
            double depth  = 55.92;     // z direction


            Emissive emissive = new Emissive(new Vec3(1.0, 0.73, 0.4), 100);

            p0     = new Vec3(21.3, height - 0.001, 22.7);
            a      = new Vec3(0.0, 0.0, 10.5);
            b      = new Vec3(13.0, 0.0, 0.0);
            normal = new Vec3(0.0, -1.0, 0.0);

            RectangularLamp lamp = new RectangularLamp(new Rectangle(p0, a, b, normal), emissive);

            lamp.Sampler = new MultiJittered(vp.NumSamples);
            AddObject(lamp);

            AreaLight ceilingLight = new AreaLight();

            ceilingLight.Object = lamp;
            AddLight(ceilingLight);


            // left wall

            Matte matte1 = new Matte();

            matte1.SetKa(0.0f);
            matte1.SetKd(0.6f);
            matte1.SetColor(0.57f, 0.025f, 0.025f);     // red
            matte1.SetSampler(new MultiJittered(vp.NumSamples));

            p0     = new Vec3(width, 0.0, 0.0);
            a      = new Vec3(0.0, 0.0, depth);
            b      = new Vec3(0.0, height, 0.0);
            normal = new Vec3(-1.0, 0.0, 0.0);
            Rectangle leftWall = new Rectangle(p0, a, b, normal);

            leftWall.Material = matte1;
            AddObject(leftWall);


            // right wall

            Matte matte2 = new Matte();

            matte2.SetKa(0.0f);
            matte2.SetKd(0.6f);
            matte2.SetColor(0.37f, 0.59f, 0.2f);    // green
            matte2.SetSampler(new MultiJittered(vp.NumSamples));

            p0     = new Vec3(0.0, 0.0, 0.0);
            a      = new Vec3(0.0, 0.0, depth);
            b      = new Vec3(0.0, height, 0.0);
            normal = new Vec3(1.0, 0.0, 0.0);
            Rectangle rightWall = new Rectangle(p0, a, b, normal);

            rightWall.Material = matte2;
            AddObject(rightWall);


            // back wall

            Matte matte3 = new Matte();

            matte3.SetKa(0.0f);
            matte3.SetKd(0.6f);
            matte3.SetColor(ColorUtils.WHITE);
            matte3.SetSampler(new MultiJittered(vp.NumSamples));

            p0     = new Vec3(0.0, 0.0, depth);
            a      = new Vec3(width, 0.0, 0.0);
            b      = new Vec3(0.0, height, 0.0);
            normal = new Vec3(0.0, 0.0, -1.0);
            Rectangle backWall = new Rectangle(p0, a, b, normal);

            backWall.Material = matte3;
            AddObject(backWall);


            // floor

            p0     = new Vec3(0.0, 0.0, 0.0);
            a      = new Vec3(0.0, 0.0, depth);
            b      = new Vec3(width, 0.0, 0.0);
            normal = new Vec3(0.0, 1.0, 0.0);
            Rectangle floor = new Rectangle(p0, a, b, normal);

            floor.Material = matte3;
            AddObject(floor);


            // ceiling

            p0     = new Vec3(0.0, height, 0.0);
            a      = new Vec3(0.0, 0.0, depth);
            b      = new Vec3(width, 0.0, 0.0);
            normal = new Vec3(0.0, -1.0, 0.0);
            Rectangle ceiling = new Rectangle(p0, a, b, normal);

            ceiling.Material = matte3;
            AddObject(ceiling);


            // the two boxes defined as 5 rectangles each

            // short box

            // top

            p0     = new Vec3(13.0, 16.5, 6.5);
            a      = new Vec3(-4.8, 0.0, 16.0);
            b      = new Vec3(16.0, 0.0, 4.9);
            normal = new Vec3(0.0, 1.0, 0.0);
            Rectangle shortTop = new Rectangle(p0, a, b, normal);

            shortTop.Material = matte3;
            AddObject(shortTop);


            // side 1

            p0 = new Vec3(13.0, 0.0, 6.5);
            a  = new Vec3(-4.8, 0.0, 16.0);
            b  = new Vec3(0.0, 16.5, 0.0);
            Rectangle shortSide1 = new Rectangle(p0, a, b);

            shortSide1.Material = matte3;
            AddObject(shortSide1);


            // side 2

            p0 = new Vec3(8.2, 0.0, 22.5);
            a  = new Vec3(15.8, 0.0, 4.7);
            Rectangle shortSide2 = new Rectangle(p0, a, b);

            shortSide2.Material = matte3;
            AddObject(shortSide2);


            // side 3

            p0 = new Vec3(24.2, 0.0, 27.4);
            a  = new Vec3(4.8, 0.0, -16.0);
            Rectangle shortSide3 = new Rectangle(p0, a, b);

            shortSide3.Material = matte3;
            AddObject(shortSide3);


            // side 4

            p0 = new Vec3(29.0, 0.0, 11.4);
            a  = new Vec3(-16.0, 0.0, -4.9);
            Rectangle shortSide4 = new Rectangle(p0, a, b);

            shortSide4.Material = matte3;
            AddObject(shortSide4);



            // tall box

            // top

            p0     = new Vec3(42.3, 33.0, 24.7);
            a      = new Vec3(-15.8, 0.0, 4.9);
            b      = new Vec3(4.9, 0.0, 15.9);
            normal = new Vec3(0.0, 1.0, 0.0);
            Rectangle tallTop = new Rectangle(p0, a, b, normal);

            tallTop.Material = matte3;
            AddObject(tallTop);


            // side 1

            p0 = new Vec3(42.3, 0.0, 24.7);
            a  = new Vec3(-15.8, 0.0, 4.9);
            b  = new Vec3(0.0, 33.0, 0.0);
            Rectangle tallSide1 = new Rectangle(p0, a, b);

            tallSide1.Material = matte3;
            AddObject(tallSide1);


            // side 2

            p0 = new Vec3(26.5, 0.0, 29.6);
            a  = new Vec3(4.9, 0.0, 15.9);
            Rectangle tallSide2 = new Rectangle(p0, a, b);

            tallSide2.Material = matte3;
            AddObject(tallSide2);


            // side 3

            p0 = new Vec3(31.4, 0.0, 45.5);
            a  = new Vec3(15.8, 0.0, -4.9);
            Rectangle tallSide3 = new Rectangle(p0, a, b);

            tallSide3.Material = matte3;
            AddObject(tallSide3);


            // side 4

            p0 = new Vec3(47.2, 0.0, 40.6);
            a  = new Vec3(-4.9, 0.0, -15.9);
            Rectangle tallSide4 = new Rectangle(p0, a, b);

            tallSide4.Material = matte3;
            AddObject(tallSide4);
        }
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 100;
            vp.MaxDepth   = 10;

            backgroundColor = new Vec3(0.0, 0.3, 0.25);
            tracer          = new Whitted(this);

            //AmbientOccluder a = new AmbientOccluder(ColorUtils.WHITE,
            //                                        0.25, 1.0);
            //a.Sampler = new MultiJittered(vp.NumSamples);
            Ambient a = new Ambient();

            a.ScaleRadiance = 0.25f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(1, 7.5, 20),
                                          new Vec3(0.0, -0.35, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          5250);

            Camera = pinhole;

            Emissive e = new Emissive();

            e.ScaleRadiance = 3.0f;
            e.Ce            = ColorUtils.WHITE;

            RectangularLamp lamp = new RectangularLamp(
                new Rectangle(new Vec3(0, 20, 0),
                              new Vec3(1, 0, 0),
                              new Vec3(0, 0, 1),
                              new Vec3(0, -1, 0)),
                e);

            lamp.Sampler = new MultiJittered(vp.NumSamples);
            AddObject(lamp);

            AreaLight areaLight = new AreaLight();

            areaLight.Object  = lamp;
            areaLight.Shadows = true;
            AddLight(areaLight);

            //PointLight l = new PointLight();
            //l.SetLocation(20, 20, 15);
            //l.ScaleRadiance = 3.0f;
            //AddLight(l);

            Transparent glass = new Transparent();

            glass.SetKs(0.5f);
            glass.SetExp(2000);
            glass.SetIor(1.5f);
            glass.SetKr(0.1f);
            glass.SetKt(1.53f);
            //glass.SetCd(0.4f);

            float ir = 0.9f;
            float or = 1;

            //Bowl b = Bowl.CreateFlatRimmedBowl(ir, or);
            Bowl b = Bowl.CreateRoundRimmedBowl(ir, or);

            b.Material = glass;
            AddObject(b);

            Reflective reflective = new Reflective();

            reflective.SetKa(0.6f);
            reflective.SetKd(0.4f);
            reflective.SetCd(ColorUtils.RED);
            reflective.SetKs(0.5f);
            reflective.SetExp(2000);
            reflective.SetKr(0.25f);

            double r = 0.4;
            double t = 55;

            t = MathUtils.PI * t / 180;
            double x = -(0.9 - r) * Math.Cos(t);
            double y = -(0.9 - r) * Math.Sin(t);

            Sphere s = new Sphere(new Vec3(x, y, 0), r, reflective);

            AddObject(s);

            Reflective reflective2 = new Reflective();

            reflective2.SetKa(0.6f);
            reflective2.SetKd(0.4f);
            reflective2.SetCd(ColorUtils.YELLOW);
            reflective2.SetKs(0.5f);
            reflective2.SetExp(2000);
            reflective2.SetKr(0.5f);

            r = 0.35;
            t = 35;
            t = MathUtils.PI * t / 180;
            x = (0.9 - r) * Math.Cos(t);
            y = -(0.9 - r) * Math.Sin(t);

            Sphere s2 = new Sphere(new Vec3(x, y, 0), r, reflective2);

            AddObject(s2);

            Matte rm = new Matte();

            rm.SetColor(ColorUtils.WHITE);
            rm.SetKa(0.8f);
            rm.SetKd(0.85f);

            Rectangle rectangle = new Rectangle(new Vec3(-2, -1, -5),
                                                new Vec3(0, 0, 9),
                                                new Vec3(4, 0, 0));

            rectangle.Material = rm;
            AddObject(rectangle);
        }
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new AreaLighting(this);

            MultiJittered sampler = new MultiJittered(vp.NumSamples);

            sampler.Generate();

            AmbientOccluder occluder = new AmbientOccluder(ColorUtils.WHITE, 0.0);

            occluder.Sampler = sampler;
            //occluder.ScaleRadiance = 1.0;
            //occluder.Color = ColorUtils.WHITE;
            //occluder.SetMinAmount(0.0f);
            AmbientLight = occluder;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 500.0),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          2000.0f);

            Camera = pinhole;

            Emissive emissive = new Emissive(ColorUtils.WHITE, 20.0f);

            //emissive.ScaleRadiance = 1.0f;
            //emissive.Ce = new Vec3(1.0, 1.0, 1.0);

            sampler = new MultiJittered(256);
            sampler.Generate();

            ConcaveSphere sphere = new ConcaveSphere(new Vec3(), 10000.0);

            //sphere.Radius = 10000.0;
            sphere.Sampler          = sampler;
            sphere.Material         = emissive;
            sphere.EmissiveMaterial = emissive;
            sphere.Shadows          = false;
            AddObject(sphere);

            sampler = new MultiJittered(256);
            sampler.Generate();

            EnvironmentLight l = new EnvironmentLight();

            l.Material = emissive;
            l.Sampler  = sampler;
            l.Sampler.MapSamplesToHemisphere(10);
            l.Shadows = true;
            AddLight(l);

            //Rectangle rectangle = new Rectangle(new Vec3(0.0, 100.0, 0.0),
            //                                    new Vec3(216.0, 0.0, 0.0),
            //                                    new Vec3(0.0, 0.0, 216.0));
            //emissive = new Emissive();
            //emissive.ScaleRadiance = 1.0f;
            //emissive.Ce = ColorUtils.WHITE;

            //rectangle.Material = emissive;
            //rectangle.Sampler = sampler;
            //rectangle.Shadows = false;
            //AddObject(rectangle);

            AreaLight areaLight = new AreaLight();

            areaLight.Object  = sphere;
            areaLight.Shadows = true;
            AddLight(areaLight);

            Vec3 lightGreen = new Vec3(0.65f, 1.0f, 0.30f);
            Vec3 green      = new Vec3(0.0f, 0.6f, 0.3f);
            Vec3 darkGreen  = new Vec3(0.0f, 0.41f, 0.41f);

            Vec3 yellow     = new Vec3(1.0f, 1.0f, 0.0f);
            Vec3 darkYellow = new Vec3(0.61f, 0.61f, 0.0f);

            Vec3 lightPurple = new Vec3(0.65f, 0.3f, 1.0f);
            Vec3 darkPurple  = new Vec3(0.5f, 0.0f, 1.0f);

            Vec3 brown  = new Vec3(0.71f, 0.40f, 0.16f);
            Vec3 orange = new Vec3(1.0f, 0.75f, 0.0f);

            Matte matte = new Matte();

            matte.SetKa(0.2f);
            matte.SetKd(0.5f);
            matte.SetColor(ColorUtils.WHITE);

            Plane p = new Plane(new Vec3(0, -85, 0), new Vec3(0, 1, 0));

            p.Material = matte;
            AddObject(p);

            Phong m = new Phong();

            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.1f);
            m.SetExp(8.0f);
            m.SetColor(ColorUtils.WHITE);

            Sphere s = new Sphere(new Vec3(5, 3, 0), 30);

            s.Material = m;

            AddObject((Sphere)s.Clone());

            s.SetCenter(45, -7, -60);
            s.Radius = 20;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(40, 43, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, 28, -15);
            s.Radius = 20;
            m.SetColor(orange);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-25, -7, -35);
            s.Radius = 27;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(20, -27, -35);
            s.Radius = 25;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(35, 18, -35);
            s.Radius = 22;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-57, -17, -50);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-47, 16, -80);
            s.Radius = 23;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-15, -32, -60);
            s.Radius = 22;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-35, -37, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(10, 43, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -7, -80);
            s.Radius = 10;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-40, 48, -110);
            s.Radius = 18;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-10, 53, -120);
            s.Radius = 18;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-55, -52, -100);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, -52, -100);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, -57, -120);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, -27, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(50, -47, -120);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(70, -42, -150);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, 73, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(66, 21, -130);
            s.Radius = 13;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(72, -12, -140);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(64, 5, -160);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, 38, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-73, -2, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -62, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(25, 63, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-60, 46, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-30, 68, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(58, 56, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-63, -39, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(46, 68, -200);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-3, -72, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject(s);
        }
Ejemplo n.º 13
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 64;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            AmbientOccluder a = new AmbientOccluder(ColorUtils.WHITE,
                                                    0.25, 1.0);

            a.Sampler    = new MultiJittered(vp.NumSamples);
            AmbientLight = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            Emissive e = new Emissive();

            e.ScaleRadiance = 8.0f;
            e.Ce            = ColorUtils.WHITE;

            Rectangle rectangle = new Rectangle(new Vec3(0.0, 200.0, 100.0),
                                                new Vec3(216.0, 0.0, 0.0),
                                                new Vec3(0.0, 0.0, 216.0));

            rectangle.Shadows = false;

            RectangularLamp lamp = new RectangularLamp(rectangle, e);

            lamp.Sampler = new MultiJittered(vp.NumSamples);
            AddObject(lamp);

            AreaLight areaLight = new AreaLight();

            areaLight.Object  = lamp;
            areaLight.Shadows = true;
            AddLight(areaLight);

            //PointLight l = new PointLight();
            //l.Color = ColorUtils.WHITE;
            //l.SetLocation(100, 100, 200);
            //l.ScaleRadiance = 3.0f;
            //l.Shadows = true;
            //AddLight(l);

            Phong m = new Phong();

            m.SetColor(new Vec3(0.6, 0.2, 0.02));
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            Phong i = new Phong();

            i.SetColor(new Vec3(0.8, 0.4, 0.02));
            i.SetKa(0.2f);
            i.SetKd(0.65f);
            i.SetKs(0.4f);
            i.SetExp(64.0f);

            //Bowl b = Bowl.CreateFlatRimmedBowl(75, 80);
            //Bowl b = Bowl.CreateRoundRimmedBowl(75, 80);
            Bowl b = Bowl.Create(75, 80, true);

            b.SetExternalMaterial(m);
            b.SetInternalMaterial(i);
            b.SetBorderMaterial(i);

            AddObject(b);

            Plane p  = new Plane(new Vec3(0, -80, 0), new Vec3(0, 1, 0));
            Matte pm = new Matte();

            pm.SetColor(new Vec3(0.2, 0.2, 0.2));
            pm.SetKa(0.2f);
            pm.SetKd(0.6f);
            p.Material = pm;

            AddObject(p);
        }
Ejemplo n.º 14
0
 public object ToImageflowDynamic() => new { libpng = new { depth = BitDepth?.ToString().ToLowerInvariant(), zlib_compression = ZlibCompression, matte = Matte?.ToImageflowDynamic() } };
Ejemplo n.º 15
0
        public static void buildCornelBox(Construction primitives, IIllumination lights, double diffuse,
                                          Tracer tracer, IRandomFactory randomFactory, IHemispherecalSamplerFactory hemiSamplerFactory)
        {
            IMaterial matte         = new Matte(diffuse, Constant.WHITE, primitives, lights, tracer, randomFactory, hemiSamplerFactory);
            IMaterial emitter       = new Emissive(Constant.WHITE, 1.0, 50.0);
            var       rightMaterial = new Matte(diffuse, Constant.GREEN, primitives, lights, tracer, randomFactory, hemiSamplerFactory);
            var       leftMaterial  = new Matte(diffuse, Constant.RED, primitives, lights, tracer, randomFactory, hemiSamplerFactory);

            // 下面
#if true
            #region Floor
            //white
            //552.8 0.0   0.0
            //  0.0 0.0   0.0
            //  0.0 0.0 559.2
            //549.6 0.0 559.2
            primitives.add(new Triangle(
                               new Vector3D(552.8, 0.0, 0.0),
                               new Vector3D(0.0, 0.0, -559.2),
                               new Vector3D(0.0, 0.0, 0.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(552.8, 0.0, 0.0),
                               new Vector3D(549.6, 0.0, -559.2),
                               new Vector3D(0.0, 0.0, -559.2),
                               matte));
            #endregion Floor
#endif

            // 照明
            #region Light
            //343.0 548.8 227.0
            //343.0 548.8 332.0
            //213.0 548.8 332.0
            //213.0 548.8 227.0
            var light1 = new Triangle(
                new Vector3D(343.0, 548, -227.0),
                new Vector3D(213.0, 548, -332.0),
                new Vector3D(343.0, 548, -332.0),
                emitter);
            primitives.add(light1);
            lights.addLight(light1);
            var light2 = new Triangle(
                new Vector3D(343.0, 548, -227.0),
                new Vector3D(213.0, 548, -227.0),
                new Vector3D(213.0, 548, -332.0),
                emitter);
            primitives.add(light2);
            lights.addLight(light2);
            #endregion Light

            // 上面
#if true
            #region Ceiling
            //556.0 548.8   0.0
            //556.0 548.8 559.2
            //0.0 548.8 559.2
            //0.0 548.8   0.0
            primitives.add(new Triangle(
                               new Vector3D(556.0, 548.8, 0.0),
                               new Vector3D(0.0, 548.8, -559.2),
                               new Vector3D(556.0, 548.8, -559.2),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(556.0, 548.8, 0.0),
                               new Vector3D(0.0, 548.8, 0.0),
                               new Vector3D(0.0, 548.8, -559.2),
                               matte));
            #endregion Ceiling
#endif

            // 背面
#if true
            #region Backward
            //549.6   0.0 559.2
            //0.0   0.0 559.2
            //0.0 548.8 559.2
            //556.0 548.8 559.2
            primitives.add(new Triangle(
                               new Vector3D(549.6, 0.0, -559.2),
                               new Vector3D(0.0, 548.8, -559.2),
                               new Vector3D(0.0, 0.0, -559.2),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(549.6, 0.0, -559.2),
                               new Vector3D(556.0, 548.8, -559.2),
                               new Vector3D(0.0, 548.8, -559.2),
                               matte));
            #endregion Backward
#endif

#if true
            // 左面
            #region Left
            //0.0   0.0 559.2
            //0.0   0.0   0.0
            //0.0 548.8   0.0
            //0.0 548.8 559.2
            primitives.add(new Triangle(
                               new Vector3D(0.0, 0.0, -559.2),
                               new Vector3D(0.0, 548.8, 0.0),
                               new Vector3D(0.0, 0.0, 0.0),
                               leftMaterial));
            primitives.add(new Triangle(
                               new Vector3D(0.0, 0.0, -559.2),
                               new Vector3D(0.0, 548.8, -559.2),
                               new Vector3D(0.0, 548.8, 0.0),
                               leftMaterial));
            #endregion Left
#endif

#if true
            // 右面
            #region Right
            //552.8   0.0   0.0
            //549.6   0.0 559.2
            //556.0 548.8 559.2
            //556.0 548.8   0.0
            primitives.add(new Triangle(
                               new Vector3D(552.8, 0.0, 0.0),
                               new Vector3D(556.0, 548.8, -559.2),
                               new Vector3D(549.6, 0.0, -559.2),
                               rightMaterial));
            primitives.add(new Triangle(
                               new Vector3D(552.8, 0.0, 0.0),
                               new Vector3D(556.0, 548.8, 0.0),
                               new Vector3D(556.0, 548.8, -559.2),
                               rightMaterial));
            #endregion Right
#endif

            // 小さい箱
#if true
            #region SmallBox
            //130.0 165.0  65.0
            // 82.0 165.0 225.0
            //240.0 165.0 272.0
            //290.0 165.0 114.0
            primitives.add(new Triangle(
                               new Vector3D(130.0, 165.0, -65.0),
                               new Vector3D(240.0, 165.0, -272.0),
                               new Vector3D(82.0, 165.0, -225.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(130.0, 165.0, -65.0),
                               new Vector3D(290.0, 165.0, -114.0),
                               new Vector3D(240.0, 165.0, -272.0),
                               matte));

            //290.0   0.0 114.0
            //290.0 165.0 114.0
            //240.0 165.0 272.0
            //240.0   0.0 272.0
            primitives.add(new Triangle(
                               new Vector3D(290.0, 0.0, -114.0),
                               new Vector3D(240.0, 165.0, -272.0),
                               new Vector3D(290.0, 165.0, -114.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(290.0, 0.0, -114.0),
                               new Vector3D(240.0, 0.0, -272.0),
                               new Vector3D(240.0, 165.0, -272.0),
                               matte));

            //130.0   0.0  65.0
            //130.0 165.0  65.0
            //290.0 165.0 114.0
            //290.0   0.0 114.0
            primitives.add(new Triangle(
                               new Vector3D(130.0, 0.0, -65.0),
                               new Vector3D(290.0, 165.0, -114.0),
                               new Vector3D(130.0, 165.0, -65.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(130.0, 0.0, -65.0),
                               new Vector3D(290.0, 0.0, -114),
                               new Vector3D(290.0, 165.0, -114.0),
                               matte));

            // 82.0   0.0 225.0
            // 82.0 165.0 225.0
            //130.0 165.0  65.0
            //130.0   0.0  65.0
            primitives.add(new Triangle(
                               new Vector3D(82.0, 0.0, -225.0),
                               new Vector3D(130.0, 165.0, -65.0),
                               new Vector3D(82.0, 165.0, -225.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(82.0, 0.0, -225.0),
                               new Vector3D(130.0, 0.0, -65.0),
                               new Vector3D(130.0, 165.0, -65.0),
                               matte));

            //240.0   0.0 272.0
            //240.0 165.0 272.0
            // 82.0 165.0 225.0
            // 82.0   0.0 225.0
            primitives.add(new Triangle(
                               new Vector3D(240.0, 0.0, -272.0),
                               new Vector3D(82.0, 165.0, -225.0),
                               new Vector3D(240.0, 165.0, -272.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(240.0, 0.0, -272.0),
                               new Vector3D(82.0, 0.0, -225.0),
                               new Vector3D(82.0, 165.0, -225.0),
                               matte));
            #endregion SmallBox
#endif

            // 大きい箱
#if true
            #region BigBox
            //423.0 330.0 247.0
            //265.0 330.0 296.0
            //314.0 330.0 456.0
            //472.0 330.0 406.0
            primitives.add(new Triangle(
                               new Vector3D(423.0, 330.0, -247.0),
                               new Vector3D(314.0, 330.0, -456.0),
                               new Vector3D(265.0, 330.0, -296.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(423.0, 330.0, -247.0),
                               new Vector3D(472.0, 330.0, -406.0),
                               new Vector3D(314.0, 330.0, -456.0),
                               matte));

            //423.0   0.0 247.0
            //423.0 330.0 247.0
            //472.0 330.0 406.0
            //472.0   0.0 406.0
            primitives.add(new Triangle(
                               new Vector3D(423.0, 0.0, -247.0),
                               new Vector3D(472.0, 330.0, -406.0),
                               new Vector3D(423.0, 330.0, -247.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(423.0, 0.0, -247.0),
                               new Vector3D(472.0, 0.0, -406.0),
                               new Vector3D(472.0, 330.0, -406.0),
                               matte));

            //472.0   0.0 406.0
            //472.0 330.0 406.0
            //314.0 330.0 456.0
            //314.0   0.0 456.0
            primitives.add(new Triangle(
                               new Vector3D(472.0, 0.0, -406.0),
                               new Vector3D(314.0, 330.0, -456.0),
                               new Vector3D(472.0, 330.0, -406.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(472.0, 0.0, -406.0),
                               new Vector3D(314.0, 0.0, -456.0),
                               new Vector3D(314.0, 330.0, -456.0),
                               matte));

            //314.0   0.0 456.0
            //314.0 330.0 456.0
            //265.0 330.0 296.0
            //265.0   0.0 296.0
            primitives.add(new Triangle(
                               new Vector3D(314.0, 0.0, -456.0),
                               new Vector3D(265.0, 330.0, -296.0),
                               new Vector3D(314.0, 330.0, -456.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(314.0, 0.0, -456.0),
                               new Vector3D(265.0, 0.0, -296.0),
                               new Vector3D(265.0, 330.0, -296.0),
                               matte));

            //265.0   0.0 296.0
            //265.0 330.0 296.0
            //423.0 330.0 247.0
            //423.0   0.0 247.0
            primitives.add(new Triangle(
                               new Vector3D(265.0, 0.0, -296.0),
                               new Vector3D(423.0, 330.0, -247.0),
                               new Vector3D(265.0, 330.0, -296.0),
                               matte));
            primitives.add(new Triangle(
                               new Vector3D(265.0, 0.0, -296.0),
                               new Vector3D(423.0, 0.0, -247.0),
                               new Vector3D(423.0, 330.0, -247.0),
                               matte));
            #endregion BigBox
#endif
        }
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 16;
            vp.MaxDepth   = 5;

            backgroundColor = new Vec3(0.5);
            tracer          = new Whitted(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 0.5f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(5, 6, 10),
                                          new Vec3(0.0, 1.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          2000);

            Camera = pinhole;

            PointLight light1 = new PointLight();

            light1.SetLocation(40, 50, 30);
            light1.ScaleRadiance = 3.0f;
            AddLight(light1);

            Vec3 glassColor  = new Vec3(0.65, 1.0, 0.75);
            Vec3 liquidColor = new Vec3(1.0, 0.25, 1.0);

            Dielectric glass = new Dielectric();

            glass.SetEtaIn(1.50f);
            glass.SetEtaOut(1.0f);
            glass.SetCfIn(glassColor);
            glass.SetCfOut(1, 1, 1);

            Dielectric liquid = new Dielectric();

            liquid.SetEtaIn(1.33f);
            liquid.SetEtaOut(1.0f);
            liquid.SetCfIn(liquidColor);
            liquid.SetCfOut(1, 1, 1);

            Dielectric dielectric = new Dielectric();

            dielectric.SetEtaIn(1.33f);
            dielectric.SetEtaOut(1.50f);
            dielectric.SetCfIn(liquidColor);
            dielectric.SetCfOut(glassColor);

            //double height = 2.0;
            //double innerRadius = 0.9;
            //double wallThickness = 0.1;
            //double baseThickness = 0.3;
            //double waterHeight = 1.5;
            //double meniscusRadius = 0.1;

            double glassHeight  = 2.0;
            double liquidHeight = 1.5;
            double innerRadius  = 0.991;
            double outerRadius  = 1.0;

            GlassWithLiquid glassWithLiquid = new GlassWithLiquid(glassHeight,
                                                                  liquidHeight,
                                                                  innerRadius,
                                                                  outerRadius);

            //GlassWithLiquid glassWithLiquid = new GlassWithLiquid(
            //                                                      height,
            //                                                      innerRadius,
            //                                                      wallThickness,
            //                                                      baseThickness,
            //                                                      waterHeight,
            //                                                      meniscusRadius);

            glassWithLiquid.SetGlassAirMaterial(glass);
            glassWithLiquid.SetLiquidAirMaterial(liquid);
            glassWithLiquid.SetLiquidGlassMaterial(dielectric);
            AddObject(glassWithLiquid);

            Matte matte = new Matte();

            matte.SetColor(1, 1, 0);
            matte.SetKa(0.25f);
            matte.SetKd(0.65f);

            Instance straw = new Instance(new OpenCylinder(-1.2, 1.7, 0.05));

            straw.Material = matte;
            straw.RotateZ(40);
            straw.Translate(0, 1.25f, 0);
            //straw.ComputeBoundingBox();
            AddObject(straw);

            // ground plane
            Checker3D checker = new Checker3D();

            checker.Size = 0.5f;
            checker.SetColor1(0.75f);
            checker.SetColor2(1);

            SV_Matte svMatte = new SV_Matte();

            svMatte.SetKa(0.5f);
            svMatte.SetKd(0.75f);
            svMatte.SetCd(checker);

            Plane plane = new Plane(new Vec3(0, -0.01, 0),
                                    new Vec3(0, 1, 0));

            plane.Material = svMatte;
            AddObject(plane);
        }
Ejemplo n.º 17
0
        public override void Build()
        {
            vp                = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples     = 16;
            vp.ShowOutOfGamut = 0;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 500.0),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          2000.0f);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(100, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Vec3 lightGreen = new Vec3(0.65f, 1.0f, 0.30f);
            Vec3 green      = new Vec3(0.0f, 0.6f, 0.3f);
            Vec3 darkGreen  = new Vec3(0.0f, 0.41f, 0.41f);

            Vec3 yellow     = new Vec3(1.0f, 1.0f, 0.0f);
            Vec3 darkYellow = new Vec3(0.61f, 0.61f, 0.0f);

            Vec3 lightPurple = new Vec3(0.65f, 0.3f, 1.0f);
            Vec3 darkPurple  = new Vec3(0.5f, 0.0f, 1.0f);

            Vec3 brown  = new Vec3(0.71f, 0.40f, 0.16f);
            Vec3 orange = new Vec3(1.0f, 0.75f, 0.0f);

            Matte matte = new Matte();

            matte.SetKa(0.2f);
            matte.SetKd(0.5f);
            matte.SetColor(ColorUtils.WHITE);

            Plane p = new Plane(new Vec3(0, -85, 0), new Vec3(0, 1, 0));

            p.Material = matte;
            AddObject(p);

            Phong m = new Phong();

            //Plastic *m = new Plastic();
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.1f);
            m.SetExp(8.0f);
            m.SetColor(ColorUtils.WHITE);

            Sphere s = new Sphere(new Vec3(5, 3, 0), 30);

            s.Material = m;

            AddObject((Sphere)s.Clone());

            s.SetCenter(45, -7, -60);
            s.Radius = 20;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(40, 43, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, 28, -15);
            s.Radius = 20;
            m.SetColor(orange);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-25, -7, -35);
            s.Radius = 27;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(20, -27, -35);
            s.Radius = 25;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(35, 18, -35);
            s.Radius = 22;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-57, -17, -50);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-47, 16, -80);
            s.Radius = 23;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-15, -32, -60);
            s.Radius = 22;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-35, -37, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(10, 43, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -7, -80);
            s.Radius = 10;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-40, 48, -110);
            s.Radius = 18;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-10, 53, -120);
            s.Radius = 18;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-55, -52, -100);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, -52, -100);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, -57, -120);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, -27, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(50, -47, -120);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(70, -42, -150);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, 73, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(66, 21, -130);
            s.Radius = 13;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(72, -12, -140);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(64, 5, -160);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, 38, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-73, -2, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -62, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(25, 63, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-60, 46, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-30, 68, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(58, 56, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-63, -39, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(46, 68, -200);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-3, -72, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject(s);
        }
Ejemplo n.º 18
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 64;
            vp.MaxDepth   = 10;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new Whitted(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(7.5, 3, 9.5),
                                          new Vec3(5.0, 2.5, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          800);

            Camera = pinhole;

            PointLight l1 = new PointLight();

            l1.Color = ColorUtils.WHITE;
            l1.SetLocation(10, 10, 0);
            l1.ScaleRadiance = 2.0f;
            AddLight(l1);

            PointLight l2 = new PointLight();

            l2.Color = ColorUtils.WHITE;
            l2.SetLocation(0, 10, 10);
            l2.ScaleRadiance = 2.0f;
            AddLight(l2);

            PointLight l3 = new PointLight();

            l3.Color = ColorUtils.WHITE;
            l3.SetLocation(-10, 10, 0);
            l3.ScaleRadiance = 2.0f;
            AddLight(l3);

            PointLight l4 = new PointLight();

            l4.Color = ColorUtils.WHITE;
            l4.SetLocation(0, 10, -10);
            l4.ScaleRadiance = 2.0f;
            AddLight(l4);

            //sphere
            Reflective r1 = new Reflective();

            r1.SetKa(0.1f);
            r1.SetKd(0.4f);
            r1.SetCd(0, 0, 1);
            r1.SetKs(0.25f);
            r1.SetExp(100.0f);
            r1.SetKr(0.85f);
            r1.SetReflectiveColor(0.75f, 0.75f, 1.0f);
            //r1.SetSpecularColor(ColorUtils.WHITE);

            Sphere s1 = new Sphere(new Vec3(0, 0.5, 0), 4);

            s1.Material = r1;
            AddObject(s1);

            //wall
            double roomSize = 11.0;

            //floor
            Matte m1 = new Matte(new Vec3(0.25), 0.1f, 0.50f);

            Plane floor = new Plane(new Vec3(0, -roomSize, 0), new Vec3(0, 1, 0));

            floor.Material = m1;
            AddObject(floor);

            //ceiling
            Matte m2 = new Matte(ColorUtils.WHITE, 0.35f, 0.50f);

            Plane ceiling = new Plane(new Vec3(0, roomSize, 0), new Vec3(0, -1, 0));

            ceiling.Material = m2;
            AddObject(ceiling);

            //back
            Matte m3 = new Matte(new Vec3(0.5, 0.75, 0.75), 0.15f, 0.60f);

            Plane back = new Plane(new Vec3(0, 0, -roomSize), new Vec3(0, 0, 1));

            back.Material = m3;
            AddObject(back);

            //front
            Plane front = new Plane(new Vec3(0, 0, roomSize), new Vec3(0, 0, -1));

            front.Material = m3;
            AddObject(front);

            //left
            Matte m4 = new Matte(new Vec3(0.71, 0.40, 0.20), 0.15f, 0.60f);

            Plane left = new Plane(new Vec3(-roomSize, 0, 0), new Vec3(1, 0, 0));

            left.Material = m4;
            AddObject(left);

            //front
            Plane right = new Plane(new Vec3(roomSize, 0, 0), new Vec3(-1, 0, 0));

            right.Material = m4;
            AddObject(right);

            //mirrors
            double mirrorSize = 8;
            double offset     = 1.0;

            Reflective r2 = new Reflective();

            r2.SetKa(0.0f);
            r2.SetKd(0.0f);
            r2.SetCd(0, 0, 0);
            r2.SetKs(0.0f);
            r2.SetExp(2.0f);
            r2.SetKr(0.9f);
            r2.SetReflectiveColor(0.9f, 1.0f, 0.9f);
            //r2.SetSpecularColor(ColorUtils.WHITE);

            float           e = 25000;
            GlossyReflector g = new GlossyReflector();

            g.SetSamples(vp.NumSamples, e);
            g.SetKa(0.0f);
            g.SetKd(0.0f);
            g.SetKs(0.0f);
            g.SetExp(e);
            g.SetCd(0, 0, 0);
            g.SetKr(0.9f);
            g.SetExponent(e);
            g.SetReflectiveColor(0.9f, 1.0f, 0.9f);
            //r.SetSpecularColor(ColorUtils.WHITE);
            //back
            Rectangle rect1 = new Rectangle(new Vec3(-mirrorSize, -mirrorSize, -(roomSize - offset)),
                                            new Vec3(2.0 * mirrorSize, 0, 0),
                                            new Vec3(0, 2.0 * mirrorSize, 0),
                                            new Vec3(0, 0, 1),
                                            g);

            AddObject(rect1);

            //front
            Rectangle rect2 = new Rectangle(new Vec3(-mirrorSize, -mirrorSize, +(roomSize - offset)),
                                            new Vec3(2.0 * mirrorSize, 0, 0),
                                            new Vec3(0, 2.0 * mirrorSize, 0),
                                            new Vec3(0, 0, -1),
                                            g);

            AddObject(rect2);

            //left
            Rectangle rect3 = new Rectangle(new Vec3(-(roomSize - offset), -mirrorSize, mirrorSize),
                                            new Vec3(0, 0, -2.0 * mirrorSize),
                                            new Vec3(0, 2.0 * mirrorSize, 0),
                                            new Vec3(1, 0, 0),
                                            r2);

            AddObject(rect3);

            //
            Reflective r3 = new Reflective();

            r3.SetKa(0.0f);
            r3.SetKd(0.0f);
            r3.SetCd(0, 0, 0);
            r3.SetKs(0.0f);
            r3.SetExp(2.0f);
            r3.SetKr(1.0f);
            r3.SetReflectiveColor(1.0f, 1.0f, 0.5f);
            //r3.SetSpecularColor(ColorUtils.WHITE);

            Rectangle rect4 = new Rectangle(new Vec3(-mirrorSize, -4.0, -mirrorSize),
                                            new Vec3(0, 0, 2.0 * mirrorSize),
                                            new Vec3(2.0 * mirrorSize, 0, 0),
                                            new Vec3(0, 1, 0),
                                            r3);

            AddObject(rect4);
        }
Ejemplo n.º 19
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 100;
            vp.MaxDepth   = 5;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new PathTrace(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 0.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(100, 45, 100),
                                          new Vec3(-10, 40, 0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          800, 1.5f);

            Camera = pinhole;

            Emissive emissive = new Emissive(ColorUtils.WHITE, 1.5f);

            ConcaveSphere sphere = new ConcaveSphere();

            sphere.Radius   = 1000000;
            sphere.Shadows  = false;
            sphere.Material = emissive;
            AddObject(sphere);

            float ka = 0.2f;

            Matte m1 = new Matte();

            m1.SetKa(ka);
            m1.SetKd(0.60f);
            m1.SetColor(ColorUtils.WHITE);
            m1.SetSampler(new MultiJittered(vp.NumSamples));

            Sphere largeSphere = new Sphere(new Vec3(38, 20, -24), 20);

            largeSphere.Material = m1;
            AddObject(largeSphere);

            Matte m2 = new Matte();

            m2.SetKa(ka);
            m2.SetKd(0.5f);
            m2.SetColor(0.85f);
            m2.SetSampler(new MultiJittered(vp.NumSamples));

            Sphere smallSphere = new Sphere(new Vec3(34, 12, 13), 12);

            smallSphere.Material = m2;
            AddObject(smallSphere);

            Matte m3 = new Matte();

            m3.SetKa(ka);
            m3.SetKd(0.75f);
            m3.SetColor(0.73f, 0.22f, 0.0f);
            m3.SetSampler(new MultiJittered(vp.NumSamples));

            Sphere mediumSphere = new Sphere(new Vec3(-7, 15, 42), 16);

            mediumSphere.Material = m3;
            AddObject(mediumSphere);

            Matte m4 = new Matte();

            m4.SetKa(ka);
            m4.SetKd(0.75f);
            m4.SetColor(0.60f);
            m4.SetSampler(new MultiJittered(vp.NumSamples));

            float b = 0;
            float t = 85;
            float r = 22;

            SolidCylinder cylinder = new SolidCylinder(b, t, r, m4);

            AddObject(cylinder);

            Matte m5 = new Matte();

            m5.SetKa(ka);
            m5.SetKd(0.75f);
            m5.SetColor(0.95f);
            m5.SetSampler(new MultiJittered(vp.NumSamples));

            Box box = new Box(new Vec3(-55, 0, -110),
                              new Vec3(-25, 60, 65),
                              m5);

            AddObject(box);

            Matte m6 = new Matte();

            m6.SetKa(0.15f);
            m6.SetKd(0.95f);
            m6.SetColor(0.37f, 0.43f, 0.08f);
            m6.SetSampler(new MultiJittered(vp.NumSamples));

            Plane plane = new Plane(new Vec3(0, 0.01, 0),
                                    new Vec3(0, 1, 0),
                                    m6);

            AddObject(plane);
        }
Ejemplo n.º 20
0
        public static void Build14_21(World world)
        {
            world.ViewPlane           = new ViewPlane();
            world.ViewPlane.HRes      = 400;
            world.ViewPlane.VRes      = 400;
            world.ViewPlane.PixelSize = 1;
            world.ViewPlane.Gamma     = 1;
            //world.ViewPlane.SamplesCount = 25;
            world.ViewPlane.Sampler = new Hammersley(1, 16);
            world.BackgroundColor   = new RGBColor(0, 0, 0);
            world.Tracer            = new RayCast(world);
            world.AmbientLight      = new Ambient();

            PinholeCamera pinholeCamera = new PinholeCamera(850);

            pinholeCamera.SetUpCamera(
                new Vector3d(0, 0, 500),
                new Vector3d(5, 0, 0));
            world.Camera = pinholeCamera;

            Point pointLight = new Point();

            pointLight.Location   = new Vector3d(100, 50, 150);
            pointLight.LightScale = 3;
            world.AddLight(pointLight);

            //Sphere 1
            Matte matte1 = new Matte();

            matte1.KA    = 0.25;
            matte1.KD    = 0.65;
            matte1.Color = new RGBColor(1, 1, 0);

            Sphere sphere1 = new Sphere(new Point3d(10, 5, 0), 27);

            sphere1.Material = matte1;
            world.AddObject(sphere1);

            //Sphere 2
            Matte matte2 = new Matte();

            matte2.KA    = 0.15;
            matte2.KD    = 0.85;
            matte2.Color = new RGBColor(0.71, 0.40, 0.16);

            Sphere sphere2 = new Sphere(new Point3d(-25, 10, -35), 27);

            sphere2.Material = matte2;
            world.AddObject(sphere2);

            //Plane
            Matte matte3 = new Matte();

            matte3.KA    = 0.15;
            matte3.KD    = 0.5;
            matte3.Color = new RGBColor(0, 0.4, 0.2);

            Phong phong = new Phong();

            phong.KA    = 0;
            phong.KD    = 0;
            phong.KS    = 1;
            phong.Color = new RGBColor(0, 0.4, 0.2);

            Vector3d normal = new Vector3d(0, 1, 0);

            normal.Normalize();

            Plane plane = new Plane(new Point3d(0, -10, 0),
                                    normal);

            plane.Material = phong;
            world.AddObject(plane);
        }
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 1;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(),
                                          new Vec3(-100, 0, 0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          400);

            Camera = pinhole;

            Directional l1 = new Directional();

            l1.SetDirection(1, 0, 0);
            l1.ScaleRadiance = 1.0f;
            l1.Shadows       = true;

            Directional l2 = new Directional();

            l2.SetDirection(0, 1, 0);
            l2.ScaleRadiance = 2.0f;
            l2.Shadows       = true;

            Directional l3 = new Directional();

            l3.SetDirection(0, 0, 1);
            l3.ScaleRadiance = 1.5f;
            l3.Shadows       = true;

            Directional l4 = new Directional();

            l4.SetDirection(-1, 0, 0);
            l4.ScaleRadiance = 1.0f;
            l4.Shadows       = true;

            Directional l5 = new Directional();

            l5.SetDirection(0, -1, 0);
            l5.ScaleRadiance = 1.5f;
            l5.Shadows       = true;

            Directional l6 = new Directional();

            l6.SetDirection(0, 0, -1);
            l6.ScaleRadiance = 1.5f;
            l6.Shadows       = true;

            AddLight(l1);
            AddLight(l2);
            AddLight(l3);
            AddLight(l4);
            AddLight(l5);
            AddLight(l6);

            int numSpheres = 25;

            double volume = 0.1 / numSpheres;
            float  radius = (float)(2.5 * Math.Pow(0.75 * volume / Math.PI, 0.333333));

            Grid grid = new Grid();

            Rnd.SetRandSeed(14);

            for (int j = 0; j < numSpheres; j++)
            {
                Matte matte = new Matte();
                matte.SetKa(0.25f);
                matte.SetKd(0.85f);
                matte.SetColor(new Vec3(Rnd.RandDouble(),
                                        Rnd.RandDouble(),
                                        Rnd.RandDouble()));

                Sphere sphere = new Sphere();
                sphere.Material = matte;

                Instance instance = new Instance(sphere);
                instance.Scale(radius, radius, radius);
                instance.Translate(new Vec3(1.0 - 2.0 * Rnd.RandDouble(),
                                            1.0 - 2.0 * Rnd.RandDouble(),
                                            1.0 - 2.0 * Rnd.RandDouble()));
                instance.ComputeBoundingBox();

                grid.AddObject(instance);
            }

            grid.SetupCells();

            AddObject(grid);
        }