I need some advice about the fastest way to multitexture a polygon.
I would like to apply various textures to a single polygon. The first texture should be completly opaque. All other textures should be drawn above the previously applied and should appear completly opaque on one corner and between slightly transparent and completly transparent on the remaining corners.
On way to solve the problem would be to render each polygon multiple times using blending for transparency.
Using multitexturing could be an other way. Although i was not yet able to apply a texture (unit) transparent based on a vertex alpha value. (Is this possible?)
Or maybe i should use a fragment shader? (But how much textures can be accessed for one fragment?)
What do you think would lead to the best performance?
Which solution would you prefer?
Are there any other ways to multitexture a polygon?
Plase let me know if you have any advice.
Thanks in advance and a merry christmas,
I’m not sure I understand what the problem is. The lower the number of passes you have to do, the faster it will be (that’s why multitexturing exists).
I think you problem is that you have your base texture, and you are trying to add additional textures (extra layers) to the object you are texturing (a quad) with the extra layers blended.
The easiest way to do this is to actually write the alpha of your extra layers into the texture data (ie. Use a TGA with the required alpha levels).
Alternately you could use the alpha of the vertices - and use ARB_texture_env_combine or register comibiners to achieve the blending. Depending on how many layers you need, you may still need to do multiple passes.
With texture_env_combin you’d setup your first texture stage as REPLACE and the additional stages you use INTERPOLATE (I think - I always spend a great deal of time playing around with texture_env_combine settings). The equation of INTERPOLATE is a0*a2 + a1 * (1 - a2). You’d then use the Primary color as one of the options (probably “a2”). And the operands would be the alpha.
And yes you could use a fragment program - but (a) your hardware needs to support it and (b) your target hardware would need to support it too.
That’s my 2c