public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 144;

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

            AmbientOccluder a = new AmbientOccluder(ColorUtils.WHITE,
                                                    0.4, 1.5);

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

            Pinhole c = new Pinhole(new Vec3(-702, -108, 270),
                                    new Vec3(-540, -100, 0),
                                    new Vec3(0, 1, 0),
                                    800, 1.5f);

            Camera = c;



            CreateIllumination();
            CreateWalls();
            CreateObjects();
        }
示例#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, 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();
    }
示例#3
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_FLOAT);
            vp.NumSamples = 4;

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

            MultiJittered sampler = new MultiJittered(vp.NumSamples);

            AmbientOccluder occluder = new AmbientOccluder();

            occluder.Color         = ColorUtils.WHITE;
            occluder.ScaleRadiance = 1.5;
            occluder.MinAmount     = 0.4f;
            occluder.Sampler       = sampler;
            AmbientLight           = occluder;

            Pinhole pinhole = new Pinhole(new Vec3(-0.731249, -0.199999, -0.3),
                                          new Vec3(-0.562499, -0.185185, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          0.6f, 1.0f);

            Camera = pinhole;

            CreateIllumination();
            CreateWalls();
            CreateObjects();
        }
示例#4
0
        void build10()
        {
            World world = new World();
            int   ns    = 49;

            world.ViewPlane.HRes = 400;
            world.ViewPlane.VRes = 400;
            world.ViewPlane.SetSampler(new Regular(ns));
            world.ViewPlane.MaxDepth = 10;
            world.Tracer             = new Whitted(world);
            AmbientOccluder occ = new AmbientOccluder();

            occ.RadianceScale = 1.0f;
            occ.MinAmount     = 0f;
            occ.Shadows       = true;
            occ.Color         = Vector3.One();
            occ.SetSampler(new MultiJittered(ns));
            world.AmbientLight = occ;
            Pinhole cam = new Pinhole();

            cam.Position = new Vector3(40, 30, 20);
            cam.Target   = new Vector3(0, 0, 0);
            cam.Distance = 5500;
            cam.Zoom     = 1.5f;
            world.Camera = cam;
            PointLight pl = new PointLight();

            pl.Color         = Vector3.One();
            pl.Position      = new Vector3(4, 4, 0);
            pl.RadianceScale = 1.0f;
            pl.Shadows       = true;
            world.Lights.Add(pl);
        }
        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);
        }
        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);
        }
示例#7
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

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

            //Ambient a = new Ambient();
            //a.ScaleRadiance = 1.0f;
            //AmbientLight = a;

            AmbientOccluder a = new AmbientOccluder();

            a.ScaleRadiance = 1.5;
            a.Color         = ColorUtils.WHITE;
            a.MinAmount     = 0.4;
            a.Sampler       = new MultiJittered(vp.NumSamples);
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(-150.0, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          800);

            Camera = pinhole;

            PointLight l = new PointLight();

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

            Phong m = new Phong();

            m.SetColor(ColorUtils.BLUE);
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            Phong m1 = new Phong();

            m1.SetColor(ColorUtils.YELLOW);
            m1.SetKa(0.2f);
            m1.SetKd(0.65f);
            m1.SetKs(0.4f);
            m1.SetExp(64.0f);

            SolidCone sc = new SolidCone(70, 60);

            sc.SetBodyMaterial(m);
            sc.SetBaseMaterial(m1);

            AddObject(sc);

            Sphere s = new Sphere(new Vec3(150, 0, 0), 50);

            s.Material = m;

            Box b = new Box(-200, -70, -50, 50, -100, 0);

            b.Material = m1;

            AddObject(s);
            AddObject(b);
        }
    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;
        background_color = Constants.white;

        tracer_ptr = new Whitted(this);

        Jittered        jit    = new Jittered(1);
        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);

        Dielectric mat_ptr = new Dielectric();

        mat_ptr.set_eta_in(0.8f);
        mat_ptr.set_eta_in(1.2f);
        mat_ptr.set_cf_in(new Color(0.0f, 1.0f, 0.8f, 1));
        mat_ptr.set_cf_out(new Color(0.75f, 1.0f, 0.4f, 1));
        mat_ptr.set_ks(0.5f);
        mat_ptr.set_exp(100.0f);
        mat_ptr.set_ior(1.2f);

        Sphere sph = new Sphere();

        sph.sphereCenter = Vector3.zero;
        sph.sphereRad    = 1.0f;
        sph.set_material(mat_ptr);

        Instance sphInst = new Instance(sph);

        sphInst.set_material(mat_ptr);
        add_object(sphInst);

        sphInst.set_identity();
        sphInst.Scale(40, 40, 1);
        sphInst.Translate(0.0f, 0.0f, -60);

        Dielectric mat_ptr1 = new Dielectric();

        mat_ptr.set_eta_in(0.2f);
        mat_ptr.set_eta_in(0.4f);
        mat_ptr1.set_cf_in(new Color(0.0f, 1.0f, 0.0f, 1));
        mat_ptr1.set_cf_out(new Color(0.75f, 1.0f, 0.0f, 1));
        mat_ptr1.set_ks(0.8f);
        mat_ptr1.set_exp(100.0f);
        mat_ptr1.set_ior(1.52f);

        Rectangle rect1 = new Rectangle(Vector3.zero, new Vector3(1, 0, 0), new Vector3(0, 1, 0));

        rect1.set_material(mat_ptr1);

        Instance rect1Inst = new Instance(rect1);

        rect1Inst.set_material(mat_ptr1);
        add_object(rect1Inst);

        rect1Inst.set_identity();
        rect1Inst.Scale(80, 80, 1);
        rect1Inst.Translate(-40, -40, 0.0f);

        render_scene();
    }
        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);
        }
