Computer Graphics Project

Project Idea & Plan of Implementation


For my project, I plan on coding a bubble. I find implementing this idea into code challenging, but also fun. I plan on coding the bubble with triangle meshes all tied together with springs like how we did with lab 5 of this course. After some research, I found that spheres in computer programming are not all circular, but they are a bunch of triangles put together.

PROJECT


Sample Image From Online




Working With Animation/Lab 6


For lab 6, our main objective was to mess around with some code given to us and ultimately make an animation. We then export that animation into a gif using a function given to us. This was the end result I got after fiddling with the code a bit. I tried to create an illusion where the ball seen is actually being thrown into the distance and bouncing into the wall in the background. It is not a very good animation, but it is a start.



Animation Created in Lab 6




Shaders in openGL


For lab 8, we had to work with vertex and fragment shaders. The shaders were already created, but we had to modify the program to make one image fade out while another image fades in. Both of the images are outputted onto a triangle. Below is a gif animation I created of what my program outputs.



Fade created in Lab 8




Terrain in openGL


For lab 9, our main objective was to render a terrain. To do this, we used heightmaps which are just files containing height positions. We then drew triangles at each of the positions and gave them a color. Below is an image of the terrain I generated. The height map I used was for White Wolf. I also added some movement to the water as an extra feature.



Terrain in Lab 9




Project progress #1


The first thing I had to do for my project was generate a 3d sphere. I used the pball program as a guide for building vertices on a circle. I did have to modify it a bit and add a 'z' component since my object is in 3d. I used glut.h as the main framework of the program and below is the 3d sphere I was able to generate.



3d Circle




Project progress #2


The next step was to implement physics movement on the sphere. All of the vertices are treated as masses and I connected springs between all of them like how we did with the jello in lab 5. I used lab 5 as a reference for all of the physics of the masses and the springs. I had to modify most of it due to my vertices having three components: a 'x', a 'y', and a 'z'. After some time, I was able to replicate bubble movement as shown below.



Sphere with bubble movement




Project progress #3


After implementing the physics movement, I had to focus on the transparency of the bubble object. For transparency, I had to enable gl_blend and use the glBlendFunc. To test if the transparency actually worked, I made a checkerboard floor and some walls with binded textures on them. After debugging the code, I was finally able to generate everything to my liking as shown below.



Bubble transparency




Project progress #4


In this part of my project, I implement the use of shaders. Shaders are user-defined programs designed to run on the pipeline of a graphics processor. There are many shader stages that you are able to implement but I just stuck with the vertex and fragment shader. At this phase, I only added some lighting to my bubble. Below is an animation of my result.



Bubble Lighting With Shaders




Project progress #5


After some research, I learned that you are able to simulate transparency, reflection , and refraction with a skybox. To make a skybox using shaders, I had to make a cubemap. A cubemap is just a giant cube. I then proceeded to grab some images online that are specifically used for skyboxes to texture each side of the cube. This then alters the perspective to make it appear as if you are in a world. After adding this, I took off the lighting of my bubble and gave if a default color of red. Below is my bubble animating in front of the front side of the cubemap.



Bubble With Skybox




Project progress #6


The next phase of my project was to reflect and refract the textures of the skybox onto the bubble. There are built in functions in GLSL which allow you to do this. I only needed to use the refract function. The refraction function takes in three parameters: the incident, the normal, and a ratio. The incident is the normalized position and the position is calculated by multiplying the view matrix, the model matrix, and the position of the mesh. The ratio is just a float that determines the amount of light let through the object. Here is a list of refractive indices that informs you what ratio you should use depending on the appearance you want. I went with a glass-like refractive surface so my ratio was 1.52. Below is an animation of my bubble with refraction and reflection implemented into the shader.



Bubble With Refractive & Reflective Surface




Project progress #7


For this part of my of my project, which I think is the final part, I implemented chromatic aberration on my bubble. To achieve chromatic aberration, you must have different ratios in the refract function. There must be three: one for the R, G, and B components. You then combine the three into a single pixel and render that color. Bubbles have a yellowish and purple refractive surface, so that was what I was going for. I increased the ratios for the R & G to around 1.80 but left the B ratio to 1.54. This gave me the refractive surface I was going for and below is what it produced.



Bubble With Chromatic Aberration