Shader Development from Scratch for Unity with Cg
4.7 (1,321 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
7,917 students enrolled

Shader Development from Scratch for Unity with Cg

Learn to program the graphics pipeline with Unity's Shaderlab for creating unique visual surfaces for game objects.
4.7 (1,321 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
7,917 students enrolled
Last updated 3/2019
English
English [Auto-generated]
Current price: $15.00 Original price: $149.99 Discount: 90% off
30-Day Money-Back Guarantee
This course includes
  • 6 hours on-demand video
  • 21 articles
  • 48 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to Udemy's top 3,000+ courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Use Unity Shaderlab to create their own shader effects with CG/HLSL.
  • Apply their knowledge of simple mathematics to change the visual surface of virtual objects.

  • Work with mesh vertices and textures to develop unique rendering effects.

  • Demonstrate a knowledge of the graphics pipeline and apply it to problem solving shading issues.
Course content
Expand all 60 lectures 06:25:20
+ Introduction
7 lectures 25:52

This lecture introduces the course and takes you through the content that will be covered showing demos of the effects that will be covered.

Preview 02:36
FAQs
00:01

More often than not when you are learning something new with software you will find it difficult to tell when you've done something wrong or the software is not working. Here are a couple of common issues you might come across when you start to develop shaders. Be sure to use these as a go to when debugging your own work.

Help! Why can't I see my shaders correctly?
00:41

In this lecture we will take a look at the graphics pipeline and the stages in taking a model from virtual to an image on the screen.

The Rendering Pipeline
03:20

There's nothing like seeing your first shader program come to life. There's still much to discuss about the technical and programmatic specifications of shaders, but lets start with a simple example to get the ball rolling.

Preview 12:31
Challenge
00:15
Crash Course in Vector Mathematics
06:27
+ Shader Essentials
7 lectures 36:47

Shader code has a lot in common with regular C# but can sometimes look a little strange especially with respect to data types. In this lecture we will go over these types and discuss how they are used.

Variables and Packed Arrays
14:01

The structure of a model's mesh is crutial in determiing how a shader will affect its surface. Understanding all the 3D components of a mesh is a fundamental you should have under your belt before attempting to manipulate the look of its surface with shaders.

The Anatomy of a Mesh and Shader Input
06:01

In this lecture we will examine in detail the properties block and investigate how external values and images can be used in shaders.

Shader Properties
15:55
Properties Challenge 1
00:10
Properties Challenge 2
00:09
Properties Challenge 3
00:10
Properties Challenge 4
00:20
+ Illuminating Surfaces
8 lectures 48:16

Before you can start writing more complex shaders an understanding of the way surface brightness is calculated based on the lighting model is necessary. In this lecture we will introduce the concept of lighting models and examine the simpliest: Lambert.

Preview 02:46

In this lecture normal mapping will be introduced. The method is a way to add detail and depth to a model when no geometric detail exists.

Normal Mapping
17:01
Bumped Diffuse Challenge
00:05

Sometimes it can be difficult to visualise mathematical concepts without models to support them.  In this article I will provide a tool for examining normals in Unity which will visualise them and how they change as their coordinates do.

Visualising Normals
03:05

In this section we will examine three illumination models from the history of computer graphics. Learning how each is applied across the surface of a polygon to give a resulting visual effect will give you a better appreciation for the role of the normal in developing shaders.

Illumination Models
03:59

When you want to create an effect that involves multiple vectors, such as the world reflection and normals you need to mix these together in the shader so one affects the other before adding a texture. In this lecture you will learn how to effect a world reflection with a normal map.

Bumped Environments
13:47
Bumped Environments Challenge
00:11

At some point in the rendering pipeline a pixel ends up in a buffer or two. As you create more shaders and shaders containing multiple effects it becomes critical to understand exactly whats going on otherwise it becomes difficult to debug your code. In this lecture we will examing the roles of the frame buffer, z buffer and g buffer and touch on the processes of forward and deferred lighting.

Buffers and Queues
07:21
+ The Dot Product
4 lectures 29:04

Being able to tell where the part of a model is facing with respect to the viewer is critical for the production of numerous shader effects. The dot product function is "need to know" information for any shader writer.

The Dot Product
07:00
Quiz
5 questions

Rim lighting demonstrates perfectly the use of the dot product, though it requires a little mathematical manipulation to get just the right results. In this lecture we will look at introducing other mathematical operations into the code to tweak the dot product.

Rim Lighting
10:04

When you want to vary the effect a shader has on different parts of a surface, logical statements are your friend. In this lecture we will explore the use of logical statements embedded in the code to turn parts of an effect on and off.

Logical Cutoffs
11:51
Challenge
00:09
+ Lighting
8 lectures 42:59

Thus far we've only used Lambert as the lighting model for our shader. To expand the possibilities of what you can do with shaders, we now examine the other lighting models available in Unity.

Lighting Models
05:44

Lambert lighting cannot produce specular highlights. For that you need BlinnPhong. In this lecture we will employ the BlinnPhong lighting model to add glossy effects to our model.

Blinn-Phong Lighting & Surface Output
08:51

In this lecture we take a look at the Unity Physically-Based Lighting Shaders and use the lighting models to investigate the metallic and specular features.

Physically-Based Rendering
11:39

To the Standard PBR shader created in the last lecture add an emissive slider that makes the model glow in the same areas that are grey and white in the metallic gloss map. See the working example in this video. The solution is attached.

Challenge 1
00:18

To the Standard Specular PBR shader created in the previous lecture reverse the glossiness effect so the black areas of the map are highly reflective and the grey and white much more diffuse. See the working example in this video. The solution is attached.

Challenge 2
00:20

In this lecture we will explore the creation of custom lighting models through the development of our own Lambert, BlinnPhong and Toon Ramped lighting from scratch.

Writing Your Own Lighting Model
15:44
Challenge 3
00:06
Challenge 4
00:16
+ Passes & Blending
7 lectures 01:11:55

Many effects including particles and vegetation in games rely on textures which use the alpha channel. In this lecture we will explore the creation of shaders that manipulate this channel as well as discover how transparency works withing the rendering pipeline with respect to the Z buffer.

The Alpha Channel
08:34

In this lecture we will use the alpha channel with rim lighting to create a holographic effect. Included in the lesson will be pointers on using mulitple passes to clear up z buffer issues arising from making models transparent.

Preview 09:50

Blending provides you with control over the way incoming colours are added to colours already in the frame buffer. Through a series of very simple blend statements you can create a plethora of effects. This lecture shows you how.

Blending
13:07

By default in computer graphics the reverse side of polygons are not shown to save on processing. However, in the case of billboards you might want to be able to draw on both sides. This lecture shows you how to turn on the drawing of the backfaces.

Leaves and Culling
05:17

Sometimes you might want a shader that takes more than one image and then merges them together onto a single surface. In this lecture you will learn how to do this as well as dynamically turn one on and off at runtime.

Blending Two Images
11:00

In this lecture we will examine the use of another buffer called the Stencil Buffer. This is useful for masking certain pixels to create a variety of effects including XRay Vision and Drawing Holes in walls.

Stencil Buffer
10:22

The best way to get to understand the stencil buffer is to try it out many different ways. In this lecture we will use the stencil buffer to create a fun optical illusion as well as a dynamic piece of stencil code to let you play with the stencil settings via the Inspector.

Advanced Stencils
13:45
+ Writing Vertex and Fragment Shaders
7 lectures 53:14

In this lecture we'll examine the structure of a vertex/fragment shader. I'll point out a few of the nuances in the code and then show you how to create your own.

The Anatomy of a Vertex/Fragment Shader
07:46

Both the vertex shader and fragment shader both deal with vertices and they can both produce colours. In this lecture we will examine the differences.

Colouring by Vertices and Fragments
17:40

V/F shaders, like surface shaders, are capable of processing materials to colour the surface of objects. In this lecture we will look at how UV values are processed in both the Vert and Frag functions. Towards the end I will show you how to take a screen grab of a scene and use that as a manipulatable material on a plane.

Material Use
11:52

While lighting is best kept to surface shaders that handle them elegantly on your behalf, it is handy to know how they work in V/F shaders. This lecture examines how to add a lambert lighting model to create diffuse light.

Lighting
05:54

There's no point in having light if you can't have shadows. So let's modify the lighting shader in this lecture to examine how shadows are cast and received.

Shadows
09:47
Challenge 1
00:08
Challenge 2
00:07
+ Advanced Effects
9 lectures 01:11:16

In this lecture we will examine the use of a vertex shader with a surface shader. The vertex shader will be used to extrude the surface of a mesh for a ballooning effect.

Vertex Extruding
07:10

Outline is a cool effect you can combine with toon shading to get a Borderlands rendered look. In this lecture we will examine two ways to achieve the look.

Outlining
11:21

In this lecture we will create everyone's favourite glass. But this glass isn't simply a transparent pane. It includes bump mapping, a stained-glass pattern and light refraction.

Glass
10:33

Once you know how, modifying vertices with mathematical functions can create all sorts of interesting effects. In this lecture we will examine the sin function for producing waves on the surface of a plane.

Waves
10:41

In this lecture we will examine a simple way to change the UV values of a surface over time to create a texture that rolls over the surface.

Scrolling Textures
09:09
Challenge 1
00:12

In this lecture we will use more sine functions and lots of them, plus a cosine, pow and squareroot to create some old school plasma to warp across the surface of objects.

Plasma
10:47
Challenge 2
00:06
Where to Now?
11:16
+ Appendices
3 lectures 07:37
Appendix A - CG Function List
05:11
Appendix B - Shader Cheat Sheet
01:58
Appendix C - Credits and Extra Resources
00:28
Requirements
  • You should be familiar with the Unity Game Engine.
  • You should be able to program in a procedural language such as C#.
Description

This course presents a comprehensive guide to programming with Cg and High Level Shader Language in Unity's Shaderlab to create your own visual surface effects for colouring and lighting game objects. It covers the mathematics of light and surfaces and steps you through the recreation of some of the most popular shaders. Many computer graphics concepts will be presented to help you understand the graphics pipeline and provide you with an essential toolkit of rendering knowledge that will have you developing your own transparent, animated and texturised shaders in no time.

In this course, Penny teaches all the invaluable skills you will require to program the computer graphics pipeline in Unity from scratch using her internationally acclaimed teaching style and knowledge from over 25 years working with games and graphics.  But hold on tight as you'll be taken on a journey across the computer graphics realm as it is taught to post-graduate university students. Through detailed descriptions and hands-on workshops examining all you need to know about rendering queues, vector mathematics, graphics buffers, colour theory, 3D meshes, texture mapping, lighting models and much more.

Learn how to program and work with:

  • variables and packed arrays,

  • meshes, vertices and UVs,

  • the mathematics for working with objects in 3D and 2D spaces,

  • a variety of lighting models from creating flat shaded objects to highly reflective shiny surfaces,

  • bump maps for adding extra depth and dimension to surface textures,

  • special effects such as holographic, scrolling textures and surface deformations,

  • the variety of graphics buffers used in the rendering pipeline,

  • forward and deferred lighting, and

  • surface, vertex and fragment shaders written in CG/HLSL.

Contents and Overview

After diving right in and creating your very first shader from scratch we will begin the lessons by examining how 3D models are structured and how that is used within shader code to colour and display the surface in computer graphics. You'll discover all the properties of a shader and how they can be controlled in code and via values fed in through Unity's Inspector.

Following this we will examine a variety of lighting models and how lights and surface textures can influence the final look of a render. Included here, an overview of the buffers involved in the rendering queue will be given with practical examines for creating special effects that require more than one draw call. Students will also be exposed to the power of vector mathematics and especially the dot product and its role in creating beautiful effects such as outlines, rim lighting and holograms. In addition, issues surrounding transparency and blending will be discussed along with many practical hands-on workshops in which students can flex their new found skills to interrogate the code they write for better understanding.

The final section of this course brings all the skills learned throughout together to develop some of the more popular complex shaders including animated plasma and animated water with waves.

What students are saying about this course:

  • This is the best course I've ever taken. It is perfect for me. I worked for 15 years in feature animation. A large part of my career was spent developing shaders for a proprietary renderer. This course has already helped me to bring the value of my previous experience into Unity.

  • Best shader course I've come across. There are enough and more tutorials on youtube to teach you how to develop your own shaders, but nothing falls into the class of Penny's tutorials. They are clear and to the point. Really happy about this one.

  • Wow! Thank you so much! If there were 10 stars - this course would deserve it. Going from absolutely knowing nothing about Shader writing to have a profund understanding about it.....

  • I wanted to let you know that I just finished your shader course and thought it was fantastic. It was a pleasure to take the course and finally get a grasp on a topic that seemed so foreign to me not so long ago. Your teaching style and personality really worked for me and made learning a breeze!

Who this course is for:
  • Anyone fascinated by the way computer graphics works.
  • Anyone wanting to understand how to write their own shaders.
  • Anyone who loves the visual effects that can be achieved through simple code and mathematics.