diff --git a/hw1/images/image1.png b/hw1/images/image1.png new file mode 100644 index 00000000..45b113e4 Binary files /dev/null and b/hw1/images/image1.png differ diff --git a/hw1/images/image2.png b/hw1/images/image2.png new file mode 100644 index 00000000..754eafd4 Binary files /dev/null and b/hw1/images/image2.png differ diff --git a/hw1/images/image3.png b/hw1/images/image3.png new file mode 100644 index 00000000..78aab9cd Binary files /dev/null and b/hw1/images/image3.png differ diff --git a/hw1/images/image4.png b/hw1/images/image4.png new file mode 100644 index 00000000..a22e7e4c Binary files /dev/null and b/hw1/images/image4.png differ diff --git a/hw1/index.html b/hw1/index.html index a7458a33..73d459ba 100644 --- a/hw1/index.html +++ b/hw1/index.html @@ -1,7 +1,96 @@ - - - - - Homework 1 index.html here - - \ No newline at end of file + + + + +CS 184/284A Rasterizer + + + + + + + +

CS 184/284A: Computer Graphics and Imaging, Spring 2024

+

Homework 1: Rasterizer

+

YOUR NAME

+ +

+ +
+ +

Overview

+

Give a high-level overview of what you implemented in this homework Think about what you've built as a whole. Share your thoughts on what interesting things you've learned from completing the homework.

+ +

Section I: Rasterization

+ +

Part 1: Rasterizing single-color triangles

+ +

Here is an example 2x2 gridlike structure using an HTML table. Each tr is a row and each td is a column in that row. You might find this useful for framing and showing your result images in an organized fashion.

+ +
+ + + + + +
+ + + + +
+ +
Caption goes here.
+
+ +
Caption goes here.
+
+ +
Caption goes here.
+
+ +
Caption goes here.
+
+
+ + +

Part 2: Antialiasing triangles

+ + + +

Part 3: Transforms

+ + + +

Section II: Sampling

+ +

Part 4: Barycentric coordinates

+ + +

Part 5: "Pixel sampling" for texture mapping

+ + +

Part 6: "Level sampling" with mipmaps for texture mapping

+ + + +

Section III: Art Competition

+

If you are not participating in the optional art competition, don't worry about this section!

+ +

Part 7: Draw something interesting!

+ + + diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/1.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/1.png new file mode 100644 index 00000000..5971ae6c Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/1.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/2.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/2.png new file mode 100644 index 00000000..bd30a2ad Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/2.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/3.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/3.png new file mode 100644 index 00000000..b958f9c3 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/3.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/4.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/4.png new file mode 100644 index 00000000..a3ebb00f Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/4.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/5.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/5.png new file mode 100644 index 00000000..8c5b0d00 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/5.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/6.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/6.png new file mode 100644 index 00000000..3e999cf8 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/6.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/7.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/7.png new file mode 100644 index 00000000..6a33f8ed Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/7.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 1.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 1.png new file mode 100644 index 00000000..c43e97d2 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 1.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 10.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 10.png new file mode 100644 index 00000000..9d29a87d Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 10.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 11.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 11.png new file mode 100644 index 00000000..0cfa07a4 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 11.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 12.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 12.png new file mode 100644 index 00000000..30aaa960 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 12.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 13.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 13.png new file mode 100644 index 00000000..d91d7205 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 13.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 14.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 14.png new file mode 100644 index 00000000..4e7d0ba5 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 14.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 15.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 15.png new file mode 100644 index 00000000..c0ecdfb4 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 15.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 16.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 16.png new file mode 100644 index 00000000..3d27022b Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 16.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 17.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 17.png new file mode 100644 index 00000000..fba93d37 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 17.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 18.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 18.png new file mode 100644 index 00000000..3b3df732 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 18.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 19.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 19.png new file mode 100644 index 00000000..e1a8d76e Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 19.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 2.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 2.png new file mode 100644 index 00000000..00759009 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 2.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 20.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 20.png new file mode 100644 index 00000000..7d567c77 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 20.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 21.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 21.png new file mode 100644 index 00000000..5a8979d7 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 21.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 22.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 22.png new file mode 100644 index 00000000..70c9f616 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 22.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 23.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 23.png new file mode 100644 index 00000000..e0d5c6c5 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 23.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 24.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 24.png new file mode 100644 index 00000000..f4575992 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 24.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 25.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 25.png new file mode 100644 index 00000000..e6d9e9b9 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 25.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 3.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 3.png new file mode 100644 index 00000000..465da208 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 3.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 4.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 4.png new file mode 100644 index 00000000..e4d0cd83 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 4.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 5.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 5.png new file mode 100644 index 00000000..9db1c316 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 5.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 6.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 6.png new file mode 100644 index 00000000..b2e1d012 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 6.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 7.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 7.png new file mode 100644 index 00000000..c225468a Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 7.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 8.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 8.png new file mode 100644 index 00000000..1b191427 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 8.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 9.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 9.png new file mode 100644 index 00000000..c34461e6 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled 9.png differ diff --git a/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled.png b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled.png new file mode 100644 index 00000000..4c7b7957 Binary files /dev/null and b/hw2/CS 184 - HW 2 7b4cc4cc2d6549328ee1212e51b4cdf0/Untitled.png differ diff --git a/hw2/index.html b/hw2/index.html index 13b78467..f129f736 100644 --- a/hw2/index.html +++ b/hw2/index.html @@ -1,7 +1,685 @@ - - - - - Homework 2 index.html here - - \ No newline at end of file +CS 184 - HW 2

