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

Setting up materials


Lighting can add certain dynamics into your 3D scene or game, which can make it more immersive. Everything you see is a light that reflects from surfaces. Some part of the visible light is absorbed by the material on a surface. The rest of the visible light spectrum defines the material color. You can say that the surface material reacts with the light in a certain way. Therefore, OpenGL attributes light processing into parts—material and lighting.

OpenGL tries to approximate light distribution and reflection by five material attributes, which are as follows:

  • GL_DIFFUSE: This specifies the color of the surface and is mostly the attribute you will want to use

  • GL_AMBIENT: This affects all vertices equally and often simulates ambient light

  • GL_SPECULAR: This is the color of the highlight

  • GL_EMISSION: This is the emitted light color, which can be used for surfaces that emit light, such as lamps or LEDs

  • GL_SHININESS: This specifies the size of the highlighted area; smaller...