Saturday, October 28, 2017

The Art of Optimization

Disclaimer:

Most of the projects that I will be doing are for a game that I am developing on my own code named Project Ninjio. In short, the game is a story action driven role playing game (common referred to as an action RPG). It features 2 uniquely styled areas, one in which the cities are built to flow along with nature, and the other where the cites are hyper futuristic. The game is set in a futuristic China, where after a large war, the country is split into the two settings described above. The game is built in the Unity 3D game engine.

The Art of Optimization

Introduction

It has been my goal to insure that Ninjio is the best experience that I can offer to its players. I had many smaller goals that I have for Ninjio to insure this high quality experience, however one of them (and the most important one to the gamer inside me) is making sure that the game will run at a constant 60 frames per second (FPS) or higher at all times on all sorts of hardware.

60 whats?

Without diving too far into the technology that we all use on a nearly daily basis, a frame in terms of a computer is the image that the computer is outputting to your monitor or display. It is well documented that the human eye can only see around 30 to 60 of these images per second, any lower number and the image would look choppy while any higher number would result in a similar looking image while wasting computing power, which is not ideal. Gamers, like myself, can definitely "feel" the difference between 60 fps and it's lower counterparts. Most games these days strive to run at this 60 fps threshold, however most fail (especially when running on consoles) and run at around 30 fps. 

So what are the benefits of this higher frame rate?

Image result for frames per second
Look at the difference, the 30 FPS image looks smeared
compared to the 60 FPS one.
In short, the higher the frame rate (and therefore higher fps) the faster you see the result of your action, say moving your mouse or pressing a button. This is generally what you want in games where there is a lot of action going on at a time, like Ninjio. Another benefit to this higher frame rate is that images do not look blurry and smeared when you pause the game, as there are more images being outputted to you monitor.

The challenges of achieving higher frame rates

In short, there are 2 ways to achieve higher frame rates, by either optimizing your code or optimizing your art. While optimizing your code could yield a better result on a per optimization basis, it is generally harder to do. Art, on the other hand is very easy to do. It is important to optimize your art as best as you can, even while you are creating it.

How to optimize your art

Related image
Not a too much changes visually here
One easy way of optimizing art in video games is to make sure you are using the least amount of vertices (or points in 3D space) as you can. By doing so and asking questions like "Do I really need a ton vertices to make a sphere when I could do it in much less vertices and have it look the same", you can optimize different pieces of art very easily. Another method is to remove any faces (3 or more vertices put together to make a side of an object) that you know that players are not supposed to see. This could be like the back of a building facade that players cannot see in game or the bottom of a building that would normally be buried under the ground.  These methods are very simple and easy to do, however sometimes you do need a high polygon count on an object or sometimes you do need all of the faces to be filled in, it is situations like this where different programing tricks come in handy.
Image result for level of detail
Level of detail (LOD) in Team Fortress 2

One programming trick is level of detail, or LOD for short. It is the process of making it so that the game engine gradually reduces the amount of detail in the object as object gets farther away from the player. This method has to be programmed, but the results of it can vastly improve the performance of the game.
Image result for draw call batching
An example of draw call, look at how the
 trees are rendered together in a single
graphics call, as shown by the grey box.
Another programing trick, one that is fairly easy to do inside of the Unity3D engine, is draw call batching. This trick involves telling the computer that instead of treating each object as its own separate entity upon the rendering of the scene, instead the engine tells the computer that a certain group of objects should be rendered at the same time, thus saving processing time on the computer's side. This trick only works well when you have objects that are static, like building and pieces of the environment that do not move during gameplay.
Occlusion culling in Horizon: Zero Dawn
One last programming trick is called occlusion culling. In short, it makes it so that the computer only renders what the camera inside of the game can see. Normally the computer will render every single object in the scene regardless of if it is onscreen or not. With occlusion culling, the game doesn't render anything that the player cannot see through the camera, so objects behind the player are not even processed and rendered at all. Occlusion culling is used heavily in some of the earlier 3D games like the original Crash Bandicoot. However this method has become popular in modern games like Horizon: Zero Dawn as the method allows for a higher visual fidelity, especially in games where the worlds are large and expansive. 

Saturday, October 14, 2017

How to Model: Hair, the Anime Way

Level of detail (LOD) in Team Fortress 2

Disclaimer

Most of the projects that I will be doing are for a game that I am developing on my own code named Project Ninjio. In short, the game is a story action driven role playing game (commonly referred to as an action RPG). It features 2 uniquely styled areas, one in which the cities are built to flow along with nature, and the other where the cites are hyper futuristic. The game is set in a futuristic China, where after a large war, the country is split into the two settings described above. The game is built in the Unity 3D game engine.

