Book Image

WebGL Game Development

By : Sumeet Arora
Book Image

WebGL Game Development

By: Sumeet Arora

Overview of this book

<p>WebGL, the web implementation of Open GL, is a JavaScript API used to render interactive 3D graphics within any compatible web browser, without the need for plugins. It helps you create detailed, high-quality graphical 3D objects easily. WebGL elements can be mixed with other HTML elements and composites to create high-quality, interactive, creative, innovative graphical 3D objects.</p> <p>This book begins with collecting coins in Super Mario, killing soldiers in Contra, and then quickly evolves to working out strategies in World of Warcraft. You will be guided through creating animated characters, image processing, and adding effects as part of the web page canvas to the 2D/3D graphics. Pour life into your gaming characters and learn how to create special effects seen in the most powerful 3D games. Each chapter begins by showing you the underlying mathematics and its programmatic implementation, ending with the creation of a complete game scene to build a wonderful virtual world.</p>
Table of Contents (17 chapters)
WebGL Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding perspective transformations


Although we touched upon perspective transformations in Chapter 1, Getting Started with WebGL Game Development, and have been using our perspective matrix throughout our code, we would like to discuss it in depth here.

Nearly all 3D games use a perspective projection to render their scene. Like the real world, this simulates the application of a perspective to objects rendered within the game so that objects that are further away appear smaller than objects that are nearer.

In addition to this obvious size effect, more subtle effects of perspective are picked up intuitively by us, and we will add a substantial feeling of depth to the rendered scene. The sides of a cube would seem to narrow slightly as the distance from the viewer increases, thereby allowing us to automatically determine the exact position in which the cube is situated.

Understanding the viewing frustum

The viewing volume of a camera takes the shape of a frustum which is a rectangular...