Multiple textures assigned to an object? How to?

Basically, I have a shader written in GPU assembly (so it’ll work on 1.4) and I want it to be able to access different textures, which are assigned to an object. The textures are the base texture, normal map, and gloss map. I got some code where the shader references the textures using:

TEX textureBase , fragment.texcoord[0], texture[0], 2D;
TEX normalVector, fragment.texcoord[0], texture[1], 2D;
TEX textureGloss, fragment.texcoord[0], texture[2], 2D;

I know this samples each of the textures and stores them in memory, but I don’t think texture[n] is a valid built-in variable and I think it needs to be defined by me. First off, how do I make an index containing multiple textures (not multitexturing) and assign it to an object? Second, how do I pass these to this in the shader through this so called ‘texture[n]’ variable? And no, I can’t switch to GLSL, because my card doesn’t support it. Any help would be appreciated. Thanks in advance to whoever can help me out.

I don’t think texture[n] is a valid built-in variable

According to the specification it is. That’s how the examples do it. Why don’t you try it and see what happens?

First off, how do I make an index containing multiple textures (not multitexturing)

Using multiple textures is multitexturing, whether you want to call it that or not.

You bind textures to an ARB-assembly shader pretty much like you bind textures to a GLSL shader. You bind textures to a texture image unit, by setting glActiveTexture followed by glBindTexture. The primary difference is that ARB-assembly shaders specify which image unit they use directly in the shader, while GLSL shaders have to be told by OpenGL code which texture unit to use.

The “texture[#]” syntax specifies which texture image unit the texture accessing function uses.

Would I be correct in saying (textures already loaded and display correctly):

        glBindTexture(GL_TEXTURE_2D, basetex);
        glBindTexture(GL_TEXTURE_2D, dot3tex);
        glBindTexture(GL_TEXTURE_2D, glosstex);

and then passing them to this normal mapping shader like this:

OPTION ARB_position_invariant;
PARAM modelViewTranspose[4] = { state.matrix.modelview.transpose};
PARAM cameraPosition        = program.env[0];
PARAM scale                 = {1.0};
TEMP lightPosObjSpace, cameraPosObjSpace;
TEMP viewVector      , lightVector, temp;
TEMP tangent, binormal;
MUL tangent , vertex.texcoord[1], scale.x;
MUL binormal, vertex.texcoord[2], scale.x;
DP3 lightPosObjSpace.x, modelViewTranspose[0], state.light[0].position;
DP3 lightPosObjSpace.y, modelViewTranspose[1], state.light[0].position;
DP3 lightPosObjSpace.z, modelViewTranspose[2], state.light[0].position;
SUB temp, lightPosObjSpace, vertex.position;
DP3 lightVector.x, temp, tangent;
DP3 lightVector.y, temp, binormal;
DP3 lightVector.z, temp, vertex.normal;
DP3 cameraPosObjSpace.x, modelViewTranspose[0], cameraPosition;
DP3 cameraPosObjSpace.y, modelViewTranspose[1], cameraPosition;
DP3 cameraPosObjSpace.z, modelViewTranspose[2], cameraPosition;
SUB temp,  cameraPosObjSpace,  vertex.position;
DP3 viewVector.x, temp, tangent;
DP3 viewVector.y, temp, binormal;
DP3 viewVector.z, temp, vertex.normal;
MOV result.texcoord[0], vertex.texcoord[0];
MOV result.texcoord[1], lightVector;
MOV result.texcoord[2], viewVector;


# Light parameters
PARAM specularColor = state.light[0].specular;
PARAM ambientColor  = state.material.ambient;
PARAM diffuseColor  = state.material.diffuse;
PARAM shininess     = state.material.shininess;
TEMP textureBase, normalVector, lightVector;
TEMP reflectionVector, viewVector;
TEMP NdotL, RdotL, Falloff, temp, textureGloss;
TEX textureBase , fragment.texcoord[0], texture[0], 2D;
MUL RdotL, textureBase.a, RdotL;
TEX normalVector, fragment.texcoord[0], texture[1], 2D;
TEX textureGloss, fragment.texcoord[0], texture[2], 2D;
MAD normalVector  , normalVector  , 2.0, -1.0;
DP3 normalVector.w, normalVector  , normalVector;
RSQ normalVector.w, normalVector.w;
MUL normalVector  , normalVector  , normalVector.w;
MOV lightVector, fragment.texcoord[1];
MUL Falloff, lightVector, state.light[0].attenuation.z;
DP3 Falloff, Falloff, Falloff;
SUB_SAT Falloff, 1.0, Falloff;
DP3 lightVector.w, lightVector, lightVector;
RSQ lightVector.w, lightVector.w;
MUL lightVector, lightVector, lightVector.w;
MOV viewVector, fragment.texcoord[2];
DP3 viewVector.w, viewVector, viewVector;
RSQ viewVector.w, viewVector.w;
MUL viewVector, viewVector, viewVector.w;
DP3 reflectionVector, normalVector, viewVector;
ADD reflectionVector, reflectionVector, reflectionVector;
MAD reflectionVector, reflectionVector, normalVector, -viewVector;
DP3 reflectionVector.w, reflectionVector, reflectionVector;
RSQ reflectionVector.w, reflectionVector.w;
MUL reflectionVector, reflectionVector, reflectionVector.w;
DP3_SAT RdotL, reflectionVector, lightVector;
POW RdotL, RdotL.x, shininess.x;
MUL RdotL, textureBase.a, RdotL;
MUL RdotL, specularColor, RdotL;
MUL RdotL, RdotL, textureGloss;
DP3_SAT NdotL, normalVector, lightVector;
MUL NdotL, Falloff, NdotL;
MUL RdotL, NdotL, RdotL;
MUL NdotL, diffuseColor , NdotL;
ADD textureBase, ambientColor, textureBase;
MAD result.color.rgb, textureBase, NdotL, RdotL;

Apparently not, because I am getting a black screen… And I know my shader setup is correct because it works with other shaders written in ARB.

Use glActiveTexture(GL_TEXTURE0) before the glBind to activate tex unit 0…n

I did… reread my post…

BUMP. The question still remains unanswered. :confused: