Terrain Texturing

Started by
2 comments, last by zix99 16 years, 9 months ago
Hi, I am now doing a terrain from heightmap, and using shaders-based multi-texturing. Basically, the weightage of each texture being blended on a polygon is dependent on its height. Is there anyway I can use the same concept to do a terrain editor, something like the WC3 Map Editor or the Age of Wonder II map editor, where you can pretty much paint any texture you want? Right now, for multi-texturing, I already have 4 textures load...would using the same technique cause any resources management problem? Is it possible to accomplish this by having a separate bitmap and using its color value to determine which texture to use for a particular patch of terrain? Thanks in advance!
GamesTopica.Net- http://www.gamestopica.net
Advertisement
I'll answer your second question only because that's the only one I know about (I havent used either terrain editor).

The way I texture terrains is a method called "Texture Splatting" (Google it). I use a shader, with 6 textures bound to it. The first 4 are actual terrain textures (ie: grass, sand, rock, and dirt), the 5th is a 32 bit (RGBA) map to tell the shader which texture to blend (must have linear filtering), and the 6th is a normal/lighting map of some sort.

Then it's easy. if you're using OpenGL and GLSL, it's just
texmap = texture2D(tex5, coord).rgba;
outcolor = texture2D(tex1, coord).rgb * texmap.r + texture2D(tex2, coord).rgb * texmap.g + ... + texture2D(tex4, coord).rgb * texmap.a;

Hope that helps you some
~Zix
---------------------------------------------------Game Programming Resources, Tutorials, and Multimedia | Free Skyboxes
Quote:Original post by zix99
I'll answer your second question only because that's the only one I know about (I havent used either terrain editor).

The way I texture terrains is a method called "Texture Splatting" (Google it). I use a shader, with 6 textures bound to it. The first 4 are actual terrain textures (ie: grass, sand, rock, and dirt), the 5th is a 32 bit (RGBA) map to tell the shader which texture to blend (must have linear filtering), and the 6th is a normal/lighting map of some sort.

Then it's easy. if you're using OpenGL and GLSL, it's just
texmap = texture2D(tex5, coord).rgba;
outcolor = texture2D(tex1, coord).rgb * texmap.r + texture2D(tex2, coord).rgb * texmap.g + ... + texture2D(tex4, coord).rgb * texmap.a;

Hope that helps you some
~Zix


Thanks for the idea, but what if there is more than 4 textures? Would it end up hogging lots of resources?
GamesTopica.Net- http://www.gamestopica.net
Ya, it could depending on the size of the textures and the size of the terrain. You may have to swap back and fourth from the HD and the graphics VRAM. I'm sure there are tutorials out there that could explain it better than I could. I'm also sure there are more efficient methods of doing splatting for more than 4 textures.
---------------------------------------------------Game Programming Resources, Tutorials, and Multimedia | Free Skyboxes

This topic is closed to new replies.

Advertisement