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 mipmapping


First, let's understand what texture filtering and mipmapping are. Take a close look at the following images. The image on the left shows the image of a monkey model with aliasing effects (look at the eyes of the monkey). On the right, we have an image of the same model with no such effects. When the object moves closer to the camera or moves further away from it, the texture associated with that object appears blocky or pixelated. Let's first understand why this happens. In our shader, we pass the image coordinates of the image. Now the shader interpolates texel values (texture pixels) and decides which pixel of the image to pick to be shaded on the screen. When the object is close to the viewer, each texel might become larger than the screen pixel. When the object is very far from the viewer, the screen pixel might become larger than the texel. Now, when it comes to selecting the texel, the rendering engine needs to decide which algorithm to follow to select the...