WHAT’S A SHADER?
A shader is a small program that is run within the GPU’s pipeline and manipulates either individual pixels or the geometry in the world in some way. The term comes from shaders’ first implementations, which were for shading algorithms, such as the Phong shader to produce smooth images.
There are effectively two distinctive types of shaders: pixel (or “fragment” in OpenGL/ Vulkan parlance) shaders and vertex shaders. Pixel shaders work at the end of the pipeline, and their output is an individual pixel’s RGB and Alpha value.
What we’re calling vertex shaders work on manipulating point vertices of models (three vertices make a triangle) for lighting and warping. Other shaders—geometry, tessellation (fixed function), hull, domain—are all about manipulating geometry within the world. Importantly, shaders are able to process basic input and output back to shared memory, called Stream Output. In the context of graphics, Stream Output enables the GPU to create and animate particle systems without CPU intervention.
With a GPGPU, shaders become the programmable processors of the GPU. Texture units are the read-only memory interface, and the output frame buffer is the write-only memory interface. The basic operations of a shader and the limited input mean that GPGPU excels when there is a large dataset that requires repetitive processing with minimal dependency between data elements.