void build10() { 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; Sphere ss = new Sphere(new Vector3(2f, 0.5f, 1f), 0.5f, "MainPlane"); ss.SetShadows(true); ss.SetMaterial(new Matte(0.25f, 0.5f, new Vector3(1f, 1f, 1f)) { Shadows = true }); world.Objects.Add(ss); Matte matte = new Matte(0.25f, 0.5f, new Vector3(0.5f, 0, 0.5f)); matte.Shadows = true; Box s = new Box(new Vector3(0, 0, 1), new Vector3(1, 1, 2), "Box1"); s.SetShadows(true); s.SetMaterial(matte); world.Objects.Add(s); Matte m2 = new Matte(0.25f, 0, new Vector3(1, 1, 0)); m2.Shadows = true; Box b2 = new Box(new Vector3(1, 1, 0), new Vector3(2, 2, 1), "Box2"); b2.SetMaterial(m2); b2.SetShadows(true); //world.Objects.Add(b2); Matte matte2 = new Matte(0.75f, 0.5f, new Vector3(1, 1, 1)); matte2.Shadows = true; Plane p = new Plane(Vector3.Zero, new Vector3(0, 1, 0), "Plane2"); p.SetShadows(true); p.SetMaterial(matte2); world.Objects.Add(p); Matte m5 = new Matte(0.75f, 0.1f, new Vector3(0, 0.5f, 1)); m5.Shadows = true; Annulus an = new Annulus(new Vector3(1, 1.2f, 0), Vector3.Up, 0.4f, 0.2f, "Annulus"); an.SetMaterial(m5); an.SetShadows(true); world.Objects.Add(an); Matte m6 = new Matte(0.75f, 0.1f, new Vector3(1, 0, 0.4f)); m6.Shadows = true; SolidCylinder sc = new SolidCylinder(0, 1, 0.5f, "Cs"); sc.SetShadows(true); sc.SetMaterial(m6); world.Objects.Add(sc); 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); float exp = 2000; Transparent sphere_material = new Transparent(); sphere_material.SetSpecularRC(0.5f); sphere_material.SetExp(exp); sphere_material.SetIndexOfRefraction(1.5f); sphere_material.SetReflectiveRC(0.1f); sphere_material.SetTransmissionCoefficient(0.9f); Sphere sph = new Sphere(new Vector3(2f, 0.5f, 0f), 0.5f, "s1"); sph.SetMaterial(sphere_material); world.Objects.Add(sph); Reflective smatte2 = new Reflective(); smatte2.SetAmbientRC(0.25f); smatte2.SetDiffuseRC(0.5f); smatte2.SetRColor(new Vector3(1)); smatte2.SetSpecularRC(0.15f); smatte2.SetExp(100); smatte2.SetReflectiveRC(0.75f); smatte2.SetCD(new Vector3(1)); Sphere sphere = new Sphere(new Vector3(0, 2, 0), 0.4f, "s2"); sphere.SetMaterial(smatte2); world.Objects.Add(sphere); }
void build1(int ns) { world.ViewPlane.HRes = 400; world.ViewPlane.VRes = 400; world.ViewPlane.MaxDepth = 5; world.ViewPlane.SetSamples(ns); world.Tracer = new Whitted(world); Ambient occ = new Ambient(); occ.RadianceScale = 0f; occ.Shadows = true; occ.Color = Vector3.One; world.AmbientLight = occ; Pinhole cam = new Pinhole(); cam.Position = new Vector3(0, 60, 120); cam.Distance = 100; cam.Zoom = 1400; world.Camera = cam; PointLight pl = new PointLight(); pl.Color = Vector3.One; pl.Position = new Vector3(0, 1000, 0); pl.RadianceScale = 1.0f; pl.Shadows = true; world.Lights.Add(pl); OBJReader obj = new OBJReader(File.ReadAllText(@"C:\Users\Belal\Downloads\bunny.obj.txt")); Mesh mesh = obj.GetMesh(); mesh.SetShadows(false); mesh.SetMaterial(Material.Glass); world.Objects.Add(mesh); BBox bb = mesh.GetBoundingBox(); cam.Target = (bb.Min + bb.Max) * 0.5f; Matte matte2 = new Matte(0.5f, 0.5f, new Vector3(1, 1, 1)); matte2.Shadows = true; Plane p = new Plane(new Vector3(0, -20, 0), new Vector3(0, 1, 0), "p1"); p.SetShadows(true); p.SetMaterial(matte2); world.Objects.Add(p); }
void build6(int ns) { try { world.ViewPlane.HRes = 400; world.ViewPlane.VRes = 400; world.ViewPlane.MaxDepth = 5; world.ViewPlane.SetSamples(ns); world.Tracer = new Whitted(world); Ambient occ = new Ambient(); 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 = 5000; cam.Zoom = 1; world.Camera = cam; Plastic plas = new Plastic(); Vector3 color = new Vector3(1); float ls = 0.8f; plas.ambient = new Lambertian() { Color = color, ReflectionCoefficient = ls }; plas.diffuse = new Lambertian() { Color = color, ReflectionCoefficient = ls }; plas.specular = new GlossySpecular() { SpecularColor = color, ReflectionCoefficient = ls, Exponent = 500f }; Sphere sp = new Sphere(new Vector3(0, 0.5f, 0), 0.5f, "sp"); sp.SetMaterial(plas); world.Objects.Add(sp); Matte matte2 = new Matte(0.75f, 0.5f, new Vector3(1, 1, 1)); matte2.Shadows = true; Plane p = new Plane(Vector3.Zero, new Vector3(0, 1, 0), "p1"); p.SetShadows(true); p.SetMaterial(matte2); world.Objects.Add(p); PointLight pl = new PointLight(); pl.Color = Vector3.One; pl.Position = new Vector3(0, 4, 0); pl.RadianceScale = 1.0f; pl.Shadows = true; world.Lights.Add(pl); } catch (Exception e) { MessageBox.Show(e.StackTrace); MessageBox.Show(e.TargetSite.ToString()); } }