login | register

5-texture blend

5-texture blend
11th Mar 2010 - 13:22by jansic
Just recently I've been working on the map editor for DaK. It's not a particularly difficult application to write but as I've been developing it certain design decisions have reared their heads as forms of inflexibility, that then extend into the usability of the application.

Initially I used an ARGB texture as a blend map for other textures on the terrain, using the alpha channel for baked lighting and RGB for the texture weights. Using the editor made it clear that three textures just isn't enough, even allowing for the fact that I can change textures on a per-patch basis. To alleviate this I switched to normal-based lighting; this freed up the alpha channel and gave me four textures per patch. Four textures is better but still not enough for the flexibility I need.

It occurred to me this morning that if I've got texture units to burn (which I have) then actually I can blend 5 textures, because hiding in the weights there's an implicit 5th texture.

w0 = blend.x w1 = blend.y w2 = blend.z w3 = blend.w w4 = 1.0 - (w0 + w1 + w2 + w3)

Very simple really, the weight for the 5th texture is what the other weights didn't contribute. I'm assigning this 5th texture to the parent grid for all the patches, this means that all the sub-patches share the same texture but can still have 4 unique textures of their own.
Replies: