Game Engineering || – EAE 6320 – Assignment_12

Overall this assignment was really long and I found it pretty challenging since the instructions were not as straightforward as the other assignments. The order of the requirements were not given sequentially so it wasn’t clear whether to start from the top or the bottom. However, it was worth it to figure it out and learnt a lot.

The main objective of this assignment is create the material system in the game. So earlier the color of the mesh was based on the vertex colors that were in the mesh files. So if we had to add a different color to mesh we would have to create a new mesh file with different colors. Now in this assignment we can use the same meshes and use different colors with our materials that we have created.


The screenshot of my human readable file looks like as shown above.
The pathEffect is the relative path of the effect file. The UniformData holds different uniform information.
UniformName indicates the uniform name.
The ShaderType indicates the type of shader whether it is vertex or fragment shader . The values indicate the values of uniform .


The above picture shows the binary version of the effect_transparent.lua file which is the blue transparent material’s binary file.

The red highlight shows the path of the effect file. The yellow highlight shows 02 which indicates the number of uniforms which is 2. The pink highlight shows the uniform names . Since this is a transparent material it will the colorRGB as well as the alpha modifier. The green highlights are the null terminators. The blue highlight is basically the struct of the uniform data.

If this were a opaque shader then it would not have the alpha modifier . The picture below shows the binary file for an opaque shader which does not contain the alpha modifier. So you can only see the colorRGB for the case of opaque material.

hes opaque

The output is shown below.

It contains 4 box meshes which is using 4 different materials. The first two which is the red and the green are opaque and hence have no transparency in them. The last two are yellow and blue which are transparent materials. The yellow has the transparency of 0.3 while the blue has the transparency of 0.7 . Hence yellow box looks more clearer than the blue. The way you affect the transparency is by making the alpha modifier value for yellow box to be 0.3 and for the blue box to be 0.7.

bandicam 2015-12-07 00-00-33-977

I was getting a weird bug while doing this assignment. The bug was like a cracked screen and looked as follow :

bandicam 2015-12-08 16-56-59-875

Initially I though that I was not writing or reading the lua file properly but after looking at the binary files and then debugging the values that was not the problem. The problem turned out to be a simple one . I was not setting the path of the effect file due to which I was getting this weird pattern. But it took me quite a while to figure out this problem. Another problem that I faced was that my s_direct3dDevice was becoming null. The solution for that turned out to be that I was creating the material before CreateDevice() . So after moving that code for creating material , after the CreateDevice() was called, the device was not longer null. This again took me a long time to fix.

You can download the Zip File of Assignment_11 from the following
link to get the square output.

The controls for camera are First Person Shooter controls as follows:
A –     to strafe left
D –    to strafe right
W –   to move forward
S –     to move backward
Space – To fly upward
Z –    to Dive Downward
E –    rotate Camera ClockWise
Q –   rotate Camera AntiClockwise

C-    rotate the man around the house in clockwise direction to guard          the house
X-   rotate the man around the house in anti-clockwise direction to             guard  the house

Use arrow keys to control the mans movement


After downloading the link run Game.exe.



Game Engineering || – EAE 6320 – Assignment_11

The main objective of this assignments is to create a Maya Exporter which is used to export a maya model in the human readable format. We can then use this human readable format and load it into the game. We also create a transparency effect for which we create render states for opaque and transparency effect.

So the work of the MayaMeshExporter is to convert the model in Maya to the human readable format. For that we have to write a function called WriteToMeshFile() according to our human readable format and this will convert the Maya model into our format.

As far as the dependency goes, the MayaMeshExporter is independent i.e. it does not depend on any other project in the solution. This is because its sole purpose is to convert the Maya model into the human readable format. You can pretty much just export the Maya model and build this MayaMeshExporter alone and independently and it will generate the human readable format for that particular model which is a great feature to have.

The following image shows the Plug-in Manager in Maya 2016. You can also see the two custom names. For my Release version the name is “eae6320_mankoo_hardit.mll” and for my DEBUG version the name is “eae6320_mankoo_hardit_DEBUG.mll”.

bandicam 2015-11-16 22-13-23-117

My scene below contains 4 meshes:

  1. House Mesh
  2. Man Mesh
  3. Floor Mesh
  4. Sphere Mesh

bandicam 2015-11-16 22-28-18-887

My output is as shown in the image above. You can see the transparency effect on the sphere which is between the man and house. Earlier I had given the same color for the triangle faces of the house and the man but it was looking like a flat a plane. So to give the model some depth I varied the color on the faces with the lightest colors on the left and darker colors on the right to give an effect as if there is a point light on the left of the scene. This process would be much simpler when we learn texture coordinates.

