01 - What is a shader? (Shaderdev.com)
Chayan Vinayak Chayan Vinayak
8.8K subscribers
58,261 views
1.2K

 Published On Aug 28, 2016

Full course on: http://shaderdev.com

Transcript of the video:

Hello Everyone, I am Chayan Vinayak Goswami and this is where our journey of Shader Development begins. In this chapter, we will understand, what is a Shader and to define Shaders I will use simple terminology.

First, we will understand what is a Shader ?

When we ask a computer to perform any operation, we give an instruction to it and a set of instructions is called a Program. A program that is used or contributes to shade or draw something on the screen is called as Shader. Shader is a set of instructions that is run on GPU - Graphics Processing Unit

GPU is a processing unit or circuit specially designed for faster and efficient computer graphics operation or image manipulation

If we briefly take a look at the comparison of GPU and CPU.
This is a CPU with four cores in it and this is a GPU with thousands of cores in it.

These four cores of CPU are designed for simultaneous operations and whereas cores of GPU are designed for parallel or simultaneous operations. - that's how fast GPU is, in comparison of CPU.

Now, let's understand the types of shaders based on their functionality

1. Vertex Shader
2. Pixel Shader
3. Geometry Shader
4. Compute Shader
5. Tessellation Shader

In this series, we will emphasize on Vertex and Pixel Shader. Before we start understanding Vertex and Pixel Shader, let's understand why there is even a need of shader or why do we need shaders.

When we have to show or draw any object on the screen, it will be in the form of primitives or a mesh. eg: if it is a geometry of a specialized character in the game or if it is a texture. Even if we have to draw a texture, we will have to draw a mesh card and then we will draw a texture on top of it. Even, if we shade something we will draw a mesh first and then shade it. When it is an exciting object i.e. if we want to show an emitting object, we will have to draw the shape/mesh of object first.

That means it comes down to drawing a mesh, which is then divided into primitives.

What is a Primitive? :
These are the basic units of a mesh :
1. Triangle
2. Line
3. Point

If we have to draw a triangle on the screen, our first task is to draw the vertices. - what mesh is made up of ? its made up of vertices. In order to draw the vertices, we will use our first type of shader which is called as Vertex Shader. We will collect the information of the vertices and give it to vertex shader to draw them on the screen.

Our next problem is that how we will fill the area in between these vertices. In other words, how we will shade the pixels of the screen in the region of this geometry - we will use Pixel Shaders to perform that operation. Pixel shader is also known as fragment shader, it's a type of shader that works on a pixel or a fragment.

Fragment : term fragment is used to define an element that will eventually contribute to the final color of the pixel. A fragment is like a presidential candidate, a candidate can be a president, it can not be a president or it can contribute to a president. In the later chapters, we will see how a fragment contributes to a final color of the pixel.


Tessellation Shader : Now, we will get an overview of Tessellation Shader. Tessellation Shader is also known as Hull Shader. They are relatively new shaders as they are added in OpenGL 4 and Directx 3d 11. In a nutshell, tessellation shader is used to subdivide the mesh.

In 2016 WWDC which is Apple's Worldwide Developer's Conference. Apple introduced their new metal tessellation pipeline. Metal is the apple's graphics API. But in this pipeline, tessellation shaders are fixed function shaders that mean they are the shaders that are not programmable, they are embedded inside the hardware.

Fixed function Shader: now we know what is Fixed function shader. A shader that is not programmable and is embedded inside the hardware.

Geometry Shader : as the name suggests are used to manipulate the geometry. Geometry shader takes a primitive as input (as vertex shaders take a vertex as input). In the rendering pipeline, geometry shader comes in between the vertex shader and pixel shader.

Compute Shader : Compute Shader is a general purpose shader that is used outside of rendering pipeline that means they are not used to draw a primitive or shade pixel, then what they are used for - they are used for using GPU's parallel processing capability for general purpose tasks.

So that is what a shader and these are the types of shaders based on their functionality. That is it for this chapter and thank you so much for listening!

show more

Share/Embed