multitexturing

hi,
im currently trying to use multitexturing to project two images over a plane.
im just having a real hard time figure out what im doing wrong, it works perfect with the texture0 but if i try for texture1 it just doesn’t…here’s what my code looks like:

 // FRAGMENT SHADER: for now, i just take the second texture and apply it, its not even multitexturing yet really
uniform sampler2D myTexture;
uniform sampler2D myTexture2;
 
void main (void)
{
  vec4 texval1 = texture2DProj(myTexture2, gl_TexCoord[1]);
  gl_FragColor  = texval1;
}

// My main program where i initialise the textures and activate them
 
	glUseProgramObjectARB(ShaderObject);
 
	GLint texLoc   = glGetUniformLocationARB(ShaderObject, "myTexture");
	glUniform1iARB(texLoc, 0);
	GLint texLoc2   = glGetUniformLocationARB(ShaderObject, "myTexture2");
	glUniform1iARB(texLoc2, 1);
 
 
	glActiveTexture(GL_TEXTURE1);
	glBindTexture( GL_TEXTURE_2D, render_texture[1] );
 
 
	glEnable(GL_NORMALIZE);
 
	Vector3D N;
 
	int t=0;
	for(int x=0; x<m-2; x++)
	{
		glBegin(GL_TRIANGLE_STRIP);
		{
		glNormal3f(0,0,1);
		for(int y=0; y<n-2; y++)
		{
			if(y>0 && x>0)
			{
				N.x = Height[x-1+y*(m-1)] - Height[x+1+y*(m-1)];
				N.y = Height[x+(y-1)*(m-1)] - Height[x+(y+1)*(m-1)];
				N.z = 2; 
				glNormal3f(N.x, N.y, N.z); 
 
			}
			glMultiTexCoord3fARB(GL_TEXTURE0_ARB, x, y, Height[x+y*(m-1)]);
			glMultiTexCoord3fARB(GL_TEXTURE1_ARB, x, y, Height[x+y*(m-1)]);  
 
		//	glTexCoord3f(x, y, Height[x+y*(m-1)]);
			glVertex3f(x, y, Height[x+y*(m-1)]);
			if(y>0 && x>0 && x+1<(m-2))
			{
				N.x = Height[x+y*(m-1)] - Height[x+2+y*(m-1)];
				N.y = Height[x+1+(y-1)*(m-1)] - Height[x+1+(y+1)*(m-1)];
				N.z = 2; 
				glNormal3f(N.x, N.y, N.z); 
 
			}
			glMultiTexCoord3fARB(GL_TEXTURE0_ARB, x+1, y, Height[x+1+y*(m-1)]);
			glMultiTexCoord3fARB(GL_TEXTURE1_ARB, x+1, y, Height[x+1+y*(m-1)]);
		//	glTexCoord3f(x+1, y, Height[x+1+y*(m-1)]);
			glVertex3f(x+1, y, Height[x+1+y*(m-1)]);
			}
		glEnd();
		}
		t=0;
	}
	glDisable(GL_NORMALIZE);
	glUseProgramObjectARB(0);
 
 
	glActiveTexture(GL_TEXTURE1);
	glDisable(GL_TEXTURE_2D);

///////////////////////////////////////////////////
// and this is where i initialise the texture 1
 
 
void RenderToTexture_Inv()
{
 
	GLdouble eqn[4] = {0.0, 0.0, 1.0, 10};
	glClipPlane (GL_CLIP_PLANE1, eqn);
	glEnable (GL_CLIP_PLANE1);
 
	glMatrixMode(GL_MODELVIEW);	
	glPushMatrix();
 
 
	calcreflect();
	glViewport(0,0,512,512);					
////////////////////////////////////////////////////////////////// here i associate it with texture1
    glActiveTexture(GL_TEXTURE1);
  glBindTexture(GL_TEXTURE_2D, render_texture[1]);
/////////////////////////////////////////////////////////////////
 
	// On copie l'image du viewport dans notre texture
	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16, 0, 0, 512, 512, 0);
 
	glViewport(0,0,WIDTH,HEIGHT);
 
	glDisable (GL_CLIP_PLANE1);
	glPopMatrix();
 
 
}


  

maybe there’s something obvious i just missed, but i don’t understand why it works for texture0 but when i switch active texture to texture1 it just doesn’t…

Quick check if it works with a vertex shader routing the multitexcoord1 through to the fragment shdader. E.g.:

void main(void)
{
gl_Position = ftransform();
gl_TexCoord[1] = gl_MultiTexCoord1;
}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.