Weather Effects Shader – Ground Water

Weather Effects Shader – Ground Water

This shader will be making use of the height-blending / lerping shader include described on my previous blog. If you want to find out how that works it’s all covered here.

For many games a dynamic weather system is as important as a day night cycle. Sometimes this is just to provide randomised weather events to add variation, and other times this is part of a scripted event, or area based trigger. Whatever the reason for the effects, it’s important that the environment reacts to the weather.

This blog will be the first in a series creating a shader that adds various dynamic weather effects to surfaces. For this post, we’ll cover adding dynamic standing ground water to any surface. Everything covered in this post is available as a download at the end.

Continue reading “Weather Effects Shader – Ground Water”

Height-blending shader

Height-blending shader

Many of the shaders I find myself writing require some sort of blending between textures. The most common example of this is for terrain shaders, or shaders for terrain type objects. These are usually controller by a splat map, where each color channel dictates the amount of a given texture to use. Another reasonably common example is a model where this data is fed in through the vertex colors instead of a texture map. A rarer example is an effect where the blending is controlled by world position, or even procedural noise.

Everything here is written using C# or HLSL/Cg in Unity, but the maths and principal are valid for any DirectX or OpenGL engine.

In this post we’ll be looking at how to implement texture blending, starting with a basic linear blend and ending up with a fancy height-blended approach. There’s a cginc to download at the end so you can quickly and easily implement these effects into your own shaders.

Continue reading “Height-blending shader”