CS 184 - HW 2

+

Webpage: https://cal-cs184-student.github.io/hw2-meshedit-sp24-ddr/

Overview

In this project, we took coordinates in screen space and mapped them onto 3D objects in world space to create a mesh. We then made use of the Halfedge data structure, to implement vertex-based shading, to flip and split the edges of the mesh, and to upsample the components of the mesh. In doing this, we were able to manipulate the topology of an object.

Section I - Bezier Curves and Surfaces

Part 1 - Bezier Curves with 1D de Casteljau Subdivision

De Casteljau’s algorithm recursively interpolates between n-1 pairs of points points by value t, until a singular point is produced. In order to evaluate Bezier curves we used de Casteljau’s algorithm for each step, or for each new level of control points.

+

+

+

Part 2 - Bezier Surfaces with Separable 1D de Casteljau

De Casteljau’s algorithm allows us to evaluate multiple levels of intermediate control points until a single final point is found on the Bezier curve. In part 2, we worked with Bezier surfaces which are comprised of Bezier curves. To find the surface point given x and y of this Bezier surface, we simply iterated through each Bezier curve and found the final point of each with respect to `u` using the recursive algorithm we wrote in the previous part. Next, we took this set of points to create its own "moving" Bezier curve and once again called our De Casteljau’s algorithm to evaluate a single final point given v; the point return is the surface point.

+

+

Section II: Triangle Meshes and Half-Edge Data Structure

Part 3 - Area-Weighted Vertex Normals

To implement the area-weighted vertex normals, we iterated through each triangle in the target vertex’s manifold. In each neighboring triangle we took the vertex’s 2 connecting vectors and computed its cross-product to get our face’s normal vector. Then we got the area of the triangle by multiplying the face’s normal vector by 1/2. After, we summed all of the face’s normal vectors and divided it by its normalization to compute the area weighted normal.

no shading
smoothing/shading

Part 4 - Edge Flip

Edge Flip Operation Process

Starting off, we drew out a diagram for the edge flip operation and wrote down all of the pointer assignments. (Warning: we had to debug so these initial assignments may not be correct.)

  1. We stored all the pointers for the current halfedges (h0-h9), vertices (v0-v3), edges (e0-e4), and faces (f0-f1) into variables.
  1. Then we reassigned all the pointers of the attributes in each halfedge (its next, twin, vertex, edge, and face).
  1. Finally, we reassigned all the halfedge pointers inside of all vertices, edges, and faces.

Screenshots

Debugging Journey

Thankfully, there was no debugging journey for Part 4.

Part 5 - Edge Split

Edge Split Operation Process

