Assignment 9
Screen Capture
Main Section:
The goal of this assignment was to take the same build work flow we did for custom geometry, and do it for effects as well. I created my own custom human readable effect file (which can bee seen below in figure 1), and then I created an EffectBuilder that would build that into a binary file (which can be seen in figure 2 below). Lastly, in figure 3 below, you can see the code I used to read data during run-time from the binary file.
Looking at the human readable file, I wanted to store three core things: vertex shader path, fragment shader path, and the render state. I opted to have as much text description as possible in the file to make it easily understandable. You can clearly see there are paths, and you can clearly see how you would modify different properties of the render state.
Looking at the binary file next, I wrote binary data as follows:
(1 byte for render state) (char string for vertex shader path with null terminator) (char string for fragment shader path with null terminator)
Looking at the binary file, I underlined in red the first byte representing the render state. I then underlined the null terminating characters in the paths. By using null terminating characters, I could easily determine during run-time where each path starts and ends. It also makes it easy to just directly read from file memory in order to attain the path (the path isn’t retained by the actual object). You can see this with the red arrows in figure 3, I simply cast the pointer and I’m on my way!
When building from human readable to a binary file, I end up converting the vertex and fragment shader paths to include “data/” in front of them. A couple of points to be made on why this is done this way:
- Firstly, a game user writing the lua file would path logic relative to their point of view of where the shader files are located. They shouldn’t have to worry about the ending path of the actual build. So we do this path conversion process to represent that aspect
- Secondly, putting everything in a data folder from the build’s perspective just makes sense. Assets are organized in an intuitive manner when it comes to final built projects
- Lastly, in my opinion, it is more optimal to do the path conversion before writing to the binary file because it saves the need to convert paths during runtime in the game. If during build time we know where everything is already gonna go, why not just convert.
A couple of weird issues I ran into during all of this that concerns me. One issue that I ran into was that my anti virus was constantly flagging issues with my built files and preventing them from running. I had to disable my anti virus to get things working. Secondly, I sometimes ran into build issues with missing GeometryBuilder.exe and EffectBuilder.exe. But restarting visual studio would fix the issue and things would build fine. I am curious to know if something we did recently is resulting in possible security issues that are being flagged by my antivirus.
Credits:
I discussed the assignment with Byreave, and Bosan.
Got free dinosaur model from: https://www.turbosquid.com/3d-models/3d-indominus-rex-rig-irex-1182227 . Had to reduce poly count.
Fig 1 : Human Readable Effect File
Fig 2 : Hex Dump Of Binary Effect File
Fig 3 : Code to Extract Binary Effect Data
Instructions:
Use left and right arrow keys to move the camera
Use up and down arrow keys to move the camera forward and backward
Use ‘W’ ‘A’ ‘S’ ‘D’ to move one of the shapes.
Use ‘SHIFT’ to change the shape that moves when held down