void build11() { int ns = 100; world.ViewPlane.HRes = 600; world.ViewPlane.VRes = 600; 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 Regular(ns)); world.AmbientLight = occ; Pinhole cam = new Pinhole(); cam.Position = new Vector3(-6, 6, 45); cam.Target = new Vector3(0, 0, 0); cam.Distance = 5000; cam.Zoom = 1.7f; world.Camera = cam; Matte plane_material = new Matte(0.9f, 0.9f, Vector3.One); XRectangle pl = new XRectangle(new Vector3(-2.5f, 0, -2.5f), new Vector3(0, 0, 5), new Vector3(5, 0, 0), Vector3.Up); //Plane pl = new Plane(new Vector3(0), Vector3.Up); pl.SetMaterial(plane_material); world.Objects.Add(pl); PointLight light = new PointLight(); light.Color = Vector3.One; light.Position = new Vector3(-3, 3, 0); light.RadianceScale = 2.0f; float refl = 0.18f; float spec = 0.8f; float amb = 0.5f; float diff = 1f; float exp = 100; Group tree = new Group(); world.Lights.Add(light); { ImageTexture im = new ImageTexture(); Disque.Raytracer.Textures.Image imm = Extensions.CreateFromBitmap(@"C:\Users\Belal\Downloads\Earth_Diffuse_2.jpg"); im.SetImage(imm); im.SetMapping(new SphericalMap()); SV_Phong sphere_m = new SV_Phong(); sphere_m.SetCD(im); sphere_m.SetSpecularColor(im); sphere_m.SetExp(40); sphere_m.SetSpecularRC(0.2f); sphere_m.SetDiffuseRC(0.6f); sphere_m.SetAmbientRC(0.25f); Sphere sphere = new Sphere(new Vector3(0, 0f, 0), 1f); Instance ins = new Instance(sphere); ins.SetMaterial(sphere_m); ins.RotateY(MathHelper.ToRadians(90)); ins.Scale(new Vector3(0.4f)); ins.Translate(new Vector3(0, 0.4f, 0.5f)); world.Objects.Add(ins); } { Reflective smatte2 = new Reflective(); smatte2.SetAmbientRC(amb); smatte2.SetDiffuseRC(diff); smatte2.SetCD(new Vector3(1, 0.77f, 0.77f)); smatte2.SetRColor(new Vector3(1, 0.77f, 0.77f)); smatte2.SetSpecularRC(spec); smatte2.SetExp(exp); smatte2.SetReflectiveRC(refl); Sphere s = new Sphere(new Vector3(-0.8f, 0.45f, 0.1f), 0.45f); s.SetMaterial(smatte2); tree.AddObject(s); //world.Objects.Add(s); } { Reflective smatte2 = new Reflective(); smatte2.SetAmbientRC(amb); smatte2.SetDiffuseRC(diff); smatte2.SetCD(new Vector3(0.92f, 0.74f, 1)); smatte2.SetRColor(new Vector3(0.92f, 0.74f, 1)); smatte2.SetSpecularRC(spec); smatte2.SetExp(exp); smatte2.SetReflectiveRC(refl); Sphere s = new Sphere(new Vector3(0.7f, 0.4f, 1.5f), 0.4f); s.SetMaterial(smatte2); tree.AddObject(s); //world.Objects.Add(s); } { Reflective smatte2 = new Reflective(); smatte2.SetAmbientRC(amb); smatte2.SetDiffuseRC(diff); smatte2.SetCD(new Vector3(0.62f, 0f, 0.7f)); smatte2.SetRColor(new Vector3(0.62f, 0f, 0.7f)); smatte2.SetSpecularRC(spec); smatte2.SetExp(exp); smatte2.SetReflectiveRC(refl); Sphere s = new Sphere(new Vector3(-0.7f, 0.2f, 1.5f), 0.2f); s.SetMaterial(smatte2); tree.AddObject(s); //world.Objects.Add(s); } world.Objects.Add(tree); }
public static Texture CreateTextureFromElement(this RElement ele, Dictionary<string, Image> images) { string typ = ele.Name; if (typ == "ConstantColor") { return new ConstantColor(ele.Attributes[P.Col].ToVector3()); } else if (typ == "ImageTexture") { ImageTexture im = new ImageTexture(); im.SetImage(images[ele.Attributes["ImageRef"].Value]); im.SetMapping(ele.Attributes[P.Map].CreateMappingFromAttribute()); return im; } throw new Exception(); }
void build13() { int ns = 9; world.ViewPlane.HRes = 400; world.ViewPlane.VRes = 400; world.ViewPlane.SetSampler(new MultiJittered(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(0, 20, -60); cam.Target = new Vector3(0, 7.5f, 0); cam.Distance = 200; cam.Zoom = 3.5f; world.Camera = cam; float refl = 0.8f; float spec = 0.2f; float amb = 0.2f; float diff = 0.2f; float exp = 100; Plane p = new Plane(Vector3.Zero, new Vector3(0, 1, 0)); p.Shadows = true; p.SetMaterial(new Matte(0.75f, 0.75f, new Vector3(0.56, 0.45, 0.32))); world.Objects.Add(p); ImageTexture im = new ImageTexture(); Disque.Raytracer.Textures.Image imm = Extensions.CreateFromBitmap(@"C:\Users\Belal\Downloads\Earth_Diffuse_2.jpg"); im.SetImage(imm); im.SetMapping(new SphericalMap()); SV_Phong sphere_m = new SV_Phong(); sphere_m.SetCD(im); sphere_m.SetSpecularColor(new ConstantColor(Vector3.One)); sphere_m.SetExp(1); sphere_m.SetSpecularRC(1f); sphere_m.SetDiffuseRC(1f); sphere_m.SetAmbientRC(1f); Sphere sphere = new Sphere(new Vector3(0, 0f, 0), 1f); ins = new Instance(sphere); ins.SetMaterial(sphere_m); ins.RotateY(45); ins.Scale(new Vector3(10)); ins.Translate(new Vector3(0, 13, 0)); Reflective smatte2 = new Reflective(); smatte2.SetAmbientRC(amb); smatte2.SetDiffuseRC(diff); smatte2.SetCD(new Vector3(1, 0, 0)); smatte2.SetRColor(new Vector3(1)); smatte2.SetSpecularRC(spec); smatte2.SetExp(exp); smatte2.SetReflectiveRC(refl); SolidCylinder sc = new SolidCylinder(0, 3, 13); sc.SetMaterial(new Matte(0.5f, 0.5f, new Vector3(0.5f, 0.5f, 0))); world.Objects.Add(sc); world.Objects.Add(ins); PointLight light = new PointLight(); light.Color = Vector3.One; light.Position = new Vector3(0, 40, -20); light.RadianceScale = 2f; world.Lights.Add(light); }
static Texture getTexture(XElement ele) { string typ = ele.Name.LocalName; if (typ == "ConstantColor") { return new ConstantColor(getVector(getAttribute("Color", ele))); } else if (typ == "ImageTexture") { ImageTexture im = new ImageTexture(); im.SetImage(Images[getAttribute("ImageRef", ele)]); im.SetMapping(getMapping(getAttribute("Mapping", ele), ele)); return im; } throw new Exception("No recognized element."); }