# How to draw a circle on the ground like in “Warcraft 3”? [duplicate]

I've been watching "Warcraft 3", and suddenly realized that I have no idea how to draw a circle on a surface.

Here is an example:

I guess this is projection? I also have very little idea of how to draw a shadow. I only somewhat know OpenGL.

It is also interesting how this circle seems to not perfectly repeat the shape of that cliff. My guess is that it's drawn using a height map, which is stored somewhere separately, and not as the cliff, itself. It looks like it actually goes underwater, but it may be just a compression artifact.

• There are countless ways to do this. The best answer to this questions depends on what graphics engine you are using. – Philipp May 31 '17 at 11:46
• The keyword you are probably looking for is "decals", there are quite a few questions about decals here already - maybe you find some of them helpful? – wondra May 31 '17 at 11:49
• Don't use any engine yet. Maybe I'll use raw opengl, I'm not sure. – Viktor Smirnov May 31 '17 at 11:49
• It seems clear you would like answers in context of OpenGL. Given that, I have narrowed the scope; this came up in the review queue for closure as too broad, and without a specific context (like "OpenGL"), I have to agree. – Gnemlock May 31 '17 at 12:49
• Note that if you later decide to use a different system, where an OpenGL answer is not applicable, your certainly welcome to come back and ask "how would I use this / convert this to this other system"; though not before having to initially learn that new system, as you mention in your question. – Gnemlock May 31 '17 at 12:53

The best way to do this efficiently (without dynamic meshes) would probably be done using the fragment shader.

You pass the circle centers to the terrain's fragment shader, you get the fragment's position from the vertex shader, and using the

dist = length(fragment.xz - center.xz)

You get the distance from the circle's center. If it equals the radius of the circle, then you make the fragment green for example.

• If there are a lot of these circles to draw, then rendering them separately as screenspace decals may be more efficient — limiting the cost of each ring to only the portion of the screen it covers. – DMGregory May 31 '17 at 12:08
• Hm, warcraft 3 was done with opengl 1.3, before any shaders existed. According to this sharkyforums.com/… and this en.wikipedia.org/wiki/OpenGL_Shading_Language – Viktor Smirnov May 31 '17 at 12:27
• @ViktorSmirnov, note that we can help you identify a way to produce the same effect; but we can not tell you how a specific game does it. Unless we actually worked on said game, such answers would only be speculation. Questions asking "how did they do it", as opposed to "how do I do it like they did" are often closed for that distinct difference. – Gnemlock May 31 '17 at 12:51
• I want to target low-spec computers, and because of that I'd like to avoid shaders where possible. What do you think, should I create a circle texture and draw that? – Viktor Smirnov May 31 '17 at 13:14
• Even low-spec computers today support shaders. You'd be hard pressed to find someone playing computer or mobile games on a machine with no shader support, so I wouldn't worry about the tech limiting your audience. – DMGregory May 31 '17 at 13:25