Sign in to follow this  
Nameless Developer

Drawing markings on the terrain

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this