Skip navigation

File Link(.exe)


Click Me

Objective


This assignment requires me to add a per-material color modifier in fragment shader to change the final  mesh color. Also it wants me to add a per-instance position constant in vertex that will be updated each frame to relocate the mesh on the screen. Besides these, I need to added a specific builder for copying the assets.

Color Modifier


The game will looking for the “color” property in the material file while loading and set the color as a constant to the pixel shader. When the game is running,  the pixel shader will change the output color each round of rendering depends on the constant that we loaded from the material file.

When I set the material color to purple, the result looks like this:

mat color 1color modifier result 1

Then if I set it to gray green, it will look like this:

mat color 2color modifier result 2

 

When we don’t have the color property in the material, the pixel shader will use the default value as the color modifier.

Moves the Rectangle 


In order to move the rectangle with vertex shader, I added a constant in the shader code , which will be updated each frame when the game is running. In the update() function of my Game class, I handle the input ( arrow keys (UP, DOWN, LEFT, RIGHT)) to change the position of the rectangle.

rectagle moving

Time estimation


Reading and searching — 1 h
Coding / Debugging — 4 h
Writing blog — 1 h
Total — 6 h

Leave a Reply