Similar to the edge flip, we first drew a diagram and wrote down all of the pointer assignments.

  1. We stored all the pointers for the current halfedges (h0-h9), vertices (v0-v3), edges (e0-e4), and faces (f0-f1) into variables.
  1. We then instantiated 6 new halfedges, 1 new vertex, 3 new edges, and 2 new faces to account for the additional elements that would appear when the edge was split.
    1. In order to get the new vertex position, we took the average of the orginal splitting edge’s (e0) connecting vertex positions.
  1. Then we reassigned all the pointers of the attributes in each halfedge (its next, twin, vertex, edge, and face).
  1. Finally, we reassigned all the halfedge pointers inside of all vertices, edges, and faces.
    1. We also had to change the 2 new edges’s (e5 and e6) isNew attribute to true, since the split creates 1 new long edge segmented into 2.

Screenshots

+

Debugging Journey

The main bug we ran into was the operation successfully running, but the face to the west disappearing (which left what looked like a hole). We debugged it by rechecking our diagram and the corresponding code to each pointer. After posting on Edstem to ask for debuggging advice and doubly rechecking our diagram, we eventually realized that the next reassignment in h0’s setNeighbor call was wrong. Instead of h0→next() = h1 the code read h0→next() = h0.

Part 6 - Loop Subdivision

Loop Subdivision Implementation

  1. We started by iterating through each vertex in the mesh to update their old positions.
    1. We iterated through each neighbor to calculate the sum of the neighboring vertex positions.
    1. Then we calculated the updated vertex position by computing the constant of the vertex according to the formula below (u) and extracting our known vertex degree value (n) and applying this formula: (1 - n * u) * original_position + u * original_neighbor_position_sum .
    1. We then changed the vertex’s isNew attribute to false.
  1. Next, we computed the new vertex positions that will be created by the new edges. To do this, we iterated through the pre-existing edges and found its 4 surrounding vertices that would formulate 2 neighboring triangles (like in the diagram below). We stored the calculated position using this formula, 3/8 * (A + B) + 1/8 * (C + D), and stored it in Edge::newPosition . We also changed the edge’s isNew value to false.
  1. Next, we re-iterated through the edges in the mesh and split them using the splitEdge function we created in the previous part. As we split, we updated the returned vertex’s isNew attribute to true and assigned its position to the newPosition stored in the edge.
  1. We re-iterated through the edges again, this time using flipEdge to flip edges that were connected to a new and old vertex.
  1. Finally, we iterated through each vertex in the mesh and copied its newPosition value over to position to update it.

Screenshots

After loop subdivision, the triangles of the mesh become smaller and greater in number. Sharp corners and edges are physically smoothed out. You can reduce this effect by pre-splitting edges near the sharp areas and creating a ring or an edge loop around it.

You can pre-process the cube by splitting the faces so each one has a cross on it. This ensures that each face has matching edges and faces. This enables the upsampling to equally split and flip itself. Before, the cube would skew itself to the right when it was upsampled since the faces only had 1 split edge that pointed in the direction of the skew.

+

+

