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

Texturing basics


There are mainly three types of textures: 2D textures (most common), Cubemap textures, and 3D textures. 3D textures are rarely used in gaming applications and are mostly used in volumetric effects such as light rays and realistic fog. We will not discuss 3D textures in this book as they are mostly procedural. To explain better, there is some software that can help you create or modify textures. Some of this software, such as PixPlant (http://www.pixplant.com/), is young and still evolving.

Understanding 2D textures and texture mapping

A 2D texture is a two-dimensional array of image data, a regular JPG or PNG image. The individual data elements of a texture are called texels. In 3D graphics, we use the term texels instead of image pixels. Texels are represented in different formats such as gl.RGB, gl.RGBA, gl.LUMINANCE, or gl.ALPHA along with their data types. Rendering with 2D textures requires a texture coordinate, which is an index into the image. Texture coordinates for...