Advertisement

Lesson 22 MultiTexture Problem

Started by August 28, 2003 03:19 PM
7 comments, last by flattop 21 years, 6 months ago
I have a problem with lesson 22 that I can''t figure out. Everything works fine when the demo is running without using multitexturing. But when I enable multitexturing the emboss messes up. The texture loaded into GL_TEXTURE0_ARB is fine, but the inverted bump, loaded into GL_TEXTURE1_ARB does not display correctly. (It looks a lot like a sheet of metal, as tho a smaller image is stretched across the cube.) I''ve been through the code many times but I can''t figure out what i''ve missed. (BTW the downloaded version works fine.) Any help would be much approciated, before I go mad.
Have you change this value :

#define MAX_EMBOSS (GLfloat)0.01f						// Maximum Emboss-Translate. Increase To Get Higher Immersion 


========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Advertisement
Thanks for the quick response, but no, MAX_EMBOSS is still (GLfloat)0.01f

The strange thing is, that everything is ok when not using multi-texturing.
I have a feeling that your card is not supporting Multi Texturing.

Because, if you leave multi texturing off and bump mapping on, then you should get the same effect.

I suggest you download the source of Lesson 24 and run the prog (before you do that lesson). And see if you see anything with Multi (I forgot what the actual extension was, but I think it should be in that lesson).

If you see the extension, then I don''t have a clue...
Thanks for that, but I know my card supports it because if I download the code, it compiles and runs fine. I know I''ve made a mistake somewhere but I cannot figure out what it is.

I''ll let you know if I find it.
Do enable the texture for each multitexture call ?

	// 1. First Texture Unit	glActiveTextureARB(GL_TEXTURE0_ARB);	glBindTexture(GL_TEXTURE_2D, Texture_TGA[0].Texture_ID);	glEnable(GL_TEXTURE_2D);	// 2. Second Texture Unit	glActiveTextureARB(GL_TEXTURE1_ARB);	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);	/*		GL_MODULATE		==> Module the 2 textures		GL_REPLACE		==> Replace the first texture	*/	glBindTexture(GL_TEXTURE_2D, Texture_TGA[1].Texture_ID);	glEnable(GL_TEXTURE_2D);	glBegin(GL_QUADS);		glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f);		glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f);		glVertex3f( 0.75f,  0.75f, 0);			glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f);		glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f);		glVertex3f( 0.75f, -0.75f, 0);		glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);		glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);		glVertex3f(-0.75f, -0.75f, 0);		glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f);		glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f);		glVertex3f(-0.75f,  0.75f, 0);	glEnd(); 


========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Advertisement
The more simple, post your draw function.

========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Thanks Leyder, will post in a few hours when I have finished work.
Hi Leyder, this is the draw code. I''m fairly sure it''s correct. The texture bump displays correctly but invbump is messed up. Both display correctly without multitexturing so I guess I''ve loading them ok. I''ll try and get a screenshot up somewhere in case the can help anyone.

// TEXTURE-UNIT #0
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, bump[filter]);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);

// TEXTURE-UNIT #1
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, invbump[filter]);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);

// General Switches
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);

glBegin(GL_QUADS);
// Front Face
n[0] = 0.0f;
n[1] = 0.0f;
n[2] = 1.0f;
s[0] = 1.0f;
s[1] = 0.0f;
s[2] = 0.0f;
t[0] = 0.0f;
t[1] = 1.0f;
t[2] = 0.0f;
for(i=0; i<4; i++)
{
c[0] = data[5*i+2];
c[1] = data[5*i+3];
c[2] = data[5*i+4];
SetUpBumps(n,c,l,s,t);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, data[5*i], data[5*i+1]);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, data[5*i]+c[0], data[5*1+1]+c[1]);
glVertex3f(data[5*i+2], data[5*i+3], data[5*i+4]);
}

etc....

This topic is closed to new replies.

Advertisement