Unity Liquid Shader

Team: Solo Project

Role: Shader Programmer

Timeline: 3 Months

DESCRIPTION

This was an independent study project I completed in my 3rd year programming class. I had always wanted to learn more about Unity’s Shader Graph, so I took the opportunity to research techniques used in liquid shaders. I then used those techniques in Unity’s Shader Graph to build my own fully customizable liquid shader that can take on a multitude of visual styles.

TOOLS

  • Unity Shader Graph

PROJECT SHOWCASE

SHADER PROGRAMMING

SHADER TECHNIQUES

I began the project by researching existing water shaders, and I found a few commonly-used techniques:

  • Refraction
  • Depth Fade Effect
  • Scrolling + Layered Normal Maps
  • Vertex Displacement
  • Foam Borders
 On their own these effects don’t do much, but when combined they create a convincing liquid effect.

CUSTOMIZABILITY

Originally my shader was tailored only to creating a water effect, however when I realized the range of effects that could be accomplished by changing a few values, I pivoted to creating a more universial “Liquid Shader.”

 

To support this change, I added two additional features:

  1. A Fresnel Effect which adds a gradient to the border of 3D models using the shader.
  2. Emissive Colour Support which allows glowing liquids to be created such as lava.
Additionally, almost all shader variables are exposed to the user to allow for as much customization as possible.

SHADER PROGRAMMING TAKE AWAYS

My work with Unity’s Shader Graph taught me how most complex visual effects in games are just a few simple effects layered on top of each other. Realizing this approach made it much easier for me to break down other visual effects, and helped me when creating Shaders for future projects.

DOCUMENTATION

WATER SHADER TUTORIAL

To cement what I learned from creating this liquid shader, I created a document outlining the steps needed to create the shader so that someone could follow along and achieve a similar effect.

 

I also linked guides and documentation that I used in my research so that others could expand on what I created and potentially add new features.

 

The document can be viewed here.

DOCUMENTATION TAKE AWAYS

Writing this documentation showed me how understanding a topic is only part of the battle, and that it’s often a greater challenge to communicate that topic clearly to someone who may not understand it. I had to keep this in mind when writing the documentation, explaining things in as clear and consistent terms as I could.