Sampler Objects

Textures may be read by a shader by associating a sampler variable with a texture unit and using GLSL’s built-in functions to fetch texels from the texture’s image. The way in which the texels are fetched depends on a number of parameters that are contained in another object called a sampler object. Sampler objects are bound to sampler units much as texture objects are bound to texture units. For convenience, a texture object may be considered to contain a built-in sampler object of its own that will be used by default to read from it, if no sampler object is bound to the corresponding sampler unit.

To create a sampler object, as with most other object types in OpenGL, we reserve a name for the new object and bind it to a binding ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.