\ No newline at end of file diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_16_8.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_16_8.png new file mode 100644 index 00000000..43e0dbe7 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_16_8.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_H_16_8_pt3_3.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_H_16_8_pt3_3.png new file mode 100644 index 00000000..238f16ed Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_H_16_8_pt3_3.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_H_64_32_pt3_3.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_H_64_32_pt3_3.png new file mode 100644 index 00000000..bca499f6 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBbunny_H_64_32_pt3_3.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBempty.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBempty.png new file mode 100644 index 00000000..e7ee3eb6 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBempty.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBlucy_pt2.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBlucy_pt2.png new file mode 100644 index 00000000..154f0dac Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBlucy_pt2.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres.png new file mode 100644 index 00000000..ff293a99 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_16_pt3_4.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_16_pt3_4.png new file mode 100644 index 00000000..e433dfec Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_16_pt3_4.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_1_pt3_4.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_1_pt3_4.png new file mode 100644 index 00000000..3fde9019 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_1_pt3_4.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_4_pt3_4.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_4_pt3_4.png new file mode 100644 index 00000000..b91b62d5 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_4_pt3_4.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_64_pt3_4.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_64_pt3_4.png new file mode 100644 index 00000000..b968df2f Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/CBspheres_lambertian_1_64_pt3_4.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Cube.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Cube.png new file mode 100644 index 00000000..e1adfe75 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Cube.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Plane.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Plane.png new file mode 100644 index 00000000..e973c45a Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Plane.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Untitled.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Untitled.png new file mode 100644 index 00000000..624a9a7e Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/Untitled.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_1_1_pt3_4.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_1_1_pt3_4.png new file mode 100644 index 00000000..8a5eeffb Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_1_1_pt3_4.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_64_32_pt3_4.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_64_32_pt3_4.png new file mode 100644 index 00000000..512ab49e Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_64_32_pt3_4.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_pt5_rate.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_pt5_rate.png new file mode 100644 index 00000000..b2d924f2 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/bunny_pt5_rate.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/cow.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/cow.png new file mode 100644 index 00000000..9b684297 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/cow.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/dragon_64_32_pt3_4.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/dragon_64_32_pt3_4.png new file mode 100644 index 00000000..42e873f1 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/dragon_64_32_pt3_4.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/maxplanck.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/maxplanck.png new file mode 100644 index 00000000..dd2cc6ff Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/maxplanck.png differ diff --git a/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/peter.png b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/peter.png new file mode 100644 index 00000000..6b1b0290 Binary files /dev/null and b/hw3/CS 184 - HW 3 a8fe6e887ef641e8bfb43e59c33b663f/peter.png differ diff --git a/hw3/index.html b/hw3/index.html index c30176bc..bcf19d4a 100644 --- a/hw3/index.html +++ b/hw3/index.html @@ -1,7 +1,677 @@ - - - - - Homework 3 index.html here - - \ No newline at end of file +CS 184 - HW 3

CS 184 - HW 3

+

Webpage:

Overview

In this project, we generated rays from a camera and shot them through a scene. We tested for ray intersections using bounding boxes and BVH Acceleration to optimize the process. In order to do this, we had to test for intersections of primitive shapes like triangles and spheres. Then we calculated irradiance and illumination to properly render light in our scene. The 2 different processes were Uniform Hemisphere Sampling and Importance Sampling. Then we applied Adaptive Sampling to get the pixels to converge quickly.

Part 1: Ray Generation and Scene Intersection

Ray Generation and Primitive Intersection

In order to generate rays, we converted the Vector2D (x,y) coordinate pairs from image space to its corresponding Vector3D (x,y,z) position in camera space. Next we calculated the ray direction by taking the difference between Vector3D(x,y, -1) position in camera space and the origin (Zero vector). The direction was then transformed into world space with the given c2w matrix, normalized, and finally intialized into a ray that was outputted from generate_ray().

Inside raytrace_pixel(), we called passed in the normalized x and y to generate_ray() to create a ray and take its average estimated radiance over ns_aa iterations to update the pixel with avgRadiance.

Triangle Intersection Algorithm

The triangle intersection algorithm that we implemented was the Moller Trumbore Algorithm. This algorithm takes the 3 vertices of a triangle to compute the 2 edges (or vectors i.e. E1 and E2) that are adjacent to 1 target vertex. Those are then used with our known ray origin r.o and ray direction r.d vectors to find the incident vectors S0, S1, and S2, along with the target vertex, to find the value of t that the ray intersects the triangle and the barycentric coefficients b0, b1, and b2.

We then took t and compared its value to the ray’s minimum and maximum t range. If it was [r.min_t, r.max_t], we deemed that the ray intersected the triangle. We also checked the barycentric coefficient values to make sure their values were within the range of 0 and 1.

Sphere Intersection Algorithm

For the sphere, we checked if it intersected the ray by first computing the normal vector of the sphere (the ray’s origin - the sphere’s origin). Then we calculated the determinant of the quadratic formula by finding the values of a, b, and c relative to the sphere. a = dot(r.d, r.d) b = dot(2.0f * (originMinusCenter), r.d) c = dot(originMinusCenter, originMinusCenter) - r2 If the determinant was less than 0.0f, there was no intersection. Otherwise, there was an intersection.