How to Model: Hair, the Anime Way

Image result for my hero academia
The characters of My Hero Academia

Introduction

While working on the model for Bing Nu, I have struggled a bit to make the hair for her look both realistic yet have it fit in with the art style of Ninjio. I have watched numerous tutorials online, however most result in a hyper realistic hair style and shape which would not suite the pre-defined art style of Ninjio. While watching a little bit of Boku No Hero Academia (My Hero Academia in English), one of my favorite animes to watch, I realized that the way hair is done in anime is quite different compared to other art forms.
Unlike other art forms which use individual strands and strokes of hair to make the hair flow and act realistic, anime hair tends to clump the pieces of hair together in one shape. This results in anime hair being more expressive of the character than that of traditional art forms where the hair is just there. Another benefit of using this anime hair style is that the hair on the character could not follow the laws of physics and still look good.
Since this discovery, I have developed a method for modeling this style of hair on characters inside of the Blender 3D modeling programing.

The steps

Step 1) Start out with the head that you wish to cover in hair.
Step 2) Create two bezier curves by pressing Shift-A and then to Create Curve and then to Bezier Curve.
Step 3) Create a bezier circle by pressing Shift-A and then Create Curve and then to Beizer Circle
Step 1
Step 2 (and 3 I guess)

Step 4








Step 4) Under the Shape tab of the Curve Options editor window, set the preview resolution of the bezier circle to 2. Then rename the circle to something that you will remember, I use Hair Bevel Object for mine. Move the circle somewhere in the scene where it will not be in the way of the rest of the modeling.
Step 5) Using one of the bezier curves, go into Edit Mode on it, move the control points and the handles around until they match the ones show in step 5's image. Rename the curve to something you will remember, I use Hair Taper Object for mine. Move the curve somewhere in the scene where it will not be in the way of the rest of the modeling.
around with the handles to make it look like
Step 6) Using the other curve, go into it's Geometry Options under the Curve Options editor window and set the Taper Object to the bezier curve you made in step 5 and the Bevel Object to the circle you made in step 4.
Step 5

Step 6
Step 7) Now position the bezier curve that you made in step 6 so that the control points are where you want your piece of hair to start and end. Maneuver the handles of the curve to make the piece of hair fit along the head. You may want to resize your Hair Taper Object and Hair Bevel Object 
Step 8) Repeat steps 6 and 7 until you are satisfied with the results.
Step 9) Select all the piece of hair and then press Control-J to join all the separate bezier curves into one object
Step 7





Hint: use the mirror modifier to decrease the time that you spend modeling the hair!

Final Results


A monkey with hair, because why not?

 This week's work log:

Monday October 9th: Day Off: Columbus Day
Tuesday October 10th: Started work on Bing Nu’s hair, most ended work ended up scrapped
Wednesday October 11th: more work on Bing Nu’s hair
Thursday October 12th: Finalized work on Bing Nu’s Hair
Friday October 13th: Made hands for Bing Nu, added finishing, modeling, touches

Friday, October 6, 2017

The Art of Belonging

Disclaimer:

Most of the projects that I will be doing are for a game that I am developing on my own code named Project Ninjio. In short, the game is a story action driven role playing game (common referred to as an action RPG). It features 2 uniquely styled areas, one in which the cities are built to flow along with nature, and the other where the cites are hyper futuristic. The game is set in a futuristic China, where after a large war, the country is split into the two settings described above. The game is built in the Unity 3D game engine.

The Art of Belonging

Wait, what does that mean?

Yeah, I know that the title may seem very awkward at first, but I assure you that it will make sense. The title of this post should really be The Art of Belonging to, Identifying with, and Representing a group of people though visual means but I don't think that it flows quite as well. What I am trying to answer here is how one can visually be identified as part of a larger group.

So what does this have to do with your game?

The characters in Ninjio are varied, ranging from a ex-prince set out for revenge to a hacker trying to install the truth. This variety in both motives and physical appearance raised an interesting question for myself to answer, how do I make sure that they all seem like the belong together as part of a common force trying to remove evil? There are many ways of answering this question, ranging from uniforms to common symbols found on them.

Image result for star trek
The cast of Star Trek in their character's outfits.
Notice how they all have the same, uniform, look to them.
I originally planned for each of the characters in Ninjio to wear a uniform, however I have since moved away from that idea as it would limit the amount of personality that I could add into a character. I could also do something like in Star Trek where the character's outfits are similar to each other with only the colors of them changing, however this once again would limit the personality that I could infuse into a character.

The other option is for each of the character to have a symbol or object that all the characters have on them in some form or fashion. I think that this route would be best as it would not restrict my designs for the characters as long as the symbol is something small , like a flower.

