Skip to main content
gamedev.net
🔒 Locked

blend maps...

Started by yodaman 3 replies 1.8k views
Original Post
yodaman
yodaman
Ive read many articles, threads etc and made a few threads on the subject of terrain texturing. Everyone usually just pointed me to Charles Bloom's texture splatting article. However, I wasn't very happy with his technique, I wanted something more simular to unreal tournament 2's style. My first idea was to use an alpha map for every single layer, but this method would use up vram very quickly. Anyway, I realized that instead of making a seperate alpha map for every texture 'layer' I could simply make a single rgb texture and use it as a 'look up' table, where each color would be bound so a seperate layer (grey/black = rock, green = grass, white = snow or whatever etc). Doing it this way, I can make a program that will alow me to paint directly on the terrain and then save the output as the blend map. The only problem is though, Im not sure how to go about implementing it....Im using Opengl btw. I g2g for now, so ill answer any questions when I get back. Thans a lot. ~Jason
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org
soconne
soconne
That's kind of how I do it in my own editor, http://freeworld3d.org.

But creating a separate alphamap for each layer doesn't take up too much memory if you store the alpha map as an ALPHA texture, meaning it has only 1 channel.
Author Freeworld3Dhttp://www.freeworld3d.org
soconne
soconne
Well you don't have to stretch a single texture across the terrain, you can tile it. The alpha texture and the actual RGB texture can be 2 different textures. So you map the alpha once, and the RGB however many times you want it tiled. This is what I do, and it works great, same with Unreal Tournament and even FarCry.
Author Freeworld3Dhttp://www.freeworld3d.org
Soiled
Soiled
A single alpha texture for all texture layers is what I'm planning. It can be compressed for offline storage too (eg, if only have 64 terrain textures total then 6 bits can be used instead of 8 - and some quad-tree type compression (because some regions will be covered by a single type).

I have a very low-res, pre-compiled, pre-blended dxtn texture that covers whole terrain and is used to texture terrain that's distant from the viewpoint. Closer terrain uses a VRAM texture cache (that caches results of blending). The closest terrain uses explicit blending which saves alot of texture cache memory and allows use of anisotropic filtering.

When generating a texture for the cache or doing explicit blending directly onto terrain I generate the blend factors using the GPU and a rendertarget. First the pre-compressed surface-type data is decompressed by CPU into an 8-bit surface-type alpha texture for the region being textured. For each terrain surface-type that covers the region being textured (determined at compile time) the GPU renders the blend factor into a channel of a 32-bit RGBA rendertexture by comparing the 8-bit value in the surface-type alpha texture with the 8-bit value of the current surface-type (eg, pixel shader constant) and outputting 1 if equal and 0 if not equal. This should be smoothed by doing this compare over 2x2 block of texels (and dividing sum by four). For example, say you have a terrain patch that has 32x32 sub-squares (each with an 8-bit surface-type, like rock, grass) then your surface-type alpha texture is 34x34 and your final blend factor texture is 33x33 where each texel centre maps to the vertices of the grid surrouding the 32x32 sub-squares to avoid seams between patches. This means the border of 34x34 surface-type alpha texture contains surface-types in adjacent patches. So now your blend factors are in RGBA blend factor textures (2 textures contain 8 layers) and you can blend tiled terrain textures together. With OGL may have to use pbuffers or something instead of rendertextures or just do it on the CPU. So the only area where you have decompressed 8-bit surface-type alpha textures and 32-bit blend factor textures is the area around the viewpoint. The good thing about blend textures vs storing blend factor in vertices is you can have terrain LOD.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.