So basically the man, the house and the floor are opaque that is they have an opaque effect . This means that their alpha_transparency is disabled. Their settings are as follows:
alpha_transparency = false;
depth_testing = true;
depth_writing = true;
face_culling = true;

The sphere on the other hand which lies between the man and the house has the alpha transparency and the depth writing enabled. Due to this the sphere looks semi transparent and every object that lies behind it would be visible but would have the semi transparent effect for the objects that lie behind it and are covered by the radius of the sphere. And the objects that are in front of it will not have the semi transparent effect . They transparency settings are as follows:
alpha_transparency = true;
depth_testing = true;
depth_writing = false;
face_culling = true;

My effect.lua file looks like as follows . As you can see I have chosen to add all the render states in one table under “render_states” because it makes sense to club those 4 boolean values which represent the render states under one table. It makes it easier for me to understand.

bandicam 2015-11-16 22-42-55-605

Basically we store the the render states in a uint8_t variable. The uint8_t is a 8 bit data type. Even from those 8 bits we only use 4 rightmost bits which correspond to alpha_transparency, depth_testing, depth_writing and face_culling. Hence uin8_t is actually big enough and dont need to consider uint16_t so and so on.
So earlier I had harcoded the values but from the discussions in class it makes sense not to hardcode them and associate a name for each. The advantage of associating a name is that we done need to remember which bit represents which render state.
For this I just defined 4 names as follows:
bandicam 2015-11-16 23-09-38-943

I just used the same order that was given in the assignment page, i.e. alpha_transparency represents 0, depth_testing represents 1, depth_testing represents 2 and face_culling represents 3. Our render state is basically a combination of 4 values which are
Alpha Transparency, Depth Testing, Depth Writing and Face Culling. All of these are boolean which allows us to enable of disable them.
To enable or disable these values we use bitwise operations. So say we have our render_state_value and we want to enable the alpha transparency and we want to enable the depth testing . For this we need to do a bitwise OR operation so that we can set or enable the rightmost two bits as follow:

render_state_value|= 1<<0 . This enables alpha transparency.
render_state_value|= 1<<1 . This enables  depth testing.
So now our render_state_variable looks like 0011.

My opaque effect looks as follows:
bandicam 2015-11-16 23-45-30-165
My transparency effect looks as follow:
bandicam 2015-11-16 23-44-58-120

This is how my binary files look for the opaque and transparency effect.
If you look at the highlighted value for opaque effects it shows “0E” which is 0xE which is 1110 . The information we get from this is that alpha transparency which is the rightmost bit is disabled, depth testing which is the next one is enabled, depth writing is enabled and face culling is enabled. So the information is correct as the opaque objects have no transparency and matches the values in our human readable effect file.
Similarly if you look at the transparent effect, the highlighted value shows “OB” which is 0xB which is 1011. This means that the alpha transparency , the depth testing and face culling are enabled but the depth writing is disabled. This again matches our human readable file.

For debugging the meshes in Maya I created a primitive test model called BigBox.mesh .  So if you see the screenshot of the debugging below you can see in the i_fileName the name of the asset which is being debugged which is BigBox.mesh . It also provides the vertex buffer and the index buffer information for the model which is a very cool feature .

Debug Maya 11

Overall this assignment took me 17 hours to finish .

You can download the Zip File of Assignment_11 from the following
link to get the square output.

The controls for camera are First Person Shooter controls as follows:
A –     to strafe left
D –    to strafe right
W –   to move forward
S –     to move backward
Space – To fly upward
Z –    to Dive Downward
E –    rotate Camera ClockWise
Q –   rotate Camera AntiClockwise

C-    rotate the man around the house in clockwise direction to guard          the house
X-   rotate the man around the house in anti-clockwise direction to             guard  the house

Use arrow keys to control the mans movement


After downloading the link run Game.exe.

Semester 3 Thesis – 7

Finally we have submitted the game to IGF at 5:30 am in the morning ! Everyone is burned out but we feel great and proud as a team . Here is the gameplay video of our game Blind trust.

So we are approaching the end of the semester. The only thing that needs to be updated now is the tutorial level. From the gameplay the tutorial level does not seem to be that intuitive enough for now. So that would be the final part that we will be working on this semester.

So basically my task now is to code the behavior of an insect that looks like a bee with some particles emitting from the tail.  He will orbit around the blind player in a sin wave fashion. There will be sound source on the bee and as soon as the blind player points to the sound source, the bee will move to another point around the player and the player will have to identify the sound again. This process will occur 4 times.

