William Garman
OpenGL Shader Programming
Language and Engine used:
-
I used Newcastle Universities graphics framework NCLGL to render the scenes and modified it in C++.
-
The Shaders were programmed using OpenGL.
​
The assignment was to use OpenGL shaders to "Destroy" a cube. We were given a scene of a rotating cube and told to create six different ways of destroying the cube using shaders. The first 3 were suggested for us:
-
Shrink the cube till it disappears.
-
Slowly interpolate from one texture to another damaged looking texture.
-
Slowly increase the transparency of the cube until its invisible. I chose to use Y position as well as time to calculate the alpha (opacity) value of in the fragment shader. This made the cube fade out in a wave from the top to the bottom.
The final three ways of destroying the cube were left for us to pick but had to use more advanced shaders. I used tesselation control and evaluation shaders as well as a geometry shader for each:
-
Tessellate each triangle primitive of the cube into many smaller triangle primitives then after a certain amount of time project each triangle away from the centre of the cube. This Effectively shattered the cube into many pieces.
-
Tessellate the cube again and after a certain amount of time begin converting the triangle primitives to cubes with the geometry shader and transforming them downwards to show them falling away from the larger cube. Similar to the transparency shader I used the Y position of the triangle primitive to calculate when it should fall. I used this to make the cube fall apart from the bottom to the top.
-
Finally tessellate the cube and at a certain time tessellate the cube at a specified time deform a section of it into a crater. At that time another smaller cube in the scene was programmed to hit the cube. This made it look like the smaller cube had impacted the larger one making part of it into a crater.
​
For all but the texture swapping scene I used my own specialised fragment Shader (or a modified version of it) to make it look like rainbow waves were crossing the surface of the cube. I did this by using basing the RGB values on Y position of the fragment and time.
​
Overall I enjoyed this project and it made me look forward to further graphics work in the future.