In the intersect function, we checked for an intersection. If the ray did intersect the sphere, we solved the quadratic equation to obtain the value of t. If t was within ray min_t and max_t, we updated the intersection’s parameters. If t was less than ray max_t, we updated the value of max_t.

Images

Part 2: Bounding Volume Hierarchy

BVH Construction Algo

Our BVH construction algorithm starts by iterating through the list of primitives to create a BBox node. If the number of primitives in the BBox were less than or equal to the max_leaf_size, we set the node’s start and end pointers to the list of primitives and the left and right children to NULL.

Otherwise, we looked for the split axis by comparing the axes extent values and took the greatest one. We then sorted the list of primitives according to their centroid values on the split axis in ascending order. We chose our split point to be the midpoint of the axis. Using this, we reiterated through the list of primitives and placed a pointer at the middle. The middle pointer was then used to recursively construct the BVH nodes for this interior node’s left and right children.

Images

Rendering Time Comparisons

  • cow: 0.4818s → 0.1354s
  • maxplanck: 0.7618s → 0.2348s
  • CBlucy: 0.2806s → 0.0711s
  • peter: 0.5594s → 0.1742s

The renders without BVH Acceleration were significantly slower than the renders with it. This is due to the computational efficiency that BVH Acceleration offers. Since we’re using bounding boxes to quickly identify intersections based on the split axis and point instead of iterating through the entire list of primitives each time, we are saved lots of computation.

Part 3: Direct Illumination

Direct Lighting with Uniform Hemisphere Sampling

This function calculates the amount of lighting that hits hit_p by sampling rays in its hemisphere and incorporating it in to the Monte Carlo estimate. For the estimate, we calculated the light reflected in the w_out direction by using the bsdf→f() function we wrote back in 3.1 and for the amount of incoming light, we used get_emission() on the object the ray intersected.

Direct Lighting by Importance Sampling Lights

Unlike uniform hemisphere lighting, importance sampling derives its samples from the light sources in the image. If the light source is a point, only one sample is taken. This sample gives us w_i, the distance to the light, and the pdf. We use these values to create a Ray and set min_t = ESP_F and max_t = dist2light - EPS_F, in order to detect whether not there’s an intersection before the ray reaches the light. If there’s no intermediate intersection, that means the light directly hits the point. In this case, we can calculate the irradiance the same way as we did with Uniform Hemisphere Sampling by using the reflectance equation. The biggest difference is that we must divide by pdf to account for the weight of that singular sample.

Images

Zero Bounce Radiance

Uniform Hemisphere Sampling

-t 8 -s 16 -l 8 | 14.5232s
-t 8 -s 64 -l 32 -m 6 | 165.6317s

Importance Sampling

-t 8 -s 1 -l 1 -m 1 -f | 0.1884s
-t 8 -s 64 -l 32 -m 6 -f | 71.5473s
-t 8 -s 64 -l 32 -m 6 -f | 196.0982s

Light Ray Case Study: CBspheres_lambertian.dae

-s 1 -l 1
-s 1 -l 16
-s 1 -l 4
-s 1 -l 64

Noise has an indirect relationship with the number of samples per area light.

Comparison

Generally, images rendered using Uniform Hemisphere Sampling were noisier than images rendered using Importance Sampling. There’s also less “glare” or blurred white pixels around the light source in importance sampled images than uniform hemisphere sampled images.

Part 5: Adaptive Sampling

Adaptive sampling sums up the illumination values of each sample and returns after the convergence threshold is met. This is done in order to stop extra computation (i.e. the pixel has already reached convergence and doesn’t need to have any more samples taken). The convergence value is 1.96 * (standard deviation / square root of number of samples) and the threshold is maxTolerance * mean.

\ No newline at end of file diff --git a/hw4/index.html b/hw4/index.html deleted file mode 100644 index c1ca00c5..00000000 --- a/hw4/index.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Homework 4 index.html here - - \ No newline at end of file