Basically the task list is as follows. My name is next to the tasks.


Game Engineering || – EAE 6320 – Assignment_10

The main objective of this assignment was to draw a 3D cube to the screen. We basically converted our previous 2D looking square to a cube by making a couple of changes. Along with cube we also made a camera through which we can maneuver in the game.

The 3D cube looks like the picture below:

bandicam 2015-11-09 21-50-30-599

The first important thing we do to convert 2D to 3D is to add the third dimension z-axis to the sVertex struct. We start by adding a z coordinate to our lua mesh file and update the MeshBuilder to read the z value.

We are also creating a frustum with several features like the Field Of View which describes the angle within which we can see the world. We have a near and far clipping plane. Any object outside this range is not visible.

Now the other important thing is that instead of we need to perform a MVP matrix transformation which is model view projection. Initially all out meshes exists in a Local Coordinate System.
Now a local coordinate system is a system where the object has its own local center and its orientation and coordinates will be relative to it own center or pivot.

To know where this object exists in global space or the world we have to perform a Local To World matrix transformation. By doing the objects orientation and coordinates now become relative to the world.

Now that the object exists in the world, we need to bring the object in view of the camera. We need to know whether the camera view covers the object or not . So we need to orient and transform its coordinates relative to the camera and this is called World To View
transformation. We do this because if the object exists behind the camera in the world then it will not be within the camera view and hence will not be visible.

Like a painter draws 3D objects on a 2D plane, we now need to find the projection of the objects visible to the camera, on the 2D screen . For this we do the View to Screen transformation.

bandicam 2015-11-09 21-50-30-599

We also need to do an important thing i.e. enable the depth buffer. Earlier our depth buffer was false and did not store any depth information. Essentially what was happening before was that the order in which we were drawing objects, we were just stacking them on top of each other. So the last object drawn would be the most visible. So we use the Painter’s algorithm approach before which was inconvenient.

But now we do the the depth test. The depth value ranges from +1.0 to -1.0 where 1.0 is the deepest depth. The depth buffer basically stores the depth of the pixels. So the depth of the pixels are compared to ones in the depth buffer and the lower the value that pixel gets drawn. Hence lower the depth value the closer that pixel will be to our near plane, and higher the value(1.0 being the maximum) the further away that pixel will be from the screen. So we are basically clearing the depth buffer to 1.0 because 1 is the max value for the depth and we use a less than operator because we want to draw those pixels which are closer to the camera.

My floor mesh looks like as follows:
bandicam 2015-11-10 00-44-11-410
So from the picture there is now a z axis in the mesh file. Due to that the size of each vertex is now 16 bytes because of 4 bytes for each axis plus the color.

bandicam 2015-11-10 00-43-28-972
So my Camera exists in the Graphics because i felt it had more graphics related stuff than gameplay. My camera has several movement functions. I also have a camSpeed which can be adjusted to move the camera faster or slower.I have given several controls to the camera . The list of controls are mentioned near the download section. I figured the rotation part for the Camera. Took me some time to figure out. Actually I was not multiplying with the ElapsedTime due to which it was rotating very fast at Computer speeds and not it real time seconds. But it works properly now. I also added the rotations to the Cube. The cube rotation seems to be a bit orbital for now.The key bindings are given at the download section.

In the picture below I was just trying to draw some basic primitive 3D shapes in order to understand the winding order properly.

bandicam 2015-11-08 01-04-00-822

Time Taken – 18 hours.

Here’s a recording of the Camera and Cube Controls.

You can download the Zip File of Assignment_10 from the following
link to get the square output.

The controls for camera are First Person Shooter controls as follows:
A – to strafe left
D – to strafe right
W – to move forward
S – To move backward
Space – To fly upward
Z – To Dive Down
E – Rotate Camera ClockWise
Q – Rotate Camera AntiClockwise

C-Rotate Cube Clockwise
X-Rotate Cube AntiClockwise
Use arrow keys to control the cube movement


After downloading the link run Game.exe.

Game Engineering || – EAE 6320 – Assignment_09

The main objective of this assignment was to make the Render() platform independent. So as you can see the picture  below I have split the Render in for Direct3D and OpenGL into Clear(), BeginDraw(), EndDraw() an ShowBuffer().

So there is basically no platform specific code within this Render function . It is platform independent. The implementation or the details would obviously differ depending on the platform. So the Clear() function basically clears the screen to black. We have the BeginDraw() and EndDraw() for the D3D implementation . For OpenGL I am just returning true for both the functions.

