Friday, January 18, 2013

Graphics Assignment 1


This week's graphics assignment was simpler than I thought it would be. We were required to build our own mesh format, a mesh builder tool and make some changes to John Paul's vertex and fragment shader.

Here is the download link for my assignment. Download code

File/Mesh format
My file format looks like this:

NoOfTriangles = n
x , y
x , y
x , y
x , y
x , y
x , y

Here is my rectangle mesh for this assignment:

NoOfTriangles = 2
0.6 , -0.5
-0.6 , -0.5
-0.6 , 0.5
-0.6 , 0.5
0.6 , 0.5
0.6 , -0.5

Vertex shader
I changed the vertex shader so that the rectangle moves in a cool counter-clockwise fashion across the window. What I did is basically add a sine wave of the elapsed time to the input x position and subtract the input y position by a cosine wave of the elapsed time. Then I scaled the displacement down by a certain value, so that the rectangle moves inside the window.

Fragment shader
I added a cool negative image effect to the fragment shader, by subtracting 1 by the input color.

Here are a couple of screens:









PIX screenshot of Vertex shader




PIX screenshot of Fragment shader




Notes
I did not run into any problems with the programming part. But I had a hard time dealing with PIX, since I had never used it before and was absent for John's first lecture.

No comments:

Post a Comment