After converting our mesh file to binary in last week’s assignment, this week required us to do the same for the effects. We created human readable effect files, build them as binary and use that binary file to load the effects.
As we created the mesh builder earlier, for this assignment we created an effect builder. The job of effect builder was to read the human readable effect file and save them as binary in the game install directory. Like mesh builder, this is also run at the build time of the program.
Like mesh builder and effect builder, we have another app called as ShaderBuilder which builds the actual shader used by the effects. Previously, we used to specify the shaders to build in out AssetsToBuild.lua file (this file stores all the information of the assets for the AssetBuilder to build). Now since the path of these shaders is in our human readable file, we don’t need to specify them in the AssetsToBuild, rather they registered for building before we make a call to execute Effect Builder.
For showing an effect on screen, we need the following information:
This first byte of binary file is used to store render state bits. Next two bytes are used store the lengths of the file paths for vertex and fragment shader. The following bytes are used to store the actual file paths for the shaders. I am storing vertex shader first and fragment shader second.
Below are some of the thing I kept in mind while writing this file:
Playable EXE Download
W S A D to move game object.
Up Down Left Right to move camera.
Ctrl to switch the mesh of game object.
Space to hide one object (plane).