Texturing is a common technique that significantly improves the quality of rendered images. It allows us to load an image and wrap it around the object like a wallpaper. It increases the memory usage, but saves the performance which would be wasted on processing much more complex geometry.
Writing texturing vertex and fragment shaders
How to do it...
- Create a vertex shader in a text file called shader.vert (refer to the Writing vertex shaders recipe).
- Apart from the vertex position, define an additional input variable (attribute) in the vertex shader through which texture coordinates are provided from the application:
layout( location = 1 ) in vec2 app_tex_coordinates;
- In the vertex shader, define an output (varying) variable through which texture coordinates...