I spent today trying to get actual multitexturing working using arb_fragment. In order to use shaders with texture units other than the first one the texcoords need to be passed to the remaining units. So if I have a luma/chroma key shader, I need to put a texture on unit 0 and also on unit1. Just enabling them doesn't actually texture them properly though. I added the following to SetVertex() in GemShape:
if (state->numTexCoords) { glTexCoord2f(state->texCoordX(curCoord), state->texCoordY(curCoord)); glMultiTexCoord2fARB(GL_TEXTURE1_ARB,state->texCoordX(curCoord), state->texCoordY(curCoord)); } else { glTexCoord2f(tx, ty); glMultiTexCoord2fARB(GL_TEXTURE1_ARB,tx,ty); }
Doesn't look so bad right? Well, in order to cover every one of the texture units available, they have to be textured onto properly. So for an eight texture unit GPU that's GL_TEXTURE[0..7]_ARB and so on. Is this something that I should go ahead and do?
On Dec 19, 2005, at 6:06 PM, chris clepper wrote:
I spent today trying to get actual multitexturing working using arb_fragment. In order to use shaders with texture units other than the first one the texcoords need to be passed to the remaining units. So if I have a luma/chroma key shader, I need to put a texture on unit 0 and also on unit1. Just enabling them doesn't actually texture them properly though. I added the following to SetVertex() in GemShape:
if (state->numTexCoords) { glTexCoord2f(state->texCoordX(curCoord), state->texCoordY (curCoord)); glMultiTexCoord2fARB(GL_TEXTURE1_ARB,state->texCoordX(curCoord), state->texCoordY(curCoord)); } else { glTexCoord2f(tx, ty); glMultiTexCoord2fARB(GL_TEXTURE1_ARB,tx,ty); }
Doesn't look so bad right? Well, in order to cover every one of the texture units available, they have to be textured onto properly. So for an eight texture unit GPU that's GL_TEXTURE[0..7]_ARB and so on. Is this something that I should go ahead and do?
...definitely add it if it works ;-) But I'm not really understanding how this would be accessed: are you using pix_multitexture to assign to texture unit, then passing this state onto geos? How do the geos know that there are multiple texture units being addressed, or where to stop?
jamie
On 12/19/05, james tittle tigital@mac.com wrote:
...definitely add it if it works ;-) But I'm not really understanding how this would be accessed: are you using pix_multitexture to assign to texture unit, then passing this state onto geos? How do the geos know that there are multiple texture units being addressed, or where to stop?
glTexCoord2f() only works for the default unit 0, and the other calls are needed to texture properly to the remainder of the units. For testing, I only rigged up unit 1 and used pix_multitexture to set the texUnit for each render chain to 0 and 1 respectively. After making the change to SetVertex() [square] could accept the texture. I actually had to texture to some geometry to get the shader to work at all - without setting up glMultiTexCoord2fARB(GL_TEXTURE1_ARB...) the texture was one big pixel. I don't know if alternatives exist or not, but every reference I found had the glMultiTexCoord2fARB() calls for each texUnit used. I think we might have to rewrite the Geos to accommodate the possibility of any of the texture units being enabled upstream or add something to GemState to let them know which unit(s) to use.