private IntersectableList GenerateSpheres() { var list = new IntersectableList(); list.Add(new Sphere(new Vector3(0, 0, 2), 0.5f, new Metal(new Vector3(0.831f, 0.686f, 0.216f), 0.991f))); list.Add(new Sphere(new Vector3(0.3f, -0.2f, 1.2f), 0.2f, new Metal(new Vector3(0.533f, 0.604f, 0.592f), 0.1f))); list.Add(new Sphere(new Vector3(-1.1f, 0, 2), 0.5f, new Lambertian(new Vector3(1f, 0.263f, 0.643f)))); list.Add(new Sphere(new Vector3(0, 100.5f, 2), 100, new Lambertian(new Vector3(0.086f, 0.357f, 0.192f)))); return(list); }
public SkyBoxScene() { FileName = "Assignment4_SkyBox.jpg"; Camera.FieldOfViewX = 30f; Camera.FieldOfViewY = 30f; Camera.ScreenWidth = 512; Camera.ScreenHeight = 512; Camera.Eye = new Vector4(0, 0, 2, 1); Camera.Up = new Vector4(0, 1, 0, 1); Camera.LookAt = new Vector4(0, 0, 0, 1); Camera.PreProcess(); Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); Film = new Film(Camera.ScreenWidth, Camera.ScreenHeight); Texture top = new Texture("./Textures/SkyBox_farm/skybox_country_paths_top.jpg", false); Texture back = new Texture("./Textures/SkyBox_farm/skybox_country_paths_back.jpg", false); Texture front = new Texture("./Textures/SkyBox_farm/skybox_country_paths_front.jpg", false); Texture left = new Texture("./Textures/SkyBox_farm/skybox_country_paths_left.jpg", false); Texture right = new Texture("./Textures/SkyBox_farm/skybox_country_paths_right.jpg", false); Texture bottom = new Texture("./Textures/SkyBox_farm/skybox_country_paths_bottom.jpg", false); //SkyBox.LoadSkybox(left, right, top, bottom, front, back); PerlinNoise.Initialize(); Sphere sphere = new Sphere(new LambertMaterial(new Color(1f, 0.647f, 0)), new Vector3(0, 0, 0f), 0.5f); //Sphere sphere2 = new Sphere(new LambertMaterial(new Color(1f, 0f, 0f)), new Vector3(0.5f, 0f, 0f), 0.2f); sphere.Material.Noise = Noise.Turbulence; Texture orange = new Texture("./Textures/Bumpmap/orange.jpg", true); //sphere.Material.BumpTexture = orange; //Sphere sphere = new Sphere(new MirrorMaterial(10f), new Vector3(0, 0, 2f), 1f); Objects = new IntersectableList(); Lights = new List <ILight>(); Objects.Add(sphere); //Objects.Add(sphere2); ILight light = new PointLight(new Vector3(0f, 1, 2.6f), new Color(3f, 3f, 3f)); Lights.Add(light); }
public void Construct(Aggregate aggregate) { Material = ((IIntersectable)aggregate).Material; Aggregate objects = new IntersectableList(); foreach (IIntersectable intersectable in aggregate.GetObjects()) { objects.Add(intersectable); } BoundingBox = ((IIntersectable)aggregate).BoundingBox; //Calculate max treed depth = 8+1.3*log(n); maxTreeDepth = (int)Math.Ceiling(8 + (1.3 * Math.Log(objects.Intersectables.Count))); RootNode = new BspNode(); //Kick off the recursive tree construction RootNode.BuildSubTree(objects, BoundingBox, maxTreeDepth, 0); }
public TextureScene() { FileName = "Assignment4_Texture.jpg"; Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); Texture back = new Texture("./Textures/Skybox_stars/backmo.jpg", false); Texture bottom = new Texture("./Textures/Skybox_stars/botmo.jpg", false); Texture front = new Texture("./Textures/Skybox_stars/frontmo.jpg", false); Texture left = new Texture("./Textures/Skybox_stars/leftmo.jpg", false); Texture right = new Texture("./Textures/Skybox_stars/rightmo.jpg", false); Texture top = new Texture("./Textures/Skybox_stars/topmo.jpg", false); SkyBox.LoadSkybox(left, right, top, bottom, front, back); //List of objects //Sphere sphere = new Sphere(textureMaterial, new Vector3(0, 0, 0), .3f); ColladaParser parser = new ColladaParser(); parser.ParseColladaFile("./geometries/collada/deathstar.dae", 1024); Camera = parser.Cameras.Values.First(); Camera.PreProcess(); Film = new Film(Camera.ScreenWidth, Camera.ScreenHeight); Objects = new IntersectableList(); foreach (IIntersectable intersectable in parser.Meshes.Values) { Objects.Add(intersectable); } Lights = new List <ILight>(); foreach (ILight light in parser.Lights.Values) { Lights.Add(light); } }
public RefractionScene() { FileName = "Assignment1_Refraction.jpg"; Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); Camera = new PinholeCamera() { FieldOfViewX = 30f, FieldOfViewY = 30f, ScreenWidth = 512, ScreenHeight = 512, Eye = new Vector4(0, 0, 2, 1), Up = new Vector4(0, 1, 0, 1), LookAt = new Vector4(0, 0, 0, 1) }; Camera.PreProcess(); Film = new Film(Camera.ScreenWidth, Camera.ScreenHeight); //List of objects Sphere sphere1 = new Sphere(new RefractiveMaterial(1.5f), new Vector3(0f, 0f, 0f), 0.4f); Sphere sphere2 = new Sphere(new BlinnPhongMaterial(new Color(0.8f, 0f, 0f), new Color(0.8f, 0.8f, 0.8f), 30f), new Vector3(0.4f, 0.2f, -0.3f), 0.3f); Plane p1 = new Plane(1f, new Vector3(0, 1, 0)) { Name = "P1", Material = new LambertMaterial(new Color(0f, 0.8f, 0.8f)) }; Plane p2 = new Plane(1f, new Vector3(0, 0, 1)) { Name = "P2", Material = new LambertMaterial(new Color(0.3f, 0.8f, 0.8f)) }; Plane p3 = new Plane(1f, new Vector3(-1, 0, 0)) { Name = "P3", Material = new LambertMaterial(new Color(1.0f, 0.8f, 0.8f)) }; Plane p4 = new Plane(1f, new Vector3(1, 0, 0)) { Name = "P4", Material = new LambertMaterial(new Color(0f, 0.8f, 0f)) }; Plane p5 = new Plane(1f, new Vector3(0, -1, 0)) { Name = "P5", Material = new LambertMaterial(new Color(0.8f, 0.8f, 0.8f)) }; Objects = new IntersectableList(); Objects.Add(sphere1); Objects.Add(sphere2); Objects.Add(p1); Objects.Add(p2); Objects.Add(p3); Objects.Add(p4); Objects.Add(p5); Lights = new List <ILight>(); ILight light1 = new PointLight(new Vector3(0.0f, 0.8f, 0.8f), new Color(0.7f, 0.7f, 0.7f)); ILight light2 = new PointLight(new Vector3(-0.8f, 0.2f, 0f), new Color(0.5f, 0.5f, 0.5f)); Lights.Add(light1); Lights.Add(light2); }
public DepthOfFieldScene() { FileName = "Assignment4_DoF.jpg"; Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); Camera.Eye = new Vector4(-5f, 0f, -2.8f, 1f); Camera.LookAt = new Vector4(0f, 0f, -2.8f, 1f); Camera.Up = new Vector4(0, 1, 0, 1); Camera.Apperture = 0.25f; Camera.D = 7.5f; Camera.FieldOfViewX = 50f; Camera.FieldOfViewY = 50f; Camera.ScreenWidth = 512; Camera.ScreenHeight = 512; Film = new Film(Camera.ScreenWidth, Camera.ScreenHeight); Camera.PreProcess(); Objects = new IntersectableList(); /* * shapes[0].type = SHAPE_SPHERE; * VectorSet(shapes[0].sphere.center, -2.6f, -0.5f, -1.5f); * shapes[0].sphere.radius = 1; * VectorSet(shapes[0].move_velocity, 0, 0, 0); * VectorSet(shapes[0].color, 1, 0, 0); */ Sphere sphere = new Sphere(new LambertMaterial(new Color(1, 0, 0)), new Vector3(-2.6f, -0.5f, -1.5f), 1f); Objects.Add(sphere); /* * shapes[1].type = SHAPE_SPHERE; * VectorSet(shapes[1].sphere.center, 2.6f, 0.5f, -4); * shapes[1].sphere.radius = 1; * VectorSet(shapes[1].move_velocity, 0, 0, 0); * VectorSet(shapes[1].color, 0, 1, 0); */ sphere = new Sphere(new LambertMaterial(new Color(1, 0, 0)), new Vector3(-2.6f, -0.5f, -1.5f), 1f); Objects.Add(sphere); /* * shapes[3].type = SHAPE_TRI; * VectorSet(shapes[2].tri.verts[2], 0, 0.2f, -5); * VectorSet(shapes[2].tri.verts[1], 0, -0.4f, -1); * VectorSet(shapes[2].tri.verts[0], 0, 0.6f, -2); * VectorSet(shapes[2].move_velocity, 0, 0, 0); * VectorSet(shapes[2].color, 1, 1, 0); */ /* * VectorSet(lights[0].ambient, 0.1f, 0.1f, 0.1f); * VectorSet(lights[0].diffuse, 1, 1, 1); * VectorSet(lights[0].specular, 0.1f, 0.1f, 0.1f); * VectorSet(lights[0].pos, -2, 2, -2); */ ILight light = new PointLight(new Vector3(-2f, 2f, -2f), new Color(1, 1, 1)); Lights = new List <ILight>(); Lights.Add(light); }
public ColladaScene() { FileName = "Assignment_Collada.jpg"; ColladaParser parser = new ColladaParser(); parser.ParseColladaFile("./geometries/collada/reference.dae", 1024); Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); /*Camera = new PinholeCamera() * { * FieldOfViewX = 60f, * FieldOfViewY = 60f, * ScreenWidth = 128, * ScreenHeight = 128, * Eye = new Vector4(0, 0, -50, 1), * Up = new Vector4(0, 1, 0, 1), * LookAt = new Vector4(0, 0, 0, 1) * }; * Camera.PreProcess(); */ LambertMaterial green = new LambertMaterial(new Color(0, 1, 0)); LambertMaterial red = new LambertMaterial(new Color(1, 0, 0)); LambertMaterial blue = new LambertMaterial(new Color(0, 0, 1)); LambertMaterial gray = new LambertMaterial(new Color(0.8f, 0.8f, 0.8f)); LambertMaterial black = new LambertMaterial(new Color(0, 0, 0)); LambertMaterial white = new LambertMaterial(new Color(1, 1, 1)); //List of objects Sphere sphere = new Sphere(white, new Vector3(0, 0, .25f), .3f); Plane p1 = new Plane(1f, new Vector3(0, 1, 0)) { Material = white }; Plane p2 = new Plane(1f, new Vector3(0, 0, -1)) { Material = white }; Plane p3 = new Plane(1f, new Vector3(-1, 0, 0)) { Material = green }; Plane p4 = new Plane(1f, new Vector3(1, 0, 0)) { Material = blue }; Plane p5 = new Plane(1f, new Vector3(0, -1, 0)) { Material = white }; Rectangle rect = new Rectangle(new Vector3(-0.2f, .99f, 0f), new Vector3(.5f, 0, 0), new Vector3(0, 0, 0.5f)) { Material = blue }; Objects = new IntersectableList(); /* * Objects.Add(p1); * Objects.Add(p2); * Objects.Add(p3); * Objects.Add(p4); * Objects.Add(p5); */ Lights = new List <ILight>(); foreach (ILight light in parser.Lights.Values) { Lights.Add(light); } foreach (IIntersectable intersectable in parser.Meshes.Values) { Objects.Add(intersectable); } foreach (ICamera camera in parser.Cameras.Values) { Camera = camera; Camera.PreProcess(); } if (Camera == null || float.IsNaN(Camera.AspectRation)) { Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); Camera.FieldOfViewX = 30f; Camera.FieldOfViewY = 30f; Camera.ScreenWidth = 512; Camera.ScreenHeight = 512; Camera.Eye = new Vector4(0, 0, -2, 1); Camera.Up = new Vector4(0, 1, 0, 1); Camera.LookAt = new Vector4(0, 0, 0, 1); Camera.PreProcess(); } Film = new Film(Camera.ScreenWidth, Camera.ScreenHeight); }
public MirrorScene() { FileName = "Assignment1_Mirror.jpg"; Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); Camera = new PinholeCamera() { FieldOfViewX = 30f, FieldOfViewY = 30f, ScreenWidth = 512, ScreenHeight = 512, Eye = new Vector4(0, 0, 2, 1), Up = new Vector4(0, 1, 0, 1), LookAt = new Vector4(0, 0, 0, 1) }; Camera.PreProcess(); Film = new Film(Camera.ScreenWidth, Camera.ScreenHeight); //List of objects Sphere sphere = new Sphere(new BlinnPhongMaterial(new Color(0.8f, 0, 0), new Color(0.6f, 0.6f, 0.6f), 30f), new Vector3(0f, 0f, 0f), 0.2f); //Sphere sphere = new Sphere(new LambertMaterial(new Color(0.8f, 0.8f, 0.8f)), new Vector3(0f, 0f, 0f), 0.2f); Sphere sphere2 = new Sphere(new MirrorMaterial(0.8f), new Vector3(0.4f, 0.2f, -0.3f), .3f); Plane p1 = new Plane(1f, new Vector3(0, 1, 0)) { Name = "P1", Material = new LambertMaterial(new Color(0f, 0.8f, 0.8f)) }; Plane p2 = new Plane(1f, new Vector3(0, 0, 1)) { Name = "P2", Material = new LambertMaterial(new Color(0.3f, 0.8f, 0.8f)) }; Plane p3 = new Plane(1f, new Vector3(-1, 0, 0)) { Name = "P3", Material = new LambertMaterial(new Color(1.0f, 0.8f, 0.8f)) }; Plane p4 = new Plane(1f, new Vector3(1, 0, 0)) { Name = "P4", Material = new LambertMaterial(new Color(0f, 0.8f, 0f)) }; Plane p5 = new Plane(1f, new Vector3(0, -1, 0)) { Name = "P5", Material = new LambertMaterial(new Color(0.8f, 0.8f, 0.8f)) }; /*int[] i = { 0, 1, 2, 2, 3, 0 }; * Mesh rectangle = new Mesh(new LambertMaterial(new Color(0, 0, 1)), i, * -.25f, .999998f, .25f, * -.25f, .999999f, -.25f, * .25f, .999999f, -.25f, * .25f, .999998f, .25f);*/ Rectangle rectangle = new Rectangle(new Vector3(-0.2f, .99f, 0f), new Vector3(.5f, 0, 0), new Vector3(0, 0, 0.5f)) { Material = new LambertMaterial(new Color(0, 0, 1)) }; Objects = new IntersectableList(); Objects.Add(rectangle); Objects.Add(sphere); Objects.Add(sphere2); Objects.Add(p1); Objects.Add(p2); Objects.Add(p3); Objects.Add(p4); Objects.Add(p5); Lights = new List <ILight>(); ILight light = new PointLight(new Vector3(0.0f, 0.8f, 0.8f), new Color(0.7f, 0.7f, 0.7f)); ILight light2 = new PointLight(new Vector3(-0.8f, 0.2f, 0.0f), new Color(.5f, .5f, .5f)); ILight light3 = new AreaLight(new Color(0.1f, 0.1f, 0.1f), rectangle); Lights.Add(light3); //Lights.Add(light2); //Lights.Add(light); }
public BasicScene() { FileName = "Assignment1_Basic.jpg"; //scene = new Scene { BackgroundColor = Color.Black }; Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); Camera.FieldOfView = 60f; Camera.ScreenWidth = 256; Camera.ScreenHeight = 256; Camera.Eye = new Vector4(0, 0, -1f, 1); Camera.Up = new Vector4(0, 1, 0, 1); Camera.LookAt = new Vector4(0, 0, 0, 1); Camera.D = 1f; Camera.Apperture = 0.2f; Camera.PreProcess(); Film = new Film(Camera.ScreenWidth, Camera.ScreenHeight); LambertMaterial green = new LambertMaterial(new Color(0, 1, 0)); LambertMaterial red = new LambertMaterial(new Color(1, 0, 0)); LambertMaterial blue = new LambertMaterial(new Color(0, 0, 1)); LambertMaterial gray = new LambertMaterial(new Color(0.8f, 0.8f, 0.8f)); LambertMaterial black = new LambertMaterial(new Color(0, 0, 0)); LambertMaterial white = new LambertMaterial(new Color(1, 1, 1)); //List of objects Sphere sphere = new Sphere(white, new Vector3(0, -.25f, 2f), 1f); Sphere sphere2 = new Sphere(white, new Vector3(3f, -.25f, 5f), 1f); Plane p1 = new Plane(20f, new Vector3(0, 1, 0)) { Material = white }; Plane p2 = new Plane(20f, new Vector3(0, 0, -1)) { Material = white }; Plane p6 = new Plane(20f, new Vector3(0, 0, 1)) { Material = white }; Plane p3 = new Plane(20f, new Vector3(-1, 0, 0)) { Material = red }; Plane p4 = new Plane(20f, new Vector3(1, 0, 0)) { Material = blue }; Plane p5 = new Plane(20f, new Vector3(0, -1, 0)) { Material = white }; /*Rectangle rect = new Rectangle(new Vector3(-0.2f, .99f, 0f), new Vector3(.5f, 0, 0), new Vector3(0, 0, 0.5f)) * { * Material = blue * };*/ int[] i = { 0, 1, 2, 2, 3, 0 }; Mesh rectangle = new Mesh(new LambertMaterial(new Color(0, 0, 1)), i, -.25f, .999998f, .25f, -.25f, .999999f, -.25f, .25f, .999999f, -.25f, .25f, .999998f, .25f); Objects = new IntersectableList(); //Objects.Add(rect); //Objects.Add(rectangle); Objects.Add(sphere); Objects.Add(sphere2); Objects.Add(p1); Objects.Add(p2); Objects.Add(p3); Objects.Add(p4); Objects.Add(p5); Objects.Add(p6); Lights = new List <ILight>(); ILight light = new DirectionalLight(new Vector3(0.0f, 0f, -1f), new Color(1, 1, 1)); //ILight light = new AreaLight(new Color(1, 1, 1), rectangle); Lights.Add(light); }
public void BuildSubTree(Aggregate intersectables, IBoundingBox boundingBox, int maxTreeDepth, int currentTreeDetph) { Intersectables = intersectables; BoundingBox = boundingBox; if (Intersectables.GetNumberOfComponents() <= 5 || currentTreeDetph == maxTreeDepth) { IsLeaf = true; } else { Aggregate leftIntersectables = new IntersectableList(); Aggregate rightIntersectables = new IntersectableList(); //Find the maximal Axis Axis = 0; float max = BoundingBox.Dimension.X; if (BoundingBox.Dimension.Y > max) { Axis = 1; } if (BoundingBox.Dimension.Z > max) { Axis = 2; } //Axis = currentTreeDetph % 3; PlanePos = BoundingBox.MaxVector[Axis] - (BoundingBox.MaxVector[Axis] - BoundingBox.MinVector[Axis]) / 2; Vector3 leftMin = Vector3.Zero; Vector3 leftMax = Vector3.Zero; Vector3 rightMin = Vector3.Zero; Vector3 rightMax = Vector3.Zero; switch (Axis) { case 0: leftMin = new Vector3(PlanePos, BoundingBox.MinVector.Y, BoundingBox.MinVector.Z); leftMax = new Vector3(BoundingBox.MaxVector); rightMin = new Vector3(BoundingBox.MinVector); rightMax = new Vector3(PlanePos, BoundingBox.MaxVector.Y, BoundingBox.MaxVector.Z); break; case 1: leftMin = new Vector3(BoundingBox.MinVector.X, PlanePos, BoundingBox.MinVector.Z); leftMax = new Vector3(BoundingBox.MaxVector); rightMin = new Vector3(BoundingBox.MinVector); rightMax = new Vector3(BoundingBox.MaxVector.X, PlanePos, BoundingBox.MaxVector.Z); break; case 2: leftMin = new Vector3(BoundingBox.MinVector.X, BoundingBox.MinVector.Y, PlanePos); leftMax = new Vector3(BoundingBox.MaxVector); rightMin = new Vector3(BoundingBox.MinVector); rightMax = new Vector3(BoundingBox.MaxVector.X, BoundingBox.MaxVector.Y, PlanePos); break; } IBoundingBox leftBb = new AxisAlignedBoundingBox(leftMin, leftMax); IBoundingBox rightBb = new AxisAlignedBoundingBox(rightMin, rightMax); LeftNode = new BspNode(); RightNode = new BspNode(); foreach (IIntersectable intersectable in Intersectables.GetObjects()) { if (intersectable.BoundingBox.Intersect(leftBb)) { leftIntersectables.Add(intersectable); } if (intersectable.BoundingBox.Intersect(rightBb)) { rightIntersectables.Add(intersectable); } } LeftNode.BuildSubTree(leftIntersectables, leftBb, maxTreeDepth, currentTreeDetph + 1); RightNode.BuildSubTree(rightIntersectables, rightBb, maxTreeDepth, currentTreeDetph + 1); Intersectables = null; //Clear up the intersectables in non leaf nodes to save space } }
public KdTreeScene() { FileName = "Assignment2_KdTree.jpg"; //scene = new Scene { BackgroundColor = Color.Black }; Integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); Camera.FieldOfViewX = 60f; Camera.FieldOfViewY = 60f; Camera.ScreenWidth = 512; Camera.ScreenHeight = 512; Camera.Eye = new Vector4(0, 0, 2, 1); Camera.Up = new Vector4(0, 1, 0, 1); Camera.LookAt = new Vector4(0, 0, 0, 1); Camera.PreProcess(); Film = new Film(Camera.ScreenWidth, Camera.ScreenHeight); Plane p1 = new Plane(1f, new Vector3(0, 1, 0)) { Name = "P1", Material = new LambertMaterial(new Color(0f, 0.8f, 0.8f)) }; Plane p2 = new Plane(1f, new Vector3(0, 0, 1)) { Name = "P2", Material = new LambertMaterial(new Color(0.3f, 0.8f, 0.8f)) }; Plane p3 = new Plane(1f, new Vector3(-1, 0, 0)) { Name = "P3", Material = new LambertMaterial(new Color(1.0f, 0.8f, 0.8f)) }; Plane p4 = new Plane(1f, new Vector3(1, 0, 0)) { Name = "P4", Material = new LambertMaterial(new Color(0f, 0.8f, 0f)) }; Plane p5 = new Plane(1f, new Vector3(0, -1, 0)) { Name = "P5", Material = new LambertMaterial(new Color(0.8f, 0.8f, 0.8f)) }; Mesh mesh = new Mesh() { Material = new LambertMaterial(new Color(0.5f, 0.5f, 0.5f)) }; mesh.CreateMeshFromObjectFile("./geometries/buddha.obj", 1.0f); BspAccelerator tree = new BspAccelerator(); tree.Construct(mesh); //Matrix4 m1 = Matrix4.Scale(0.5f); //m1.Translation = new Vector4(0, -0.25f, 0, 1); Matrix4 m2 = Matrix4.Scale(0.5f); m2.Translation = new Vector4(0, 0.25f, 0, 1); Instance i1 = new Instance(tree, Matrix4.Identity); //Instance i2 = new Instance(tree, m2); /* * Instance i1 = new Instance(mesh, m1); * Instance i2 = new Instance(mesh, m2); */ Objects = new IntersectableList(); Objects.Add(p1); Objects.Add(p2); Objects.Add(p3); Objects.Add(p4); Objects.Add(p5); Objects.Add(i1); //scene.IntersectableList.Objects.Add(i2); Lights = new List <ILight>(); ILight light = new PointLight(new Vector3(0.0f, 0.8f, 0.8f), new Color(.7f, .7f, .7f)); ILight light2 = new PointLight(new Vector3(-0.8f, 0.2f, 1f), new Color(.5f, .5f, .5f)); Lights.Add(light); Lights.Add(light2); }