#### Archived

This topic is now archived and is closed to further replies.

# sphere & normal maping with multi texturing??

This topic is 5794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok this puzzles me... I cant just type glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); after i tell the first texture..then tell the next texture... I see that done with games like need for speed 3... Any one know if thats possible to do? or if there is a way to add a transparent sphere map over a normal one without redrawing the object? Thnx for any advice

##### Share on other sites
I'm trying to do the same thing... Have done it using 3 passes, not with multitexture extension tho..
It uses Alpha (tga) maps to find what parts must have Sphere Mapping and which parts don't...

Here's how I did it before:

          /**********Color Mesh**********/glDisable(GL_BLEND);glColor4f(R,G,B,1.0f);glBindTexture(GL_TEXTURE_2D, CarTex);DrawMesh();/**********Sphere Map**********/glColor4f(1.0f,1.0f,1.0f,0.3f);glEnable(GL_BLEND);glBindTexture(GL_TEXTURE_2D, ChromeTex);glEnable(GL_TEXTURE_GEN_S);glEnable(GL_TEXTURE_GEN_T);DrawMesh();glDisable(GL_TEXTURE_GEN_S);glDisable(GL_TEXTURE_GEN_T);/**********"UnColoured Parts**********/glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glBindTexture(GL_TEXTURE_2D, CarTex);DrawMesh();

I would love to know how to do this using multitextures tho... I just cant find out how to do it... It's the Colouring I have trouble with!

Here's what I've Mannaged so far, It failes to change colour and the Overlay Alpha map is Absolute, either 0 or 255 (know what I mean? )..

                          glActiveTextureARB(GL_TEXTURE0_ARB);glBindTexture(GL_TEXTURE_2D, ChromeTex);glEnable(GL_TEXTURE_2D);glEnable(GL_TEXTURE_GEN_S);glEnable(GL_TEXTURE_GEN_T);glDisable(GL_BLEND);		glActiveTextureARB(GL_TEXTURE1_ARB);glBindTexture(GL_TEXTURE_2D,  mGroups[loop1].TexID );glEnable( GL_TEXTURE_2D );glDisable(GL_TEXTURE_GEN_S);glDisable(GL_TEXTURE_GEN_T);			glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_EXT);glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_INTERPOLATE_EXT);glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_TEXTURE);glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT,GL_PREVIOUS_EXT );glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR);glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE2_RGB_EXT,GL_TEXTURE);glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND2_RGB_EXT,GL_SRC_ALPHA);DrawMesh();

[edited by - shadowmaster on September 5, 2002 4:33:32 AM]

##### Share on other sites
Ok, Finaly got it...My Alpha Channel in the tga was wrong, thats y I could not get it to work...
I've got a nice effect here now... Still does cannot change colour of the car (can any one help me with this!!??)
But the Sphere map works and it has "sphere maped" parts and parts that aren't (like Lights and tires)...