bandicam 2015-11-03 17-14-16-108

Below is the screen shot of my vertex shader . Had to take two screenshots so its half and half because it didnt fit the screen.

bandicam 2015-11-03 17-18-48-408

bandicam 2015-11-03 17-18-18-464

The vertex shader includes the which makes things more platform independent. I have also made the output position calculation platform independent. For calculating the output positions , I am however using the #if defined for OpenGL and Direct3D . The g_offset position is again common for both the OpenGL and Direct3D platforms.

My AssetsToBuild.lua screenshot is as shown in the image below where I have added the dependencies.

bandicam 2015-11-03 17-35-58-712

It took me around 6 hours to finish this assignment.

You can download the Zip File of Assignment_09 from the following link to get the square output. Use the arrow keys to move the red square.


After downloading the link run Game.exe.

Semester 3 Thesis – 6

So everyone is working hard for the IGF now. To give an update of the particle hit effect, through play testing the effects seem too realistic for now. It is not matching with the theme of the game so far.

So I have decided to work with the unity’s particle system and script to behavior to generate one from scratch. It will basically use the mesh which is provided by the artists or the texture that is provided by the artists. So far I came up with these effects .

The one in the middle is using the triangle textures will be used for the arrow hitting the wall. The particles will have the gravity effect and fall down in a cube shape and the collision with the obstacle is detected. I am using texture from the low poly prototyper pack from unity asset store. Later the artists will provide their own textures.


The following video shows the particle effect.

So far I am very happy with the results since it is low poly and cartoonish and goes with the theme of the game. It seems that the from the team feedback this effect is finalized.

Game Engineering || – EAE 6320 – Assignment_08

The main objective of this assignment is to create builders for loading the binary shaders and effects during runtime. So to achieve this we had to create Effect Builder and Shader Builders .

The Effect Builder basically generates a binary format of an asset file . I have named the asset file effect.lua . The effect.lua basically contains the path of the shader file which is the for the vertex and the fragment shader.

For the Shader Builder I have created two shader builders which is VertexShaderBuilder and FragmentShaderBuilder. So I went with the option of creating two shader builders because it was less time consuming option at the time . The job of the shader builder is to generate the binary format of the compiled shader depending on the OpenGl or Direct3D platform.

My effect file format looks like the picture below and contains the path of the shaders.

bandicam 2015-11-02 12-50-55-728

So basically we just add a NULL character at the end of the fragment shader path and vertex shader path when we write to the binary file . I find this better than counting the characters everytime the path gets updated. You can spot the two null characters which look like “00” in the image below which show the Null characters at the end of both the shaders . On the right hand side you can see the path which is readable.

bandicam 2015-11-02 12-54-50-320

My updated AssetsToBuild.lua now contains the Effect Builder, VertexShaderBuilder and the FragmentShaderBuilder. The AssetToBuild.lua picture is as follows:

bandicam 2015-11-02 13-35-48-601

The release and debug version of the vertex shader for Direct 3D are shown below. You can see that the Debug Version of the Vertex Shader is a lot bigger than the Release version . This is because it contains some unnecessary information such a o_color, o_position etc . The release version is a lot shorter as it contains only the important necessary information for running the game.

Release Version of Vertex Shader (Direct 3D)

bandicam 2015-11-02 13-11-21-821

Debug Version of Vertex Shader (Direct 3D)

bandicam 2015-11-02 13-11-33-580

As you see in the picture below the Release Version of Vertex Shader for OpenGL basically has the Direct 3D part stripped off from the Vertex Shader and the comments are removed. Again the reason for comments to be removed is to reduce the file size.

Release Version of Vertex Shader (OpenGL)

bandicam 2015-11-02 13-20-57-053

In this assignment I ran up with a weird bug which was causing some
random patterns for the Direct 3D Release Output. I was not able to figure out what was causing the problem. But after debugging the problem with John Paul we figured that I had made some rookie mistakes and we found some hardcoded values for Direct3D platform which were causing the problem, that I had forgotten to update after reading the binary mesh file . But it was good that we fixed those problems, otherwise they would lead to more problems when doing 3D in the future assignments . So I was able to get those bugs sorted out. The bug looked like the image below:
bandicam 2015-11-02 15-56-06-406

Time taken for assignment was 15 hours. The assignment was not hard but it took some solving the weird bug .

You can download the Zip File of Assignment_08 from the following link to get the square output. Use the arrow keys to move the red square.


After downloading the link run Game.exe.