Shaders : A short story

Meet Shaders, Rockstars of Graphics Programming.

Preface

Picture this :

This is what I think cool parties must be like.

You are a at a party. A cool one. With fancy cocktails and glittery dresses. You are surrounded by awesome people, nearly as cool as you. The party is at full swing. There’s a LAN battle taking place in that corner, they have this scrumptious nacho with cheese dips and you are having an intellectual discussion with your new friends. All is well.

“Well, I make games”, you answer, when asked about what do you do as a profession or a hobby. There are ooohs and aaahs circling all over your small group, as you feel a wave of contentment hit over you. “Dude, that’s so cool.” “Wow, it must be awesome!”, people are saying all over. Well, making games sure does beat making a payroll software or answering phones all day long, you think to yourself and smugly smile.

Just then, somebody asks “Hey, you must know about Shaders, right? I was kinda wondering about them the other day. Care to explain it to me,buddy?”

You freeze. You start to sweat. Profusely. Shaders? Man, that was one topic you hadn’t bothered to care about. They had sounded complex, weird and confusing. And you obviously had no need to learn about it too.

“Um..Ah..They make things in the game look good…and um..”, as you manage to mumble these half-baked answers, you kinda wonder how much different would your life had been, if only you’d had studied a bit about those shaders. Where would you be now? Probably this same place, but with much more knowledge and intellect. What would you have been saying now, instead of some lines that sounded like complete bull manure. Damn, you really wish that you had done some shaders before, right? Right?

So, What are Shaders? And why should you learn them?

Simply put, Shaders are computer programs that run on the GPU to color each pixel on your video-game. That’s it. They are not some ancient mysterious code that hold the power to unlock the secrets of the universe or some other crazy stuff.

Here’s a Minecraft shader, making them pixels looks beautiful!

And other than avoiding that embarrassing aforementioned party situation, here’s why you should learn about shaders:

You will learn more about the Graphics pipeline, how the pixels are displayed on the screen. This is really handy to know if you are passionate and curious about game development and graphics programming. A lot of game developers don’t know about shaders. Knowing about shaders will give you an extra edge over them, whether it comes to making your next Flappy Bird look awesome or getting hired in a studio. It’s fun writing shaders! You will hold total command over what every element in your game would look like.

So, What will I be teaching? And what’s different about this tutorial series?

First of all, welcome to this Shaders’ series. This series will consist of various topics that I recently learned by myself about shaders. I used to be all scared of shaders and avoiding it whenever it came to writing them or knowing more about it.

But, as I have learned, Shaders are not that complex, if you are willing to put in a little bit of effort by yourselves and understand about it. Sure, there’s maths involved and we will have to dive into a bit of physics too. But that is exactly what makes it so fun.

Learning about topics like Light, Reflection, Vector maths were excruciatingly boring for me in High School and College. But, as I discovered their application in coloring the pixels of a game, it felt fascinating. Applying a little of what I’d learnt made me feel like this:

Also, writing and using shaders is fun. It becomes quite an artistic experience in itself using them too.

And, I have planned to write about the following:

Basic Shader Concepts : Lighting, Illumination, Coloring, etc. The Vector Maths involved in Shaders Lighting Models Buffers Surface, Vertex and Fragment Shaders Writing your own Shaders Some cool effects: Cel Shading, Rim Lighting, Holograms and a few more.

These are something I know from a beginner’s perspective and can’t wait to share it with you all. As a beginner myself, I know it’s not that easy to get introduced to shaders. Most of the high-quality tutorials and videos online already require you to have some basics and background on Maths, physics and programming.

The day is coming, my friend. The day is coming.

But, my series will take a different approach. It will be like a “For Dummies” type of style. And as I was a dummy myself to these topics a short while before, I feel that I can do a fantastic job of educating my fellow dummies.

So, in summation, the different things about this series are:

Everything is dummified. Simple words, Gentle concepts, I do them all. Quizzes : To test what you’ve (hopefully) learned! The maths concepts will not require you to have a Doctorate in Mathematics to understand them. And It's free.

This is what I expect you to know

Well, I possibly can’t explain everything that’s involved in making Shaders. I will explain all the core concepts, but you will need to know:

Basic programming : You should be familiar with For loops, If and Else, Conditional Operators, data types and variables. No language preference is needed, but it helps if you have some knowledge about C# in context of the Unity API. Unity Game Engine: You’ll be good to go, if you know what are GameObjects, how to write and attach scripts and use the Inspector.

And this is whom I expect you to be

This series is solely targeted to beginners and dummies. If you are one of these, you would be my ideal audience:

You know a bit of programming, and are looking to get started on writing your own shaders. You don’t know what Shaders are, and have never written them before. You have picked up a bit about shaders here and there, but have yet to get started on writing your own.

In other words, you would not be a good fit, if you are:

You have already taken some other courses about shaders and can write some basic shaders on your own. You make a living out of writing shaders for a large Game Development company. (In that case, please teach me?) You are Alan Zucconi.

And there you have it. If you find yourself as one of the people from the list above this one, then you can safely proceed. And if you’re not, stop right on your tracks. You know too much already!

Let's get this started!

Okay, now that we are done with the introductions and the formalities, let’s start learning! Let us dive right into the realm of Shader programming so that you will have a deep knowledge about how a pixel is displayed onto your screen and with that, you will also learn how graphics can be manipulated, special looks are achieved in video games and lastly, you will never ever be embarrassed at a party when when you are asked about Shaders.

Head on over to Part 1 : Meet the Shaders and get Shady!

Image Credits : Party, Minecraft Shaders, Hello World