What is that symbol then?

The design for Bing Nu, note
the magenta gemstones throughout
her design
The symbol that I am planning on using for the characters found in Ninjio is a gem of some sort. In my plans for Bing Nu's design, I included a gem stone in her outfit. This was originally included in her design as part of one of my friend's idea to have the personalities of the characters be symbolized in the colors of the clothes that they wear based off flowers and what different types of flowers symbolize (see image for more information).
A chart of what each color of
flower symbolizes

I feel that the gem stones could be used to symbolize different things based on their colors and where they are on the character. For example, I plan on making the villain in the story wear a black gem on a ring positioned as far away from the heart as possible to help convey the fact that he is a heartless ruler.

This week's work log:


Monday October 2nd: Finalized the shape of Bing Nu’s body

Tuesday October 3rd:  Started work on Bing Nu’s head
Wednesday October 4th: Halfway done shaping the head of Bing Nu
Thursday October 5th:  Finished the head of Bing Nu and attached it to the body
Friday October 6th:  Day Off: Teacher In Service, some initial work on the next character's sketch

Thursday, September 28, 2017

The Art of Bing Nu


Disclaimer

Most of the projects that I will be doing are for a game that I am developing on my own code named Project Ninjio. In short, the game is a story action driven role playing game (common referred to as an action RPG). It features 2 uniquely styled areas, one in which the cities are built to flow along with nature, and the other where the cites are hyper futuristic. The game is set in a futuristic China, where after a large war, the country is split into the two settings described above. The game is built in the Unity 3D game engine.

The Art of Bing Nu


Time to replace the
infamous "Mr. Pill" development
characters

Introduction

One of the main thing that I want Ninjio to be known for is it's characters and the story that the characters follow. The first thing that I remember doing after writing the story for the game is replacing the temporary names of the characters (such as good guy #1 and #2) with their final names. The names which are in Chinese, mean something very special due to both their meaning and their place in the story. The first name that I settled on for the only female main character is Bing Nu (冰女), or Ice Queen in English. Her name may seem random, but it makes sense once you play the game.


The design process

Step 1) Character concept

This is when I take time to write about what I envision the character to look like in my head. This is only just a rough idea of the character, but given my visual mind, it results in a good idea of what the character will both look like and sound like in the final game. The description for Bing Nu, from the official game design document, reads:

Is somewhat short and a little bit chubby. Wears a white skin tight suit. Also wears a light blue, black trimmed,chest armor on top of it. Also has thin glasses.

Step 2) Character sketch

The sketch of Bing Nu
This is the part of the design process that currently takes me the longest. This is where I take the
written description, combine it with any other thoughts that I may have for the character, and then make a 2D sketch of the character. This part is typically filled with many mistakes. I tend to keep the character in a classic t-pose to help me model and rig them later. I remember that the process for developing Bing Nu took around a week of off-and-on work. In that week, she had been drawn like a male character twice, lost her glasses, and had her colors changed around to suit her more gentle attitude.

Step 3) 3D model

The unfinished model of Bing Nu
This is where I make the actual 3D model that players will see in the game. I take the 2D sketch that I
made in the earlier sketch and put it into Blender (my 3D modeling software of choice). This process doesn't take that long in comparison to the other two previous steps as I am simply following the plans I have made. 

Step 3b) Texturing

This is where I take the 3D object and give it its colors and personality. I take the model, UV unwrap it, and then texture the model by painting color onto the model. I have not started this process with Bing Nu yet, so sorry for missing a screenshot for that. In fact, the next steps I have not done yet for Bing Nu either... but I will keep everyone reading posted on her development!

Step 4) Rigging and animating

Stages for preparing a character (modeling, rigging, and skinning)
The center image here shows what
Unity wants it's humanoid models to be rigged like
This is the step where the object truly comes to life. I add a rig to the model so that the computer knows how to change and manipulate the model around when I move different parts of the rig. I tend to rig my humanoid character exactly how Unity likes to accept them, as the game engine can then store that data in a much smaller file size compared to if it was not a humanoid character, through some programming magic. This rigging format also allows for characters to, with the right preparation, share animations with other characters.

Concluding thoughts

I will make another post here on the blog to show everyone reading the final modeled, textured, and rigged version of Bing Nu whenever I finish her up!

This week's work log


Monday September 25: Installed Ninjio Unity3D project file
Tuesday September 26:  Started work on the torso on the model for Bing Nu
Wednesday September 27: Finalized work on the torso section on the Bing Nu model
Thursday September 28: Modeled hands and arms on Bing Nu model
Friday September 29th:  Fixed many issues with the vertices on Bing Nu's model