As gamers get more complex, new technology is used to accomplish certain tasks. Take this example.

You’re working on your game, creating multiple sprite sheets for your characters. You have a deadline to meet and although you could have a unique enemy for every encounter in your game, you decide against it due to time restrictions. However, you still want more enemies, so you need to palette swaps(color adjustments for a particular character). You consider the notion but realize you to do it all by hand for your complex enemy sprite sheets. This is where shaders come in.

 

Shaders: Coloring Of The Future

Shaders are used to post-process textures, pixels, and so on. They can range from simple to complex and are often written in a specific “shader” language. But, fear not friends, the concept is straight forward.

The concept functions in a way such that given a pixel’s data or a region on a texture, if it meets the criteria for processing, the element will be processed in some way. So, going back to our predicament, if you have a character that is mostly blue on your sprite sheet, we can look for all the pixels with a blue color and change them to another color such as red. Let’s get detailed.

We would look for the RGB(Red, Green, Blue) value of the pixels within the image data of the sprite sheet; when we find pixels that are primarily blue (0, 0, 255), we would change them to red (255, 0, 0) instead. It’s a pipeline process.

That’s a simple version and would be extremely useful for a palette swap dilemma am I right? This allows you to save time with shaders. This is all well and good, but the most important thing is to understand the shader’s processing pipeline so we can eventually make our own.

 

Processing Pipeline Input Output

Shaders flow in a very declarative fashion; you create the conditions and transformations of the raw color data. This becomes the pipeline, allowing you to use this pipeline on any textures or assets that suit the pattern/input criteria the shader is trying to solve.

There are more problems shaders can solve related to lightning and more; this is just the tip of the iceberg.

Stay tuned for more coming soon!

%d bloggers like this: