multitexturing - per vertex alpha

hmm, so i’ve never worked with multitexturing before, and i want to texture a model with 4 different RGB textures. the alpha values for the vertices in the model are going to change every frame, so i’d rather not use RGBA textures and upload the new alpha channel constantly. instead, i was wondering if it would be possible to do something like this:


texture unit 0
glColor(… Alpha 0)

texture unit 1
glColor(… Alpha 1)

texture unit 2
glColor(… Alpha 2)

texture unit 3
glColor(… Alpha 3)

glVertex(…) // render the vertex


basically i was wondering if i could specify a different color/alpha pair to be modulated with each texture during the multitexturing stage?

if this isn’t possibly, does anyone have any other ideas as to how i could specify per vertex alpha values without first rendering the model into each texture’s alpha channel?

-lost hope

with GL_EXT_tex_env_combine / GL_ARB_tex_env_combine
you can assign previous textures alpha (or a constant value) to the current texture.
you can set the CONSTANT color for a COMBINE.

there is a lot of things you can do with this extension. without it, I wouldnt know how to get rid of the “A” in a RGBA texture.

oh and make sure you set texenvf for every texture stage. (in this case it would be GL_COMBINE)
this thing here:

shows the older EXT_tex_env_combine quite nice, the ARB version can do a bit more, and with other extensions like crossbar (or nv_combine4) you can jump around in the texture units.

combine and the others from recolection can’t handle 4 textures at once.
you will need something more powerful
eg check out glsl

Careful how you word that, on the face of things it can’t quite handle 4 per vertex weights however it can do overall weights and more than one per vertex, probably three if you consider that one color gets you two by blending between two and maybe all 4 if you use alpha and rgb colors separately. This question keeps coming up with a negative response… hmmmm…

The only vertex attribute you can read with texture_env_combine is the primary color, so that gives you two per-vertex blending weights (RGB and A). This allows you to blend three textures with as many texture units. You can’t access the secondary color or anything like that, so if you want to add a fourth texture, the alpha is going to have to come from a texture.

If you run out of texture units at this point, you’ll either have to resort to multiple passes, or use a more sophisticated extension (in increasing order of hipness: NV_register_combiners/ATI_fragment_shader, ARB_fragment_program, or GLSL).

– Tom

thanks for the responses, but i’m not sure i completely understand. when i retrieve GL_MAX_TEXTURE_UNITS, the value returned is 4, so i think i should be able to handle combining 4 textures at once, no? let me clarify what it is i’m looking for. at each vertex i want to have:

vertexColor = (tex0color * alpha0) + (tex1color * alpha1) + (tex2color * alpha2) + (tex3color * alpha3);

where alpha0-3 are different for each vertex on the model, and their values change every frame. if i follow you right, this cannot be done using just the ARB_texture_env_combine extension? i would have to use a shading language (such as glsl) or use multiple rendering passes where each pass the current texture is modulated with the surface color (1,1,1,current alpha) and then summed with what is already in the framebuffer?

yes, at least to my knowledge that sounds correct, then again I am just learning this stuff myself.

with combine you could only give a alpha value (using GL_CONSTANT) to each texture, you could change that value per frame as well, but it would be for the entire surface not per vertex.

or using PRIMARY_COLOR in the combine requiring multiple passes, as someone else already pointed out. cause primary color can only take the current pass’ vertex alpha.