about

Hi! I'm a junior at UC Berkeley studying Electrical Engineering and Computer Science. I'm interested in the intersection of human-computer interaction, computer graphics, and future hardware. Currently, I'm taking classes in interface design, operating systems, and computer graphics. I also enjoy reading, playing tennis, and learning new languages. This website serves as a way to log my work and keep track of what I've built or in progress.

portfolio

🫖 Computer Graphics Projects



Rasterization

In this homework, the goal was to implement a simple rasterizer with features such as drawing triangles, supersampling, hierarchal transforms, and texture mapping with antialiasing, resulting in a functional vector graphics renderer. I learnt quite a bit about each of the sampling algorithms and texture mapping algorithms implemented throughout the project. I also learnt more about the sampling pipeline and how to represent the abstractions of sample buffer, pixels, texels, and coordinate systems through the data structures used in this project.

Drawing Single-Color Triangles

In order to rasterize triangles to the frame buffer, I check if the center of each pixel is within the triangle. The rasterize_triangle function takes in coordinates for each of the three corners of the triangle. My implementation first determines what the smallest bounding box (calculated by determining the lowest and highest x and y values that the triangle covered) around the triangle. Then, it iterates through each pixel in the bounding box and checks if the center of the pixel is within the triangle. We check if the center of the pixel (x + 0.5, y + 0.5) is in the triangle by checking to see that it is within the three edges of the triangle. If it is, the pixel is filled in with the color of the triangle. This handles coordinates received in the clockwise direction, but to include coordinates in the counter-clockwise direction, I reversed the inequality check.

This algorithm is no worse than traversing each sample individually in the bounding box of the triangle and determining if it's in the triangle because we still iterate through all the points in the bounding box. There is no optimization or short circuiting that reduces the number of pixels traversed.

basic_test4_pixel

Antialiasing by Supersampling

In this task, I implemented supersampling by updating the sample_buffer data structure and modifying certain algorithms. Supersampling is useful because it allows us to antialias and reduce the jaggies in our images, making pixels seem smoother zoomed out. The modifications I made to the rasterization pipeline was to first change the size of the sample_buffer to include the number of samples we wanted to sample, width * height * sample_rate. Now, each (x, y) pixel will be represented by a sample_rate number of samples that will be averaged in order to downsample to determine the color of the original pixel. I added a new fill_sample function which fills in the color of a specific sample for an (x, y) pixel and updates its color in the sample_buffer by using a new indexing method: sample_buffer[sample_rate * (y * width + x) + s]. I updated the fill_pixel sample to stay consistent for points and lines by calling fill_sample for the number of samples in the pixel, effectively making sure that all samples have the same color. In rasterize_triangle, I now iterated through each sample, rather than pixel to check if we were within bounds, and called fill_sample instead of fill_pixel. Finally, in resolve_to_framebuffer, I updated the frame buffer by getting all samples that corresponded to an (x, y) pixel and averaging the RGB values of all the samples to get the final color, which was then resolved to the framebuffer target.

Mesh Geometry

Ray Tracing

Animation