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.
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.
I was getting a weird bug while doing this assignment. The bug was like a cracked screen and looked as follow :
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.