Sunday, October 25, 2015

3D Graphics CSCI-580

3D Graphics and Rendering

I worked on 3D Graphics and rendering class to develop a 3D graphics library.

I started with creating a 3D model of famous Utah tea pot from a base model to developing application of a rendering algorithm then moving on to shading, adding animations with anti-aliasing. Later I went on with my team to create a ray tracer and shading algorithm in our final project.
Our Web page : 3D Team Voxel. A lot of hard work went in this process but the end result is sweet and satisfying.






Few Snapshots are:

So, I started with developing a parser which interprets the 2D space and represents the X, Y coordinates. This code was written in Visual C++ and all the API calls are developed from scratch.
We took the famous Utah teapot triangle data file and parse it into a buffer space. This we called as frame buffer, the space where we fill our coordinates.




Then I worked on the 2D grids so each grid has defined color gradients and applied segment overlapping giving depth to each segment.



Then I worked on the 3D model mesh provided as a model and render it on a 2D plane. The challenge was to capture it perfectly and following issues like tapering on top, half scene rendering was a challenge. The Z-rendering was the issue. We need to assign each tris a z-index but if you do not initialize it in the beginning to MAXINT then you will find blank spots on the pot and some surface will render incorrect.


Once rendering was done I worked on shading. I used LEE rasterization algorithm. I worked on two different type of shading. 

Phonge Shading

If the point is not in shadow, we used Phong shading to determine the color of the point with respect to that light:

                I = lightColor * (kd * (L dot N) + ks * (R dot V) ^ sh)


Then worked on Translations where the model can be moved around in 3D space on x,y,z coordinates


Rotation
Added rotation along any of the 3 axis (X, Y, Z)


Scaling
Added scaling along three axis (X,Y,Z)



Final application was combination of  translation, rotation and scaling


Later I added shading and shadows.





Following is the final product of Shadow and reflection of image on the pot. Basically we calculated each pixel from the logo and did a reflection on pot and then recreated each pixel with the values from the image(USC logo). This was an amazing experience as I learnt so much we can do with maths and calculate any curved surface reflection on another surface..