GSL Shaders
Shaders are often used in video games or multimedia work to add a layer of texture onto a given object. Even though I draw and know what shading is when it comes to paper and pen, I’ve never used “shading” in the context of programming.
My instructor for Math for Artists, Robby Kraft, explained that shaders are essentially a set of instructions, but the instructions are executed all at once for every single pixel on the screen. This means that the code you write has to behave differently depending on the position of the pixel on the screen.
So, at it’s most fundamental form, a shader is a transition of colors on a screen.
In the following code, I normalize the coordinate of the fragment by dividing it by the total resolution of the billboard. By doing this the values will go between 0.0
and 1.0
, which makes it easy to map the X and Y values to the red and green channel.
As a source of inspiration, I tried to create a gradient that resembles a William Turner sunset and Josef Alber’s work.