Hey y’all, this tutorial series is going to cover all of the techniques used to create the foggy window shader! There’s quite a bit going on, so we’re going to break it down into 3 parts:
- The Gaussian blur effect
- Writing & reading a texture
- Changing the blur based on the texture
At the end of each part, you’ll have a fully working shader, and you’ll learn techniques that you can reuse and adapt in other shaders!
A little disclaimer- this section does a really lazy application for the blur for the purposes of focusing on part 2 and 3. It’s most useful if you’ve never written a blur before and want to learn a really basic (but lazy) way of applying it in Unity. If you’re already a pro at writing a blur shader, then go ahead and move on to part 2!
Here’s the full code for the foggy window shader for you to reference. You’ll also need to look at the DrawOnTexture script for the C# part of this tutorial, and the blurring algorithm is in blur.cginc.
On with the tutorial 🙂
Continue reading Foggy Window Shader in Unity
What this tutorial will cover
This is going to be a pretty big tutorial that’s going to cover how to use command buffers in Unity for graphical effects that require extending the graphics pipeline. I’m going to illustrate the concept by explaining how I built the system that creates this selective bloom effect.
The glowing effect in this tutorial is pretty boring, since the glow is a single solid color. I challenge you to modify the glow buffer step to actually render the model or utilize a custom emission map per-object… the possibilities are endless! The possibilities of what could be contained in this tutorial, however, are finite, so that’s why we’re focusing on this solid color glow.
Credit goes to Unity’s example project for command buffers, especially the one on decals, for helping me figure out how to utilize command buffers.
What you need to start
You’ll need some basic knowledge about how Unity’s rendering pipeline works, and what rendering pipelines do in general. I also recommend you check out Unity’s basic overview of command buffers before reading this.
You definitely also need to have some experience writing basic shaders. This blog is full of tutorials on shader writing that I strongly recommend you check out before diving into this one ;0
I also strongly recommend that you reference the Unity project on GitHub for this tutorial, as it completely implements everything we’re about to cover!
Continue reading Using Command Buffers in Unity: Selective Bloom
I never thought I was going to be able to do graphics programming because I believed I was bad at math. The only class I failed in college was a math course. And yet here I am, actually doing decently well at handling math subjects!!
Visualizing math has made all the difference. Abstract math means nothing to me, and I don’t expect it to mean anything to you either. But that doesn’t mean you’re not good at math- it might just mean you have untapped potential at geometry and visual-based math!
The best way to use this tutorial is probably to either a) reference it when you’re confused about or forget the meaning of a term used in another tutorial (for example, a tutorial says “get the surface normal” or “transform into X space” without explaining what that means) or b) reading it as a primer for more complex discussions of the subjects presented. To really harness the math involved in this tutorial, you’ll need to do a combination of experimentation and research: start writing code to experiment with the terms you learn, and read books that go more in-depth explaining the math involved.
Or, you could do what I did, and use it as a brush-up on your graphics-related linear algebra skills before having a technical interview. ¯\_(ツ)_/¯
This tutorial is going to cover how the following math topics apply to representing 3D geometry:
- What vectors and matrices represent
- Vector addition & subtraction
- Vector cross products & surface normals
- Vector normalization
- Vector dot products
- Matrix * vector multiplication
Continue reading Basic Math for Shaders
Mercy and certain other characters and powers in Overwatch have a cool effect that draws players in front of walls. Mercy’s looks like this:
Notice how, in this image, the D.Va is drawn as a solid translucent color. The translucency applies to the model itself such that it looks like you can see the inside of the model and its backfaces.
In this tutorial, we’re going to learn how to replicate this effect!
For your reference, the full code for the x-ray shader is here, under a non-commercial open-source license. 🙂
Continue reading X-Ray Shader Tutorial in Unity
Hey y’all! We’re going to learn about several different shader techniques in this tutorial. The distortion effect in particular was covered in the ice tutorial, but we’re going to re-learn it here in a new light.
Basically, this heat distortion shader was achieved by creating a flat plane mesh and applying a material with a shader that does the following:
- Billboard the plane to the camera view & draw it on top of everything
- Grab the camera’s rendered texture
- Distort the texture sample position
- Use the distorted position to sample & draw the camera texture
For your reference, here’s the final code for the distortion fire shader.
Let’s jump right in!
Continue reading Heat Distortion Shader Tutorial
Hey y’all! Today, I have a quick tutorial on how to create the highlight effect featured in the gif above. I was inspired by artworks like this one by Loish which have strong rim highlights.
If you’re familiar with this tutorial on how to create a basic outline, then this technique will be super easy! However, that’s certainly not required reading 🙂
For your reference, here’s the link to the final code for the highlight shader. It also includes some custom diffuse lighting from this tutorial, but you really only need to look at the pass labeled “outline pass”!
On with the tutorial!
Continue reading Rim Highlight in Unity
Hey y’all! I was incredibly inspired by this piece of art that Caludia Rinofer created, and I wanted to try and make it as a shader.
The result was the bird you see from the header image! And, of course, I just had to make a tutorial out of it too, to show y’all how I used texture masks and other fun shader tricks to create the effect.
If you enjoy this post, please consider following and supporting Claudia, who inspired it, and checking out the free Unity assets I used for the bird and background:
Living Birds (raven 3D model)
Farland Skies (skybox)
You can find the final code for this tutorial here.
Now, on with the tutorial!
Continue reading Texture Mask Shader in Unity Tutorial