Chapter 5. Lighting and Special Effects

We've come a long way in just a short time; in fact, we have the basics of our game laid out. It doesn't take a genius to see that even though our game is playable, and may even be a bit fun, it's pretty flat. The ship is just a ship and the asteroids and rocks are just asteroids and rocks—there is nothing that really catches our attention. It's similar to the feeling you get when you watch a movie being made and you realize that you are only catching half of the final product—that is, the lighting, sound, compositing, and so on, will be added later. This chapter is where we add the missing pieces. With the exception of some UI elements, the game will be nearly finished at the end of the chapter and we will be able to see what a big impact a few changes can make.

In this chapter, we'll talk about the following topics:

  • The different kinds of lighting and how each type is used in a scene
  • How lighting can be pre-computed into lightmaps to increase performance
  • How special effects such as particle effects and polytrails add depth to a game
  • Adjusting the ambient settings of our game to pull it all together

Lighting

Lighting is a key part to almost everything in our game. When we don't take the lighting into consideration, we end up with scenes that are flat or unrealistic. ShiVa makes things pretty simple depending on the type of game that you are doing. For many games, the lighting is pre-rendered into the scene to increase the quality and performance of the lighting. Static lights enable us to pre-compute the shadows into the object textures. For added realism, dynamic lights can be added to provide moving shadows. The only drawback to this method is that some platforms are incapable of rendering dynamic shadows.

The two types of lights are directional and point lights, both of which can be either static or dynamic. The difference between directional and point lights is that directional lights light the entire scene without any falloff or attenuation—the light is even and applied at the same angle for the entire scene. Compared to directional lights, point lights have a lot of options and can provide better lighting, which looks far more natural and allows for better control. We will be focusing on directional lights.

Dynamic lighting

This is the simplest light to use; and when they work, they provide nice, realistic results because moving objects can cast shadows. ShiVa provides a default dynamic light set in the Models folder, which makes it easy to drag-and-drop lighting to our scene. So far, the default lighting is all that we are using—let's take a look at the attributes for the lights, as shown in the following screenshot:

Dynamic lighting

In order to see the light attributes, we have to go to Scene Explorer | Selection | Single and then select one of the lights in the group. Here, we see that we can set the color of the light and also set the Active option to activate the lightning. The Use for real time lighting option is what makes it a dynamic light. We can also turn off the shadows if we want. Moving down the tab, we also see that we can control specific types of objects that are affected by the light, such as all objects, parent objects, group objects, and terrain.

Static lighting

Again, these lights are for generating shadows for objects that are "static", meaning they don't move. We will take a look at them in more detail in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.131.47