Friday, 12 April 2013

Normal Mapping

Normal mapping, in the world of computer graphics, is a technique used to fake the lighting of bump or dents. It is an extremely common practice as it distorts the appearance and details of a low poly (polygons) model or object by generating a normal map from a high poly model. Normal maps are generally stored as regular RGB (Red, Green and Blue) images where the X,Y,Z coordinates correspond with the RGB coordinates of the surface normal.
Normal mapping use to only be possible on a parallel rendering machine called PixelFlow, which was built at the University of North Carolina at Chapel Hill. Later it became possible to perform normal mapping using multi-pass rendering and framebuffer operations, however with technological advances and the use of the plethora (which is basically like saying many but I really enjoy the word plethora so i try and use it whenever i can, its just such a fun word to say) of shaders in PCs and Gaming consoles, normal Mapping is now widely used in commercial games.

It`s popularity for real-time rendering is a result of its good quality processing requirements ratio compared to other methods that produce the same or similar results and effects. For those interested check out this link for a great tutorial on Normal Mapping:
 Click on the image below for tutorial

Global Illumination

 Pretty image right well this is just what Global Illumination looks like in the CryEngine 3 which is rendered in real-time.

WHAT IS GLOBAL ILLUMINATION

Global Illumination, in computer graphics, is the general name givens to a group of algorithms that are designed to add realistic lighting to 3d scenes. These algorithms not only take into consideration the light coming directly from the light source but also other cases in which light rays from the source are being reflected off other surfaces. You can see an example of this happening below:
 
 Global Illumination is often used to bring realistic lighting and photorealism into video games since images rendered using the global illumination algorithms are often more realistic than images rendered with direct illumination. There are a few types of algorithms used in global illumination some of with are listed below:
  • Ambient Occlusion
  • Radiosity
  • Ray Tracing
  • Photon Mapping
  • Among others
Some of these algorithms are not the fastest at yielding the results you want but the are the most accurate.
  While Global Illumination is a great technique to make a game more realistic and shiny looking, there are a few draw backs with using it. Unfortunately with Global Illumination images are significantly more expensive and considerably much slower to render which makes them not a good mix for games (especially ray-tracing) despite how nice it can make them look.
 For anyone interest below you will find a tutorial on Global Illumination in Maya for any of you who would like to try it out:

Depth of Field

Cool images right well these are just a few examples of a little something called Depth of Field in action. Now Depth of field is the amount of distance between the nearest and farthest objects that appear in a scene. It is important to remember that depth of field doesn't change suddenly from sharp to unsharp, but instead changes gradually. You can see exactly how Depth of Field works in the image below:
Now in the image below you will find what is called the circle of confusion which is a used to define how much a point needs to be blurred in order to be perceived as unsharp. When this circle becomes perceptible to our eyes, this is considered to be outside the depth of field and thus unsharp. Now an acceptably sharp circle of confusion is that which goes unnoticed when enlarged to about 8in by 10 in and perceived from about 1 foot away.
Depth of Field is an important technique used in games to make the unimportant aspects of the game world less noticeable while drawing attention to the main focus of the scene. This is used often in the Uncharted Series as you can see from the below images:
To learn more about Depth of Field check out these links below:






What I Learned In Intermediate Graphics

There are so many things to learn about Computer Graphics that it just cannot be contained in one class (I guess that's why we had two classes about it this year huh?). Intermediate Computer Graphics covered a lot of useful techniques and methods that can really make a game pop, from Shadow Mapping to Motion Blur. The homework questions (which our class affectionately calls Hogue work) is a good application of what we learned in class (but seriously sir when you read this please note that some of those questions are just ridiculously hard) and helped with the creation of our game, since a lot of things we did in the questions were things we needed in the game. 

Personally for me I learned how to implement a lot of the shading methods like Toon Shading and Ambient Occlusion into code (I previously only knew how to do those effects by drawing them into the actual textures). In addition, I learned how Motion Blur works (outside of photography), why it is included in games and how to implement into my code (and in all seriousness just like Dr. Hogue says, it really is just three lines of code). Another thing I learned about, that I thought was super cool, was displacement mapping. It is basically using a texture to cause the geometric position of points to be displaced, changing how the model looks like with out actually changing the model (which I found really cool and super useful to know when making games). There was a lot of other topics touched upon in our class and it would take forever to go through them all, but this class was really interesting and I enjoyed learning about the techniques and tricks of Computer Graphics (if only the coding part was simpler but what can you do other than sit there and learn it right?) 

While I'm glad I learned a lot of cool things you can do to make your game look pretty (which is always a plus for me when games are pretty), Dr. Hogue I hate your class so much (in the best way) because you ruined video games for me!! I can no longer play a video game without commenting on the use of shaders and techniques used in its graphics! Cause I mean come on look at these shaders!!!

Ambient Occlusion

Ambient Occlusion, in the world of computer graphics attempts to approximate the way light radiates in real life, it especially focuses on non-reflective surfaces. Unlike Phong Shading, Ambient Occlusion is a global method, which means there is illumination at each point. This illumination is a function of other geometry in the scene, however it is a very crude approximation. Ambient Occlusion creates a soft appearance that is similar to the way an object appears on a cloudy day. This method is most often used in games to add realism in the way light works and the environment. it is usually calculated by casting rays in every direction from the surface, these rays reach the background or 'sky' and increase the brightness of the surface. The rays that don't reach the background and hit any other object contributes nothing. This renders all objects surrounded by a larger objects dark.
 Ambient Occlusion can be created a few different ways, one is to hard code it into your code by utilizing the following equation to calculate it:
However you can also create Ambient Occlusion through the use of Maya. You would create your Ambient Occlusion in Maya using an object or model and then combined the resulting ambient  texture with your model's original texture in Photoshop to create a new texture. Then in your game program you can simply load your new texture and your object, and bam, you have Ambient Occlusion in your game. Now this isn't the best way to include Ambient Occlusion in your game since it cannot adapt when you move throughout the game world. 

For anyone interested in learning how to do Ambient Occlusion in Maya you can check out the video below:

AMBIENT OCCLUSION TUTORIAL


Check out these links for more info on Ambient Occlusion:

Shadow Mapping

Shadow Mapping, otherwise known as projective shadowing, is a process of 3D computer graphic by which shadows are added into the scene. Shadows are created by testing whether a pixel is visible from the light source, you do this by comparing the z-buffer or depth image of the source's view, and it is then stored in a texture.

 Basically Shadow Mapping works by that it checks if a point is visible from the light or not. If a point is visible from the light then it's obviously not a shadow. The shadow mapping algorithm can describe as such:
  • Render the scene from the lights view point and then store the shadows (more specifically its depths)
  • Then render the scene from the camera and compare shadows (again more specifically the depths), whatever depth is greater is the shadow
  
The hard part of Shadow Mapping is the actual implementation since it is hard to select the appropriate bias and hard to get rid if artifacts at shadows edges. The basic principle of Shadow Mapping is that when you look out from a light source, all the objects you can see in a scene would appear in light, however anything behind those objects would be in shadow.
 Shadowing Mapping is a helpful technique used in video games, because it helps create realistic shadows, which act the way shadows do in real life. Nothing is worse than having shadows that are not displaying in the correct way, it breaks the illusion and makes the scene look fake. When shadows are implemented incorrectly in games it completely ruins the game's aesthetic appeal.

Bloom

Cool lighting effect in this image right?  Ever wonder how the game developers get such amazing effects into their games? Well they use a little thing called Bloom (which I mentioned in my Image Processing Techniques blog located HERE), which is a type of computer graphics effect that creates something similar to a glow in a scene or image. The basic idea is that bloom creates feathers of light extending from the edges of bright areas in an image. This then contributes to the illusion that the is a extremely bright light overpowering the camera or eye that is capturing the scene. The below images demonstrates bloom in the game world:
 The Bloom effect is used in games to create a sense of realism in the world of gaming as well as obscuring fine details that could be distracting in particular instances.  This effect is used to enhance the look of a scene or image which you can see in the image below:

 BASIC THEORY OF BLOOM

The basic idea that Bloom is based off of is that, in the real world, no lens can ever focus perfectly (I mean until they finally make one but that's besides the point). Even perfect lenses will pick up imperfections, which normally are not noticeable however these imperfections become visible when there is an extremely bright light source. This results in the image of light bleeding into actual scene or image beyond its boarders. This effect can be simulated in HDR images by applying a Glaussian blur, before converting it to fixed range pixels and by drawing it into the actual object texture.

Bloom Effects




 Bloom is an interesting effect that can create a more realistic setting for games as well all prevent objects and environments from looking fake and bland. Bloom gives an interesting aspect to games and (like in the Zelda games)helps keep the player focus on the important task at hand rather than beings distracted while gaining,



Cel Shading

 Now I bet you are all wondering what on earth Legend of Zelda and Cel Shading have anything to do with each. Well the interesting thing is that they have everything to do with each other, since Legend of Zelda employs the technique of Cel Shading in many of the game's sequels and variations.

WHAT IS CEL SHADING?

Cel shading (otherwise known as toon shading and often misspelled) is a type of shader in computer graphics that produces a type of non-realistic rendering that causes the appearances of computer graphics to be hand-drawn.  This technique mimics the iconic comic book and cartoon art style and can create a unique look of a game.

 THE CEL SHADING PROCESS

Cel shading begins its process with a 3D model like other rendering processes however it differs with its use of of non-photo realistic lighting. In Cel Shading conventional lighting values are calculated pixel by pixel and then mapped to a small number a shades to create the flat cartoon like appearance. With cel or toon shading there is no mixing or blending of shadows and colors but instead the shadows and highlights are places and stacked side by side. In toon shading, the use of edge detection is applied in order to render black outlines and contour lines which is a uniquely defining feature of toon shading. The image below is an example of toon shading with the black contour lines:
 By utilizing the edge detection with toon shading , games can easily create a very stylized art style that appeal to many players. It is important to note that cel-shading, as a term, is usually referred to the application of these outlines in gaming and animation, however this was not always the case. This techniques, while fairly recent (only coming into use at the start of this century) is most commonly found in video games.
 For those interesting in learning how to create toon shading you can check out the video below:

 TOON SHADING IN MAYA
 Cel Shading has been used in numerous video games from its start in Jet Set Radio for Sega's Dreamcast in 2000 to games such as No More Heroes, Pokemon X and Y and The Legend of Zelda: The Wind Waker. For anyone interested a full list of games using the cel shading technique can be found here.

In addition, you can find more info on cel shading on the following sites:
 

Thursday, 11 April 2013

Motion Blur

Cool looking image isn't it? Anyone out there interested on what can create something with this effect? Well I'm about to explain. Now Motion Blur is the effect responsible for the above image. I bet you are either wondering what Motion Blur is or thinking that you already know it, well in the blog I'm going to focus on Motion Blur in games and its significance.
Motion Blur is described as the streaking of rapidly moving objects in a image or a movie/animation, which is the result of a change in an image recording, either due to rapid movement or long exposure. Motion Blur has numerous applications in terms of aesthetics, from photography to animation to video games. Motion Blur is a type of artistic filter in computer graphics that converts images in order to stimulate the effect.Normally Motion Blur is not desirable in games however it can be used in certain instances it can be used to draw attention to specific areas of a scene.
 
In the above image its easy to see how motion blur is used to draw attention away from certain object while drawing attention to things like the gun. This is useful when there explosions in a scene since there are a number things happening in the scene because it helps to differentiate between everything going on, so that the player isn't confused or disoriented. Now this effect is used as an attempt to bring realism into the game just as lighting and shadows are.
Now my Professor often describes things as 'It's Just Three Lines of Code' and in this case he is completely accurate. To impliment motion blur in code you need these three lines of code placed right before your draw function in your main function:
//MOTION BLUR
glAccum(GL_MULT,q);
glAccum(GL_ACCUME,1-q);
glAccum9GL_RETURN,1.0); 
The above code produces something close to the following:
Normal                                                                                 Motion Blur
The effects that motion blur can bring to games can add a unique element and realism to the game world.
For anyone who is interested in learning more about motion blur you can check out these links below:


Lighting

Yes People the title of this blog is called Lighting, and before you say anything along the lines of  'Oh I know all about lighting why are you talking about it', I'm going to be talking about specifically lighting in games and its importance (mmmh maybe I should change the title of this blog huh?). Now quickly for anyone who doesn't know what lighting is (not just in the sense of video games) here is a quick overview.
 
Lighting, otherwise known as the process of Illumination, is the deliberate use of light to achieve a certain effect, whether it is practical or aesthetic. There are two types of light sources; Artificial, meaning light that is produced by products such as lamps and light fixture and Natural, meaning light produced by the sun captured through the use of windows, light shelves and skylights.
 
Now lighting has more than just a practical use and that is what the entertainment and gaming industry take advantage of to make their products more aesthetically pleasing, create moods and emotions as well as make things look real or believable. 
 Lighting in games is an extremely important aspect of game design and can make or break your game in a number of areas, such as visuals, atmosphere and theme. It is one of the most influential elements in environments and it is unfortunately forgotten about or underestimated. In the past it use to be that lighting wasn't as easy to add into the game because of weak hardware and game engines, however with the advances in technology there is no longer any excuses. Lighting has purposes past just allowing players to see where they are going, it creates atmosphere and can make a scene look dark and mysterious or bright and happy, this can really help the overall look and feel of a game.
 You can really notice the difference lightning has on a scene, as seen in the image above, and the importance of having a light source (which is actually one of the most basic rules of lighting). Now just having a light source isn't going to guarantee that the lighting will be fine in the game, it is also important to have a light source visible in the scene otherwise it is impossible to tell where the light is coming from. This can break the illusion and render a scene fake looking and unrealistic. In the image above image you can see the light source (the sun) which makes the image more realistic than it would if you couldn't see the light source.

It is also important to have your light source in proportion to the other aspects of the scene, as a tiny single light bulb would never be able to light up a whole room no matter how bright it is. In addition to keeping things proportionate you also have to make sure that your source's brightness is right for your scene. You can't have a really bright room with a dull light source that just looks awkward and doesn't make sense. In the above images you can really notice how keeping your light source proportionate and at the right brightness can improve the overall look of the scene.
The above images are gorgeous aren't they?  That is because not only is the lighting in them done well, but also because of the colors in the image themselves as well. Color is an important aspect in lighting, and as a rule it is a must and absolute requirement in almost every situation to have coloured lighting. Almost all of the world's light sources cast light that has color, so it is not realistic to have white lighting in the games environment, since if color isn't added the result is very bland and fake looking. Below you can see how color and coloured lighting play a huge part in the way a game looks and feels, each different color palette gives you a different feel and sense, which is extremely important in how a game relays information to players:
 Along with color it is important to ensure that the aspect of light temperature is addressed when adding lighting to your games. A common theory of light states that light is simply energy which is warmer and more energy it has the stronger the light gets. By paying attention to the temperature of the colored lights it is easier to add contrast and dynamic to your scene or game. By doing this the look of the game can completely change as seen in the image below: 

Now keep in mind that everything I mentioned above isn't the only things that make up lighting and define its importance, in fact texturing is another aspect that can make or break the game because textures are the base for lighting. It is important to note that when textures are either too dark or too light that can throw off your lighting since dark textures can't be lit very well while bright textures when lit look too bright. This goes for the colors in the textures as well, since they can influence the way the lighting behaves. The below images are perfect examples of what can happen:
These are just some of the aspects that make up lighting in many of the games we play and their importance to how the game looks and feels. Now my challenge to you is the next time you play your games, take a moment to look at the scene before you and try and see how they approached the lighting in the game and post your findings in the comments below.

Now if any of you want to learn more about lighting in games here are a few links you can check out: