Building a Custom Unity Terrain Shader @WorldOfZeroDevelopment
Building a Custom Unity Terrain Shader  @WorldOfZeroDevelopment
Uploaded April 2018 | Updated November 2026, 3 days ago
We've built a lot of shaders, how do we attach these to our terrain though? Let's take a look at how you can build a basic shader that integrates with Unity's pre-built terrain tools.

To do this we'll need to build a shader that accepts the Splat maps and Splat's that Unity passes in. Unity will give us a single RGBA control texture. This represents a map of 4 different textures on the terrain. Unity also configures both the Diffuse and Normal maps for each Splat we'll be using. Each channel in our control texture maps to the strength of the splat it represents at that point on the terrain.

By multiplying the texture lookup for each Splat by the value of the control texture that represents it (RGBA maps to Splat 0, 1, 2 and 3 respectively) we know the strength of each texture we should draw. Writing this out to our Surface Shader's Albedo allows us to easily draw the blended maps together.

We also get access to all the other advantages of writing our own shader. We can discard pixels or make our terrain emissive as examples.

If you want to follow along with the Tutorial I used in this video or just want to check out the cool toon shaded terrain example you can find the source here: alastaira.wordpress.com/2013/12/07/custom-unity-terrain-material-shaders

For a reference on Shader Levels you can see this Wikipedia page en.wikipedia.org/wiki/High-Level_Shading_Language. The number of interpolated registers increases from 10 in Shader Model 3 to 32 in Shader Model 4+.

The World of Zero Discord Channel: discord.gg/hU5Kq2u
Building a Custom Unity Terrain ShaderBuilding a Static Website from Markdown with HugoI Learn About Stencil Buffers and Cutting Holes in ThingsBuilding an Editor Window - Unity Observer - Part 0Building a Cloud Game w/ @MicrosoftReactor - Day 2Prototyping the Sand Table - Sand Table - Part 1Pseudo-Random Colors with Hashed StringsLets Draw A Circle - Circle Pixel Shader - Part 2I Built A New WebsiteFinding Components on GameObjects - Unity Observer - Part 4Building The Minefield Game Board - From Live StreamBuilding the Idea Wheel Prototype - OBS Overlay - From Live Stream
World of Zero |

Building a Custom Unity Terrain Shader

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER