Virtual Reality Development for the Google Daydream by Matthew Scarpino

Virtual Reality Development for the Google Daydream by Matthew Scarpino

Author:Matthew Scarpino [Scarpino, Matthew]
Language: eng
Format: azw3
Tags: Computer programming
Publisher: Quiller Technologies LLC
Published: 2017-03-28T04:00:00+00:00


10.1 Textures

Chapter 8 explained how fragment shaders assign colors to fragments and Chapter 9 explained how the Blinn-Phong Model computes colors mathematically. But in many applications, fragment shaders select colors from images. That is, the fragment shader reads (or samples) pixel data from an image and assigns the color to its fragment. The image data used in this process is stored in objects called textures.

Applying a texture to a surface is like putting up wallpaper. In both cases, blank surfaces are made more appealing by attaching decorative images. In both cases, the corners of the pattern must be carefully matched to the corners of the surface. It's also important to make sure that the pattern is oriented correctly.

But textures are easier to work with than wallpaper because there's no need to do any measuring. OpenGL will stretch or shrink the texture as needed. And if a texture needs to be reduced in size, you can tell OpenGL to use a miniaturized version of the texture called a mipmap.

The goal of this section is to explain how to apply textures in Android-GLES applications. The first part of the section presents the code needed to initialize a texture and pass it to the fragment shader. The second part explains how the fragment shader can read color data from the texture and use it to set a fragment's color. The section ends with example code that demonstrates how textures are used in practice.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.