Ejemplo n.º 1
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);
        }
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, 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();
    }
    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();
    }
Ejemplo n.º 4
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);
        }