-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Unity 2021 Shaders and Effects Cookbook
By :

Many real-time strategy (RTS) games display distances (range attack, moving distance, sight, and so on) by drawing a circle around the selected unit. If the terrain is flat, this can be done simply by stretching a quad with the texture of a circle. If that's not the case, the quad will most likely be clipped behind a hill or another piece of geometry. This recipe will show you how to create a shader that allows you to draw circles around an object of arbitrary complexity. If you want to be able to move or animate your circle, you will need both a shader and C# script.
The following screenshot shows an example of drawing a circle in a hilly region using a shader:
Figure 4.22 – Example of a circle in your region
Despite working with every piece of geometry, this technique is oriented to terrains. Hence, the first step is setting up a terrain in Unity, but instead of using a model, we...