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...