Engineering Two Assignment 4

Assignment 4 Download!
To move, use the arrow keys for great success!

So in this assignment, we changed how color works, and it’s no longer hard-coded in the C++ side of stuff, but is determined by the material file. This was added to my material file:
constants =
g_colorModifier = { 1.0, 0.5, 0.0, 1.0 }

When reading the material file, it will look for g_colorModifier, and if it exists, then it renders as orange, as indicated above. Otherwise, it will take the defaults and render as grayscale.
If we change it to this:
constants =
g_colorModifier = { 0.5, 1.0, 0.0, 1.0 }
Then you get this:

Here, green is rendered. No need to change C++ code and recompile is necessary. You do need to rebuild assets, which will move the material into the necessary build location. Luckily, with the changes I made to the material system last time, I didn’t need to change much when it came to this. I just created a function that gets called once you read in the g_colorModifier that tells the material to grab the ConstantTable, which is a DirectX thing with all the constants inside.

The same function to change the g_colorModifier in the pixel shader could be used to adjust the location of the rectangle in the vertex shader. The only difference is that g_colorModifier uses a Vector4 (which is rgba), and the position takes a float array. It makes the exact same calls to the ConstantTable, with the exception of using the vertex shader instead of the pixel shader to get the constant value we’re looking to use.

We also refactored the build process to make it so different projects will build different assets. Currently, it still just moves things over using the GenericBuilder. So if we don’t have a specialized builder, it will copy the files to the data directory to be used for the .exe of the project. So if nothing is changed, it will still operate the same way it has for the last couple assignments: just moving things over. However, if we want to compile the shaders in the future, we could create a ShaderBuilder that would take care of it and change it to a format that would be easier for the .exe to read at runtime.

Time spent:
Changing the color system to use LUA and constants: 1.5 Hours
Adding in movement and the material constants: 1.5 Hours
Changing the build system: 1.5 Hours
Writeup: 30 Minutes
Total: 5 Hours

Leave a Reply