Course introduction

Tutorial

intermediate

+33XP

15 mins

(17)

Unity Technologies

Course introduction

In this tutorial, you'll learn the foundational concepts behind shaders and how Unity's Shader Graph tool works. You'll explore what shaders are, how they function, and become familiar with the Shader Graph interface. You'll also learn what to expect from this course and what prior knowledge may be helpful before getting started.

By the end of this tutorial, you'll understand the following:

  • What shaders are and how they control object appearance.
  • The difference between Fragment and Vertex shaders.
  • How shaders run on the GPU for efficient rendering.
  • The relationship between shaders, materials, and meshes.

1. Welcome to the course

Welcome to your Get Started with Shader Graph!

In this course, you'll learn the fundamentals of creating shaders using Unity's Shader Graph, a powerful visual tool that lets you create custom materials without writing code.

Shaders control how GameObjects appear in your application: their color, lighting response, texture, transparency, and special visual effects. By the end of this course, you'll have hands-on experience creating multiple shader types, understand common nodes, and start developing the abstract thinking needed to design your own shaders.

In this course, tutorials are organized into units, with each unit focused on a specific group of related shaders. You can complete the course from start to finish, progressing through each unit in order, or you can jump directly to individual tutorials if you want to learn how to create a specific shader.

Each tutorial is designed to be self-contained, so you can also return to them later as a reference when building similar shaders in your own projects. By the end of this course, you'll have created several practical shaders that you can expand upon and even showcase in the portfolio scene included with the course materials.

2. Before you begin

Before diving into Shader Graph, it's highly recommended that you complete the Creative Core: Shaders and Materials course. This course provides essential background knowledge about how Unity's rendering pipeline works, which will make this course much easier to follow.

If you haven't taken that course yet, here's a brief overview of the key relationship you need to understand:

  • Shader: Shaders contain the rendering information that tells Unity how to render a surface. They define the rules for color, lighting, texture mapping, and effects.
  • Material: Materials are an instance of a shader with specific settings. Think of materials as shaders with customized parameters, like choosing a specific color or texture for a certain shader.
  • Mesh: Meshes are the 3D geometry (the shape) of your GameObject. When you apply a material to a mesh, the shader’s instructions determine how that geometry appears on screen.

Understanding this pipeline is crucial because after you create a shader in Shader Graph, you'll then create materials from that shader and apply those materials to meshes in your scene.

3. What are shaders?

Shaders are specialized programs that control how GameObjects are rendered on screen. Every surface you see in a Unity project–whether it's a character, a wall, water, or the sky–is displayed using a shader.

From a technical perspective, shaders are programs that run on your computer's GPU (graphics processing unit) rather than the CPU (central processing unit). This is important because GPUs are specifically designed to handle graphics calculations very efficiently; they can process thousands or even millions of operations simultaneously. This parallel processing power is what makes real-time 3D graphics possible.

Shaders determine several key visual properties:

  • Color: The base color or tint of a surface.
  • Lighting: How the surface responds to lights in the scene.
  • Texture: How images (textures) are mapped onto the surface.
  • Transparency: Whether the surface is see-through and how it blends with GameObjects behind it.
  • Special effects: Visual effects like glow, distortion, animation, or stylized rendering.

Important: Remember that materials are instances of shaders. This is why you typically modify the above properties in the material. However, it’s important to understand that the properties and the logic that determines how they affect the surface are actually defined in the shader.

Without shaders, Unity wouldn't know how to display your 3D and 2D models. Even a solid white cube requires the use of a built-in shader to tell the GPU what color each pixel should be.

4. Fragment vs vertex shaders

Shaders are typically divided into two main types, each operating at a different stage of the rendering pipeline: Fragment shaders (also called pixel shaders) operate during the Fragment stage, and vertex shaders operate during the Vertex stage. You’ll learn more about these stages below.

Fragment shaders

Fragment shaders work at the pixel level. They run once for each pixel that will be drawn on screen, determining the final color and appearance of each pixel.

Fragment shaders can do the following:

  • Calculate the final color of each pixel
  • Apply textures and blend them together
  • Determine how lighting affects the surface color
  • Create effects like transparency, glow, or color grading

For example, if you wanted to create a glowing effect, you'd use a fragment shader to add bright colors to certain pixels based on texture data or calculations.


Vertex shaders

Vertex shaders operate on the geometry of a mesh. They run once for each vertex (corners of your 3D model).

Vertex shaders can do the following:

  • Change vertex positions (useful for deformation effects like waves or wind)
  • Modify the scale of the geometry
  • Transform vertex data when doing lighting calculations
  • Pass data to the Fragment stage

For example, if you wanted to create a flag waving in the wind, you'd use a vertex shader to move the vertices up and down over time.

Working together

In many cases, shaders use both stages in the same shader: the Vertex stage transforms the geometry, while the Fragment stage calculates the final pixel colors. When working in Shader Graph, you’ll see both the Vertex and Fragment stacks in your graph where you can connect your logic. These correspond to the two stages of the shader. Instead of writing code manually, you only need to focus on building the visual logic with nodes. Shader Graph then generates the appropriate shader code to connect both stages automatically.

Other types of shaders

Shaders continue to evolve, and today you can find many specialized types when exploring modern graphics techniques. In addition to the common vertex and fragment shaders, there are other types such as geometry shaders, tessellation shaders, and compute shaders. These shader types enable more advanced techniques and can be used for effects such as dynamic geometry generation, surface subdivision for additional detail, simulations, particle systems, and complex data processing.

While this course will focus on the fundamentals and practical shader creation using Shader Graph, it’s important to be aware that these other shader types exist. As you continue learning and exploring graphics programming, you may want to investigate them further to understand how they expand what shaders can do beyond standard rendering tasks.

5. Next steps

Congratulations!

You completed the first tutorial in this course, and learned some of the basic theory for Shaders. In the next tutorial, you'll set up your project and prepare your workspace to create your first shader.

Complete this Tutorial