Skip navigation

Monthly Archives: September 2014

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

File Link(.exe)


Click Me

Objective


This assignment requires me to draw a rectangle with indices. Also it wants me to replace the hard-coded shader loading with materials that based on Lua.

Colored Rectangle


rectangle

This is what my rectangle looks like, thank for my artist friend helped me to pick the colors again.

Capture1 Capture2

The difference between this and last assignment is I used indices to draw the triangles. Basically the index indicate the position in the vertex buffer. With the index we don’t have to put each vertices of each triangles into the buffer, which will save a lot of memory when we have a huge number of triangles to draw.

Materials 


Instead of loading shader files in hard coding, the assignment wants me to add materials to load it dynamically. When the game is loading the shader files, it will firstly go to ask Lua engine to load a material file, and the material file contains the information about what vertex shader and pixel shader should be loaded. This is what my material file looks like.

Material

Besides the paths of the shaders, it has other information to describe the material, such as name and color. I put a parent property for the material because I want a new material can be built based on the other material that we already have.  If the child material doesn’t declare a required property, it will automatically use the parent version as default.

I will add more options to the materials. The texture should be a texture array for supporting multiple textures, more properties need to be added to describe features such as reflection and opacity.

time estimation


Reading and searching — 1 h
Setting up solution / Coding / Debugging — 2.5 h
Bug Fixing — 0.5 h
Writing blog — 1 h
Total — 5 h

File Link(.exe)


Click Me

Objective


This assignment has two main objectives. The first one is to render a triangle with colors on the screen and understand the knowledge of it. Besides it, we need to add Lua into the project and replace the old assets builder with the new lua version.

Colored Triangle


Colored Triangle

That’s the triangle that I rendered. In order to make it looks not like a “Hello World”, I asked my artist friend to help me pick colors :D.

 

Capture1

 

It’s very simple to create a colored triangle like this, but a little background knowledge is still needed to understand this. As the minimum unit in the rendering process, a triangle is formed by 3 vertices. a vertex basically is a variable to indicate the position information, (x,y) in 2D for example. But it as well as is a container for more extended data for rendering, such as color, normal vector, texture coordinate and weight. In this case, I added color data for my triangle. As we can see in the PIX, a buffer that contains the vertices of the triangle is passed when the Draw function is called. Each vertex has information about it’s position and color.  And each color data is indicated as ARGB model and is stored in a 16-bit memory space.

Build assets with Lua


Lua is a very useful language to build the script system in game development. Basically, In the game code, we create functions in the format that Lua engine can recognize and register them to Lua engine, and then call the functions that we registered in the script to implement what we want.  In this assignment, Instead of implementing every details in the cpp file, the AssetsBuilder publics several core functions ( such as copyfile ) to the Lua engine, and created lua script for the rest implementations.

time estimation


Reading and searching — 1 h
Setting up solution / Coding / Debugging — 1 h
Bug Fixing — 0.5 h
Writing blog — 1 h
Total — 3.5 h

File Link(.exe)


Click Me

Objective


the basic objective of this assignment is to set up a solution for the future class as well as implement a simple asset build pipeline on it. Beside that, I want to create a framework on that not only for making the upcoming assignments a little easier , but also to plan to use for my personal games.

Assets pipeline


The assets pipeline is responsible for processing assets from the row data ( for example a png image that created by a artist ) to the final data that will be used by game. it sometimes just do a simple copy, such as the hlsl files in this assignment , from somewhere in the hard disk to the target place where the final game will be build, and it usually also be a processing contains data converting, data parsing and other complicated operations.

Specific projects ( actually I have two this time ) are possibly required for it to do a better work. The first project called AssetsBuilder is responsible for handling all of the convert( or say processing) functions for each of the file types the game need. In addition, another project , which actually has no code inside, calls the executable file from the first project while building to process all of the assets.

There are several reasons for why we let a new project run the AssetsBuilder instead of executing it out of the building process. the main reason is that it can take the advantages from some features of Visual Studio, modify data tracking for example.

Game


I want the game framework to be flexible to extend and convenient to use. The first thing that came to my mind is that I should hide Windows APIs as possible as I can because it s**ks to me and encapsulating them into some higher level classes will be very helpful for me. I have implemented a Game class for this assignment as the first step, you can open a game window by just calling Game.Run().

In the next step, I will keep improving the game class, also the whole game framework, in order to make my life easier in the future assignments.

Issues:


Issues happened in this assignment. It took me really long to get the solution setting done. The main reason is I lost my patient on reading and missed several key place, which waste me a lot of time to go back to read again. The tasks is relatively simple in this assignment but it also really easy to fail because of uncaring of small details.

time estimation


Reading and searching — 3 h
Setting up solution / Coding / Debugging — 4 h
Bug Fixing — 1 h
Git & uploading — 1 h
Writing blog — 1 h
Total — 10 h