alpha blending with multitexturing

So I’ve searched for an answer to this and either cannot find one or do not understand that actual problem. basically here is what Im trying to do

I generate a heightmap and have about 5 different textures that consist of various parts of the height map. Originally what I did was split the height map up into five different pieces and draw each one then redraw each one with different textures and blend them. This was done by changing the various alpha values for each redrawn texture using

glColorPointer(4, GL_FLOAT, 0, mAlphaColor);

where mAlphaColor is an array of colors with varying alphas.

What I wanted to change this to was simply drawing the terrain once and having the 5 textures each have their own alpha values to determine if they should be drawn or not. Since I can only set one ColorArray per mesh I have no idea how to do this. Can I? Any help is greatly appreciated.

Looking at my previous post i guess I should elaborate a bit more on what I did different. I set it up so that I call glDrawElements only once now. I setup multitexturing in and make each texture active before I draw. At first I assumed I may be able to set a color array for each texture like you do for the texture coords. This wasn’t the case. How can you set different varying alphas per vertices for each texture? This seems like it must be possible and I am just missing it. Once again any help is greatly appreciated…

This is all about the fragment shader. Blending will use th efragment’s output color and alpha.

What gets output is 100% determined by your fragment shader.

If you could guarantee that alpha was coverage and summed to 1 you could always chain (previous_color + unit_color * per_vertex_contrib_this_unit) in each unit, and possibly sum alpha but don’t use it except for final blend, previous_alpha+alpha*contrib in each alpha combiner unit.

The problem with fixed function here is you lack the vertex attributes to supply and use per vertex weights to each unit. You need to use a shader I think. Then it’s up to you to constrain the total texture contribs to 1 in the content.

Of course there are other ways, like layered souce, 1-source in the chained units. This would also be more compatible for multi-pass fallbacks.