top of page

Cross Platform Shader Based Geometry and Lighting

       This assignment is meant to start up in the interactive computer graphics projects to help understand the graphics pipeline and OpenGL. In this assignment, we were asked to render very simple scene along with phong lighting model. The assignment was not that hard with the Super Bible Code - most of the requirement was already in the code especially mouse and shader code.

 

In previous semesters, I was building similar codebase using DirectX. I started my codebase to be working for DirectX and OpenGL with a better Asset Build system. I wrote OpenGL implementation for all of my code base for DirectX  and luckily all worked pretty fine. In this assignment, I focused more on the cross platform development along with the assignemnt requirement. 

 

First part of the assignment is to make a simple room with a sphere and a cube - I used Maya to create the model and used directly in my application. This exporter and format is custom format which I decided upon previous semester to work on. The format is easily exportable in the format with custom Maya Plugin which I wrote in previous semester. My format looks like:

With the format, it was easy for me import the meshes but changing the vertex color attribute wasn't straight forward. For this I used, a separate material files which describes which type of shader and material property is needed for each mesh. Moreover, I also included the texture capability to my texture maps. This was not hard to port it o OpenGL as they were mostly platform independent. Only problem which I faced was with uniforms. I tried to decouple the application with the uniform names from the shader object - this took a longer time of mine to figure out best possible way to achieve it. I chose to give the uniform in a separate file which contains the name of the shader files along with the uniform names.

I over estimated the system and lost most of the time to make it better and unfortunately, I was not able to finish couple of things as per the requirement. I could not complete mouse rotation, switching between shader and color change of the vertex attribute. Among these left ones, it is pretty easy for me to change the vertex color and switching the shader with a bind of the keys. I already have a messaging system in place to achieve this but due to lack of time unable to finish it. This I will add perhaps in couple of day. Only thing, I need to work on camera rotation using the Mouse.

 

As per the shader is concerned, I wrote a cross platform shader to maximum extent so that I can get the similar effect for DirectX too. Currently, I hardcoded most of the parameter for the lighting sue to which I am not getting corect result for the lighting but I need to come up with a better design to incorporate this.

As of now, I got the output as below.

Click to check the executable. Controls - WASD for camera rotation, Arrow Keys for forward, backward, left and right.

bottom of page