Book Image

OpenGL ES 3.0 Cookbook

By : Parminder Singh
Book Image

OpenGL ES 3.0 Cookbook

By: Parminder Singh

Overview of this book

<p>"Write once, use anywhere" is truly the power behind OpenGL ES and has made it an embedded industry standard. The library provides cutting-edge, easy-to-use features to build a wide range of applications in the gaming, simulation, augmented-reality, image-processing, and geospatial domains.</p> <p>The book starts by providing you with all the necessary OpenGL ES 3.0 setup guidelines on iOS and Android platforms. You'll go on to master the fundamentals of modern 3D graphics, such as drawing APIs, transformations, buffer objects, the model-view-project analogy, and much more. The book goes on to deal with advanced topics and offers a wide range of recipes on the light shading, real-time rendering techniques with static and procedure textures to create stunning visualizations and runtime effects.</p>
Table of Contents (21 chapters)
OpenGL ES 3.0 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Generating the brick pattern


The brick shader generates a pattern the bricks on the given surface of the 3D mesh object; this is another very good example of procedural texturing. The brick pattern is made up of two components (a brick and the mortar); these are represented using two different colors, as shown in the following figure. These colors are defined using BrickColor and MortarColor as the global variables in the vertex shader.

The rectangular size of the brick consists of brick and mortal materials; the total dimension of the rectangular region is 0.40 x 0.10 square units, out of which 90 percent of the horizontal dimension (0.40) is reserved for the dimension of the bricks along the x axis; the remaining 10 percent is used for the mortar along the same axis. Similarly, the brick vertical dimension is 85 percent along the y axis and the remaining 15 percent is used by the mortar's vertical dimension:

How to do it...

Perform the following steps to implement the brick shader:

  1. Create...