Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
GLSL Essentials

You're reading from   GLSL Essentials If you're involved in graphics programming, you need to know about shaders, and this is the book to do it. A hands-on guide to the OpenGL Shading Language, it walks you through the absolute basics to advanced techniques.

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781849698009
Length 116 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jacobo Rodriguez Jacobo Rodriguez
Author Profile Icon Jacobo Rodriguez
Jacobo Rodriguez
Arrow right icon
View More author details
Toc

Inputs and outputs


As the rest of the shaders, fragment shaders can receive uniform variables as input. They work exactly as for vertex shaders, so there isn't much to say at this point except if we talk about textures. Textures are represented by an opaque variable type: a sampler (an opaque type is a special type that can only be used with built-in functions and cannot be used in mathematical operations). To make a texture available, you have to declare its uniform variable, using the right sampler type. Depending on the class of the texture you should use one sampler or other. A brief list is:

  • sampler1D (for 1D textures)

  • sampler2D (for 2D textures)

  • sampler3D (for 3D textures)

  • samplerCube (for cubemaps)

  • sampler2DArray (for arrays of 2D textures)

  • sampler2DShadow (for 2D shadow maps)

Note

Samplers are special variable types that can only be used as uniforms. You can't declare a sampler inside a function.

In the host application, when you want to upload a sampler you just have to upload a uniform...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime