Drawing markings on the terrain

Started by
3 comments, last by dietepiet 14 years, 9 months ago
Hi all, I have an uneven terrain on which I'd like to draw some markings (for example, circles around selected units, blood below the fallen ones etc.) What would be the best way to accomplish this? Here is an example of something similar to what i'd like (Warcraft III screenshot): http://www.sg.hu/kep/2003_07/0713warcraft3frozen2.jpg Note the green circles around the selected units and how they never go below the terrain. Thanks in advance!
Advertisement
'Projective texturing' is a common technique, as are 'decals'. Google should turn up results for both terms.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by swiftcoder
'Projective texturing' is a common technique, as are 'decals'. Google should turn up results for both terms.


If I understood correctly, decals would require adding new geometry that would follow the terrain. That would be very effective if the terrain was a simple heightmap, which it isn't. In fact, arbitrary mesh can be used as a terrain, so that would mean a lot of geometry checking for each frame (considering that units would move), which means it would be very CPU-heavy.

I like the idea of projective texturing, however isn't it very GPU-heavy, as for each marking, each pixel inside some bounding box would need to be transformed from camera space into world (or object) space?

Just checking if I understood it correctly.
Quote:Original post by Nameless Developer
If I understood correctly, decals would require adding new geometry that would follow the terrain. That would be very effective if the terrain was a simple heightmap, which it isn't. In fact, arbitrary mesh can be used as a terrain, so that would mean a lot of geometry checking for each frame (considering that units would move), which means it would be very CPU-heavy.
Generating the decal mesh isn't going to be *that much* more expensive that performing collision detection with an arbitrary mesh. However, if you can't afford it, you can't afford it.

Quote:I like the idea of projective texturing, however isn't it very GPU-heavy, as for each marking, each pixel inside some bounding box would need to be transformed from camera space into world (or object) space?
Not al all - projective texture mapping has been around since the ancient days of OpenGL 1.1, at the very least. It is basically a form of multi-texturing, with texture coordinates generated in projection space.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Hi, there are probably more and better solutions, but for my engine I used the following solution:

I created a static 2D spatial partition tree for the map, the tree leafs represent map triangles, but only store the indices for the triangle vertices.
When rendering a decal, I use the vertex buffer (directX) of the map, select all appropriate triangles in the tree and place their indices in a dynamic index buffer. Then I rendered these selected triangles, but with the decal texture instead of the usual map textures.

I assume a similar method would work for OpenGL.

It worked pretty good in my case. But then again, I usually have only a hand full of these dynamic decals on screen at once, so it wasn't that much of a performance issue anyway.

This topic is closed to new replies.

Advertisement