Game Engineering – II | Assignment – 9
For this assignment, I had to completely overhaul how shaders were read into the game. Instead of being hard coded data paths, I had to create my own custom effect file which would store the paths to the fragment and vertex shader files as well as the render state.
Moreover, at build time this effect file would be read in and converted into a binary file which would then be parsed at run-time for get the required shader information.
Here is the executable MyGame_
- F1 – F2 — Move camera up – down
- F3 – F4 — Move camera left – right
- directional keys — move sphere
- SPACE — remove plane
Here is a screenshot of what my effect file looks like.
To make it easier to read I store the render states as boolean values which are converted into their required format when the file is parsed at build time.
And here is the binary version of the same file.
As can be seen I do not convert the paths to built paths at build time. Instead I do so at run time by prepending “data/” to the shader paths retrieved from the binary files.
Now, converting the shader paths and build time saves us runtime costs at the expense of requiring more storage space. Conversely, in my case, prepending the string at runtime requires more processing but saves us storage space.
Both solutions are valid and one may be better than the other based on the context. If there are space restrictions, my solution would be better. If there are processor restrictions, vice versa.
Here is how I extract the binary data at run time.
Refer to the binary file screenshot, each data path ends with a null character (Hex 00). When assigning to a string, it automatically treats the null character as end of string.
And finally, a screen shot of the game itself (for consistency).