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); vp.max_depth = 5; 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); SV_Matte mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); TextureData textData = new TextureData(); textData.LoadTextureData(mapTexture); mat_ptr.set_cd(textData); Rectangle rect = new Rectangle(Vector3.zero, new Vector3(80, 0, 0), new Vector3(0, 70, 0), Vector2.zero, new Vector2(0, 1), new Vector2(1, 0)); Instance rectInst = new Instance(rect); rectInst.set_material(mat_ptr); add_object(rectInst); rectInst.set_identity(); rectInst.Scale(1, 1, 1); render_scene(); }
public override void Build() { vp = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT); vp.NumSamples = 25; 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, 65), new Vec3(0.0, 0.0, 0.0), new Vec3(0.0, 1.0, 0.0), 9000 /**24*/); Camera = pinhole; Directional light = new Directional(); light.SetDirection(-0.25f, 0.4f, 1.0f); light.ScaleRadiance = 2.5f; AddLight(light); //image Image image = new Image(); image.Load(PATH + "ppm/EarthLowRes.ppm"); //mapping SphericalMap sphericalMap = new SphericalMap(); //image based texture ImageTexture texture = new ImageTexture(image, sphericalMap); //textured material SV_Matte svMatte = new SV_Matte(); svMatte.SetKa(0.45f); svMatte.SetKd(0.65f); svMatte.SetCd(texture); Sphere s = new Sphere(); s.Material = svMatte; Instance earth = new Instance(s); earth.Material = svMatte; earth.RotateY(-72); earth.RotateX(40); earth.RotateZ(20); AddObject(earth); }
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); }
void MatteRender() { 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 = 1; background_color = Constants.white; 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(); pinhole_ptr1.set_eye(new Vector3(0, 0, 500)); pinhole_ptr1.set_lookat(Vector3.zero); pinhole_ptr1.set_view_distance(500.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(0, -1, 0)); directional.cast_shadows = false; directional.scale_radiance(3.0f); add_light(directional); tracer_ptr = new RayCastTracer(this); TextureData textData = new TextureData(); Model ground = new Model("Quad/Quad", "Quad/Quad_Tex", 1, out textData); SV_Matte mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); ground.SetMaterial(mat_ptr); ground.set_identity(); ground.Rotate(Constants.PI / 2, 0, 0); ground.Scale(600, 1, 1000); ground.Translate(0, -100, 0); textData = new TextureData(); Model rightSphere = new Model("Sphere/Sphere", "Sphere/Sphere_Ball_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); rightSphere.SetMaterial(mat_ptr); rightSphere.set_identity(); rightSphere.Scale(40, 40, 40); rightSphere.Translate(50.0f, -60, 80); Model leftSphere = new Model("Sphere/Sphere", "Sphere/Sphere_Ball_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); leftSphere.SetMaterial(mat_ptr); leftSphere.set_identity(); leftSphere.Scale(40, 40, 40); leftSphere.Translate(-50.0f, -60, 80); Model cube = new Model("Cube/Cube", "Cube/Cube_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); cube.SetMaterial(mat_ptr); cube.set_identity(); cube.Scale(40, 100, 40); cube.Translate(0.0f, -40, -200); Model pyramid = new Model("Pyramid/Pyramid", "Pyramid/Pyramid_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); pyramid.SetMaterial(mat_ptr); pyramid.set_identity(); pyramid.Scale(80, 100, 40); pyramid.Translate(-100.0f, -50, -800); Model pyramidRight = new Model("Pyramid/Pyramid", "Pyramid/Pyramid_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); pyramidRight.SetMaterial(mat_ptr); pyramidRight.set_identity(); pyramidRight.Scale(80, 100, 40); pyramidRight.Translate(120.0f, -50, -800); Model cubeLeft = new Model("Cube/Cube", "Cube/Cube_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); cubeLeft.SetMaterial(mat_ptr); cubeLeft.set_identity(); cubeLeft.Scale(40, 100, 40); cubeLeft.Translate(-100.0f, -40, -100); Model cubeRight = new Model("Cube/Cube", "Cube/Cube_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); cubeRight.SetMaterial(mat_ptr); cubeRight.set_identity(); cubeRight.Scale(40, 100, 40); cubeRight.Translate(100.0f, -40, -100); }