Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am working on a terrain in XNA/C#. My intention is to be able to render multiple textures on the ground across the terrain. However, all tutorials like this are only capable of doing it with about 3-4 textures.

My idea is currently that I create a texture map in TGA that has different colors (RGBA) where each color represent a particular texture. The amount of Alpha in the color describes how much alpha the vertex on the position should have. And there would be a base texture.

However, I am a newbie in this area so I really need some getting started guides. So far I've managed to found none. All tutorials and resources are limited in terms of how many textures they support even though all modern games have many.

My game is an RTS, and having played a lot RTS games, I've noticed they all support lots of textures across the terrain. For example, the world editor for Command & Conquer 3 allows you to place any amount of any texture anywhere.

share|improve this question

2 Answers 2

First, I want to point out that the approach you linked to is capable of doing it with much more than 4 textures. In a SM 3 shader, you have 16 texture registers. You can use all of those registers if you want. Riemer's method just happens to pass 4 weighted values for textures from the vertex shader to the pixel shader. You could choose to pass 8 or 12 or whatever.

That said, as Andrew has pointed out, you probably don't want to just start using 12 textures for every part of your terrain.

Whatever method you choose, you're going to want to break your terrain down into chunks (see below).

Start by reading about texture splatting.

A gamedev paper explaining (the relatively simple) concept is here.

It has some drawbacks, but it works for World of Warcraft, and I suspect it will for you too.

It really depends what you're trying to achieve.

To permit the use of many different textures across the terrain, typically you want to split the terrain into chunks, and then assign texture information to each chunk to be drawn.

Below is a terrain split linearly into chunks. However, a common approach is to use a quadtree, so that chunks vary in size with distance.

Terrain split into chunks.

If you want to draw decal textures over top of the terrain (e.g. blood splatter), you might need to draw a second terrain pass that only draws the transparent decals.

If you're curious about more advanced techniques, you can read about the Frostbite 1 engine's approach to procedural texture splatting here: http://publications.dice.se/attachments/Chapter5-Andersson-Terrain_Rendering_in_Frostbite.pdf

share|improve this answer

First of all, allow me to poke some holes in your suggested method for expanding on that method:

First of all, you have a maximum of 16 texture samplers to use (ps_3_0 registers). So that is the limit of the expandability of the method you linked.

Second of all, each texture sampler in use will add to the texture bandwidth usage of your shader. (You may be able to mitigate this with conditionals in your shader - but I will leave you to do the experiment to see if it actually works.)

Finally, if you embed your "what texture to use" data in a texture, rather than as vertex data (as the tutorial you linked does), then you use up an available texture slot.

So, what are these games doing? I am going to take an educated guess:

First of all, they are probably using a multi-texturing technique similar to the one described in your link. They are possibly doing some tricks with this, for example: using different texture resolutions for detail and scrottox layers.

It also seems (I've been skimming this PDF) that their map builder is automatically chopping up the terrain mesh to allow different sections to use different textures, providing they are in different parts of the map. Thus increasing the number of available textures by increasing the number of batches rather than the number of samplers used (which seems like it would be better for performance).

I must admit - I am not sure how they're getting sharp edges in places - like the roads, while having blended edges elsewhere. But apparently roads are baked into the terrain texture somehow.

And finally, they are possibly also using decals to add fine detail to the map.

share|improve this answer
    
You do raise a couple of good points, but ultimately do not answer the question. Also, world of warcraft and the Frostbite engine (used by Battlefield 2) both store texture splatting data in textures. 16 texture registers is a lot. Remember, you don't draw the whole terrain in a single draw call! Your terrain can be composed of tens of thousands of chunks. –  Olhovsky May 27 '11 at 19:45
    
You might be right - the original question is a bit vague - but it does imply a request for tutorials, which I haven't given. I'll leave my "overview" answer, because it's still useful. –  Andrew Russell May 28 '11 at 2:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.