Friday 22 March 2013

FBOs: why and how



With the next generation of console games just around the corner, we should look back at how our games have advanced in the past few years. For this generation of games not only have they transited into the High Definition era, but also alot of special effects have been applied to our games. Specifically, we have seen a variety of full screen/post processing effects, such as from motion blur, to bloom and HDR(High Dynamic Range).

Why do we need FBO's

 

For those of you who have used Photoshop, you probably would have used a filter of some sort to make your picture look better. Now think about how would you apply that to "the game", especially a 3D, where some objects will be sticking out, while others will be "deeper" in the screen. So what we need a "screen shot" of the current screen, with that we can apply filters and other effects. Thats what the FBO is, a simple flat plane("texture") which the scene is rendered to first. After you are done, then you would apply your filters to it and display it.

Think of the scene as a stage actor getting ready to go on stage. Prior to ever show an actor must put on their custom, and usually some sort of make up, and thats what we do during the FBO stage.
HDR

Bloom


FBO (Frame buffer object)

 

To do this, we need a FBO(Frame buffer object) which stores the current scene, in a texture, sort of like a special picture. Here we store how the scene looks, the variables we need to analyize it, and sometimes we will specialize the buffer object to store a specific variable. Here is how a very plane scene will look with an FBO side by side the actual scene, WITHOUT any shaders .

 Heres how would your drawing Pipeline (order) should go with Shaders/FBO 
  1. Bind the FBO, like turning on the camera to start its recording
  2. Bind the shaders to start making the scene pretty, but not the post processing ones
  3. Set the camera position, and apply all transformations.
  4. Draw ALL THE OBJECTS 
  5. Unbind the shaders which were bound in step 4, for this update their jobs are done 
  6. Unbind the FBO, you just finished recording the whole scene  
  7. Do postprocess, start by applying the post processing shaders 
  8. Now apply the fbo's Texture to a full screen quad function, where it will project the game on to a flat screen
  9.  unbind all shaders
  10.  swap the buffers( I haven't used it for SFML, but glut most definably need this to be done 
  11.  

Creating An FBO 

 

Creating an FBO we need 3 steps: Create the FBO handle, create the colour storage, and finally depth storage using a texture. Just make sure to include Glew.h file and call the function glewinit prior  to initializing the game for this to work. 

 Binding the FBO

 

Just use the simple code below, to bind the gframe buffer before using it ANYWHERE. However don't forget to unbind when you are done with it, which is simply done with a similar code, glBindFramebudder(GL_FRAMEBUFFER,0);


  
   

The FBO Creation

 

This can be be as simple as the code below, as I am making this for an FBO class. Below is the explaination of the code. 

  • You create the FBO using glGenFrameBuffer (number of FBOs, FBO name)
  • Now you bind the FBO using glBindFrameBuffer(Gl_FRAMEBUFFER, FBOname)
  • fboWidth, and fboHeight- this is storing the size of the FBO, so you can pass in the screen size once, and not ever need to pass it again.
  • Now you unbing the  FBO using glBindFrameBuffer(Gl_FRAMEBUFFER, 0)

 

Create the Colour+ Depth storage 

 

Basically when creating a colour and depth storage, it is stored in a 2D texture, based on the camera view. When creating a color and depth storage, you can copy and paste the code below. 
  • Red is where you must bind, and unbind your frame buffer.
  • Orange is where the texture is being generated, binded, and created. If you are copy and pasting this code, make sure Colour storage uses ColourStorageTextures variables, and depth storage uses depth StorageTextures variables
  • Blue is another spot where the frame buffer data will change from Depth and colour storage
  

 

Other parameters 

 

Below are some other parameters you might want to use  when initialing.


As you can see,  there are only 3 extra variable which will affect the texture creation if you are using specific shaders.  For example if you are using HDR, your interal format and internal type wil change. In this picture I have colour coded accroding to each of the variables, so you can easily find it without me explaining. However the 2nd line of if statements may be confusing for those who haven't seen it before, so I have translated it below.

 

Conclusion 

FBOs are powerful objects which are needed for some effects, hopefully this has helped you out. Hopefully your FBO won't look like mine when I first implemented it into my game.




Monday 18 March 2013

Our Game Revisions: Our Vision

With the all mighty Level Up Event coming soon (in about 2 weeks), we wanted a professor's opinion for our game. We understood going into the meeting, our game didn't look so good, however game play was there. From the meeting this is what we gathered, the menu needed to be improved, the game play needed to be easier, more responsive, and we needed a distinct style.

Menu

Although we acknowledged the menu wasn't the most pretties menu, but we never really touched it for a long time. It wasn't until the meet where our Professor commented on how atrocious it was.
This may just be the 1st page, however one major comment was that there was just too much text, buttons, and a generic background. Comparing this to a nicer introduction menu, such as to Call of Duty:Black Op's menu, we can see the need for less buttons, and something better in the background.
With that in mind I introduce to you the new and improved menu, with a much more cleaner interface.

Gameplay 

The major complain was the game was too hard 

Though we set out to make the game hard as a design choice, we never really had proper external testing to show how hard it was. Once our professor played it, we saw how difficult the game was and how some necessary some game play features were.

To fix this, we implemented "player invincibility", which gave the player temporary invincibility for 1 second if they were hit. This would give allow the player to not die from a massive swarm of enemies in 1 hit, which was frustrating. Power ups were added to help the player deal with the increasing difficultly of waves of enemies. As you can see below, in the current build of our game, you turn blue, if you are invincible.



Feed back was needed 

Even playing the game, there was no way for the player to truly feel immersed in the game, because there were no ques that something had happened. For example if you shot an enemy, how do you know that we hit it. If a boss it coming how do you know that it is a boss,or if we used a power up such as cloak, how do give the feeling you are invisible.

 
To solve this, we had the enemy turn red when the player hit them like in other games.We fixed our audio ques to communicate with the player what is happening. We plan to add text to communicate messages if there is something important happening, such as a boss incoming, or bombing the enemy if hes beneath us. Finally we plan to add glow to the player if hes invisible, or to powerups to give them more of a friendly look.

Distince Style

This was a feature in our game which never really got touched on due to the lack of interest in a style.  While we just wanted art assets, and the game engine to be hard coded, we never thought how powerfull a style can make a gamer feel. Once we decided how our game would look, we would design our assets and shaders from there.

However none of us are artists, and as you can tell from the picture of our game above, we never conveyed a distinct style. What we need to do was to decide on one simple one and develop from there.

Style 1: Neon 


We could go with a simple based game which involves a pure neon style, fitted with glow shaders and deffered lighting

 Style 2: Cartoon

Or we can try to go for cartoony simple look, where every ship looks like it from a Saturday cartoon, and we shade it when toon shading.

In the end, we have to decide within 2 weeks from now, and commit to that style for the next 2 weeks. Hopefully we can proudly go to Level Up, with a game to truly represent our year.

Friday 1 March 2013

Color Filters + Resistance (PS3)

Welcome

to this week's blog. This week I'll be going over what we did for our color filter program using HSL a few weeks ago. Using this knowledge I'll apply it to a favorite of series of mine, the Resistance series, a Scifi FPS on the PS3. If you wish see that section skip to the end, or you can just read through the whole

 

USING HSL 

This week we had to use HSL/HSV (HUE-SATURATION- LIGHTNESS/VALUE) which was used with our shader program to simulate the RGB(Red Green Blue) color scale. 

Hue

Hue is the value representing what color we are currently using with a value. This value(hue) in the case of circle, would be which degree we are currently using.

Saturation 

Saturation is how "pure" a color is, the less saturated the color becomes, the more grey,or white ( depending on your model) it is. Saturation in this case could be how far we are on the radius of the circle from its center. The closer we are the center, the more grey the color is becoming, but the farther we are, the more apparent the color is. 

Lightness

Lightness, as we can predict, is based on how much light will be put into the color. Too little, and the color will be black, too much and it'll be white. This is shown to the graph to the right, with the amount of lightness affecting the y direction (up and down). The hue is affected, going from left to right.


Applying it to our program

Orginal scene
Prior to using the shader, we made sure that it our program used the file containing the conversion from RGB to HSL. Now we simply pass through our scene with our shader, and apply what ever color filter we want to it. Somes our color filter may use a simple formula to change the colors around. However sometimes we may want to use an external image to change the hue map, so we can modify it more artistically. Here we apply this chrome map, on the bottom left 


Applying this knowledge to The Resistance series (PS3)

The resistance series, on the PS3, has been personal favorite of mine, for many reasons. One reason could be because I was fond of the developer: Insomniac Games, from it Ratchet and Clank series. Not just from the unique wacky weapons I find, but the mysterious atmosphere of this alternate 1950's which the game creates. To help with this alternate 1950's feeling the color filters of the game have been tweaked to help achieve this tone/atmosphere. 

Resistance: Fall of Man



Resistance: Fall of man was released in Nov 11, 2006 along with the PS3 when it launched. It takes place in an alternate 1951, where World war 2 never happened, and instead humanity is facing the threat of an alien invasion. However despite the fact the game takes place in an alternate universe, looking at the cover, the game is trying to go for a dark  and old world war 2 film feeling.

We can tell this from the from the blurry black and white pictures, which we see throughout the game, and the color pallet of the game.  This color palet was the similar for many films in the 1930's-1950's, but it would just be generally black and white. As you can see in the game screen shot below, and above, the game is generally presented in a colorless world, filled with some hints of Red, and Yellow. With the color filter, they must have generally put a dark sepia filter over everything,  giving everything darker a shade of grey. Also the fact that game artists/modellers didn't give objects colors other than brown, black, white, and yellow.
 Playing through the game, the dark sepia filter, with the "old school pictures" and narrator voice over gives the game an outdated, historic documentary. However the dark sepia filter, combined with the fact humanity is outgunned in this bleak alternate universe, also gives the game a grim feeling.

Resistance 2

  

 Release 2 year later, on November 4, 2008, and taking place 2 years later (in 1953) Resistance 2 took the series to a bold new direction. The game was grander and larger in scope, with larger background vistas, and large boss encounters.
However with this new direction, the color scheme and filters also changed, as the game decided to be more "modern". Below was an ad for Resistance 2, and one which should've had the similar color feel/color palet for the game.
Unfortunately, as you can see with the screen shots, the team couldn't achieve the level of authenticity which the game. There were no "old school artifacts" on the screen, nor did the game come with a hint of sepia. The color pallet was much brighter, despite the more darker threat America faced, but it was also more clearer without the sepia interfering. This gave the game a more "modern military shooter" felling, leaving its roots which it had firmly created in Resistance:Fall of man.

Though this aliened much of the fan base, I personally was most impressed with the game. The reason being the scale which the game managed to achieve, all in a time of about a year and a few months to develop the game. Had Resistance 2 been given more time in development, it could have been so much more of a game.

Resistance 3

Released about 3 years later, Resistance 3 came out on Sept 6, 2011, and Insomniac games decided to take some fan criticisms to heart. Resistance 3 decided to take the series back to the authenticity that Resistance:Fall of Man was trying to reproduce.

One thing you can notice immediately is our good old sepia filter is back and being used. Though not as heavy as in RFOM, we can still see sepia with a much diverse color pallet. This brings the grim look back to into the game, as the game is about humanities struggle to survive.

Throughout the whole series I've had a great time playing each game not because of similar they felt, but how different each were. The effects through out each game was noticablitly different from each other, giving each their own atmosphere, and a different experience. Though the series maybe over now I look forward to seeing what Insomniac games makes the in future.