Here's the code from my class:
    void MESH::RenderChrome(){	int loop1,loop2,loop3;	for (loop1 =0;loop1 < numgroups;loop1++)	{		//glColor4f(1.0f,0.0f,0.0f,1.0f);					glActiveTextureARB(GL_TEXTURE0_ARB);		glBindTexture(GL_TEXTURE_2D, ChromeTex);		glEnable(GL_TEXTURE_2D);		glEnable(GL_TEXTURE_GEN_S);		glEnable(GL_TEXTURE_GEN_T);		glDisable(GL_BLEND);					glActiveTextureARB(GL_TEXTURE1_ARB);		glBindTexture(GL_TEXTURE_2D,  mGroups[loop1].TexID );		glEnable( GL_TEXTURE_2D );		glDisable(GL_TEXTURE_GEN_S);		glDisable(GL_TEXTURE_GEN_T);					glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_EXT);		glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_INTERPOLATE_EXT);		glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_TEXTURE);		glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);		glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT,GL_PREVIOUS_EXT );		glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR);		glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE2_RGB_EXT,GL_TEXTURE);		glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND2_RGB_EXT,GL_SRC_ALPHA);					glBegin(GL_TRIANGLES);		for (loop2 = 0; loop2 < mGroups[loop1].numtris; loop2++)		{			for (loop3 = 0; loop3 < 3;loop3++)			{				glMultiTexCoord2fARB(GL_TEXTURE1_ARB, mGroups[loop1].tris[loop2].u[loop3], 1.0f - mGroups[loop1].tris[loop2].v[loop3]);				glMultiTexCoord2fARB(GL_TEXTURE2_ARB, mGroups[loop1].tris[loop2].u[loop3], mGroups[loop1].tris[loop2].v[loop3]);			}		}		glEnd();	}	glActiveTextureARB(GL_TEXTURE1_ARB);	glDisable( GL_TEXTURE_2D );			glActiveTextureARB(GL_TEXTURE0_ARB);	glDisable(GL_TEXTURE_GEN_S);	glDisable(GL_TEXTURE_GEN_T);}

I hope this is what you were after skow(??)

http://nap.mega.net.kg

[edited by - shadowmaster on September 5, 2002 4:34:06 AM]

##### Share on other sites

Thanks a ton shadow!!! that will do quite nicely

ill impliment your method into my code and see how it works...thnx alot for the imput

##### Share on other sites
Hey guys I wonder why you''re using GL_COMBINE ?!??

-- "Reinventing the wheel is stoop ''cept yur noob" T.L.S.

##### Share on other sites
Yay i got my normal and sphere map working!

im using bmps so i got no alpha in the image itself...

ive been using

glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND)

on the sphere mapped texture...and while it looks ok there is no way (that i know of) to adjust the transparency... Im unable to try using your GL_COMBINE''s because when i compile it doesn’t recognize them, is there a headerfile i nead to use those?

or is there a way to set the transparency (IE some way to use glColor4f(1.0f,1.0f,1.0f,0.5f) or something like that?

##### Share on other sites
I've tried GL_BLEND, but it does not have the right effect for me, what else did u change?

Like I said I always use .TGA files as they have the Alpha channels, thats the only way that I can ajust the transparency.. The glSetColor4f function does not work as well as I hoped so it I don't use it at the moment..I'm looking at ways of getting, it or something like it, working at the moment..
I can chuck together a demo for you, if you like (?)

ps. I'm pretty new to C++ and OpenGL so my code is not the best.. If any one out there has any suggestions plz tell me!

http://nap.mega.net.kg

[edited by - shadowmaster on August 27, 2002 8:25:40 PM]

##### Share on other sites
well it seems we both cant get the glSetColor4f to work

mabey some one here will have a good sugestion...ill keep working at it and let u know if i can get it to work with
glActiveTextureARB(GL_TEXTURE1_ARB);

mabey there is a diffrent way to set the blend type for arb''s than the typical glBlendFunc..

im also pretty new to c++ and open gl too

##### Share on other sites
But in fact I recommend GL_DECAL over GL_BLEND, since the equations resulting of the GL_COMBINE operations defined here give exactly the same equations resulting of the usage of GL_DECAL.
Moreover GL_COMBINE is available for OpenGL1.3 whereas GL_DECAL is available for OpenGL1.1, and because all todays graphics cards support OpenGL1.1 and a few cards still doesn't support OpenGL1.3 (at least that's what I saw) your application will work on a greater number of cards with GL_DECAL.

To use GL_COMBINE, you have to get the GL Extensions header which is regularily updated at sgi's site. Download glext.h !

What kind of effects are you trying to get with glColor4f ? You want to colorize your object ?
I don't see what's the problem. What kind of bad visual effect do you experience ?

ShadowMaster : Why do you send texture coordinates for texture unit 2 : glMultiTexCoord2fARB(GL_TEXTURE2_ARB, mGroups[loop1].tris[loop2].u[loop3], mGroups[loop1].tris[loop2].v[loop3]) ?
Because you don't use a 3rd texture unit (in fact, you don't show it in your code but you could use it outside this code) this line will send useless coordinates, isn't it ?

[edited by - vincoof on August 28, 2002 5:07:53 AM]

##### Share on other sites
thnx vincoof come some good info.

I wana use glColor4f to adjust how much of the second texture is seen (the spheremap). (using the alpha)

And i dont know of any way to do that with BLEND OR DECAL...I am now just loading the same texture with different contrats to have diffrent amouts of sphere map showing...That works fine..but it would ne nice to have just one texture.

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 38
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631712
• Total Posts
3001850
×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!