Book Image

Lua Game Development Cookbook

By : Mario Kasuba, Mário Kašuba
Book Image

Lua Game Development Cookbook

By: Mario Kasuba, Mário Kašuba

Overview of this book

Table of Contents (16 chapters)
Lua Game Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Applying highlights and shadows to the scene


This recipe will deal with per-pixel lighting and simple shadowing. It will allow you to apply one or more lights in the 3D scene. There are two types of light sources: directional and positional light. Directional light doesn't have a position and it's used mostly for daylight. Positional light has a source at a certain position. This type of light can be divided to omnidirectional and spotlight. Omnidirectional light is used mostly with light bulbs. Spotlight is often used with reflectors. Light intensity decreases with increasing distance from the light source.

This recipe will use simple shadowing. This means that surfaces that aren't directly facing the light source will be in the shadow. However, this doesn't include real shadow casting as this is a more advanced topic that's beyond the scope of this book.

Getting ready

Before staring, you'll need to set up the camera position, object state in a scene, light sources, and materials. The camera...