示例#10
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);
        }
示例#11
0
        public RenderContext(RenderConfig config)
        {
            m_config = config;

            float aspectRatio = config.width * 1.0f / config.height;

            viewPlane         = new ViewPlane(config.width, config.height, 1f, 2);
            viewPlane.SAMPLES = config.samples;
            viewPlane.SetSampler(new JitteredSampler());

            ToneMapping.type = ToneMapping.ToneMappingType.Reinhard;
            camera           = new PerspectiveCamera(new Vector3(0, 0, -5f), Vector3.Forward, Vector3.Up, viewPlane, 60f);
            //tracer = new Tracer(this);
            tracer = new TracerAreaLigting(this);

            MatAmbientOccluder matao     = new MatAmbientOccluder();
            MatPhong           matphong  = new MatPhong(0.25f, 0.7f, 0.3f, ColourF.White, ColourF.Red, ColourF.White, 100F);
            MatPhong           matphongW = new MatPhong(0.25f, 0.7f, 0.3f, ColourF.White, ColourF.White, ColourF.White, 10F);

            Plane p1 = new Plane(new Vector3(0, 0, 4), Vector3.Backward);

            p1.SetMaterial(matphongW);
            Plane pup = new Plane(new Vector3(0, -1f, 0f), new Vector3(0, 1f, 0f));

            pup.SetMaterial(matphongW);
            Sphere spr1 = new Sphere(new Vector3(0.5f, 0f, 0f), 1.3f);

            spr1.SetMaterial(matphongW);
            Sphere spr2 = new Sphere(new Vector3(-0.8f, -0.3f, -0.5f), 0.75f);

            spr2.SetMaterial(matphong);
            //Disk disk1 = new Disk(new Vector3(3.0f, 0f, 0f), new Vector3(-0.5f, 0f, -0.1f), 0.7f);
            //disk1.SetMaterial(matphongW);

            objects.Add(pup);
            objects.Add(spr1);
            objects.Add(spr2);
            //objects.Add(disk1);

            AmbientOccluder ao = new AmbientOccluder(Vector3.One * 0.5f, Vector3.One, 0.3f);

            ao.SetSampler(new JitteredSampler(), config.samples, 5);

            ambientLight = ao;
            lights       = new List <LightBase>();

            PointLight pl = new PointLight(Vector3.Ctor(-1f, 2.5f, 2.3f), ColourF.White, 1f, 5f);

            pl.CAST_SHADOW = true;
            PointLight pl2 = new PointLight(Vector3.Ctor(0, 0f, -2.3f), Vector3.Ctor(1.0f, 0.3f, 0.1f), 1.0f, 1f);

            pl2.CAST_SHADOW = true;

            AreaLight areaLit = new AreaLight();

            areaLit.CAST_SHADOW = true;
            Disk areaLitGeom = new Disk(new Vector3(3.0f, 0.5f, 0f), new Vector3(-0.5f, 0f, -0.1f), 0.7f, false);

            areaLitGeom.SetSampler(new JitteredSampler(), config.samples, 10);
            areaLit.GEOMETRY = areaLitGeom;
            MaterialEmissive areaLitMat = new MaterialEmissive(Vector3.Ctor(1.0f, 1.0f, 1.0f), 20f);

            areaLit.MATERIAL = areaLitMat;
            areaLitGeom.SetMaterial(areaLitMat);

            objects.Add(areaLitGeom);

            //DirectionalLight dl = new DirectionalLight(Vector3.Ctor(0f,-1f,0.2f), ColourF.White, 5.0f);
            //dl.CAST_SHADOW = true;
            //lights.Add(dl);


            lights.Add(pl);
            lights.Add(pl2);
            lights.Add(areaLit);
        }