Book Image

WebGL HOTSHOT

By : Mitch Williams
Book Image

WebGL HOTSHOT

By: Mitch Williams

Overview of this book

Table of Contents (17 chapters)
WebGL HOTSHOT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating surfaces – depth, non-smooth, natural, and realistic with normal maps


Few things in life are smooth and reflect light predictably, such as plastic—a modern invention—and a glass-smooth lake. We know how to render such smooth meshes based on the angle between the light source at that pixel and the normal using the dot product. The dot product is calculated by multiplying the two normalized vectors (each having a length of 1 unit), Nx * Lx + Ny * Ly + Nz * Lz, where N is the vertex normal (Nx, Ny, Nz) and L is the light direction (Lx, Ly, Lz).

However, most objects in nature have a bumpy, irregular surface, for example, oranges, tree bark, or a choppy lake. Man-made objects also have rough surfaces, for example, fabric or brick walls. Early in computer graphics, when computation was at such a premium, we simplified the calculations as very few video games had shading. The first computer-generated movies, such as Toy Story, had a number of surfaces that were smooth plastic, such as...