Archived

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

sphere & normal maping with multi texturing??

This topic is 5580 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.

Share on other sites
Just one texture ? But if you have a texture for the car''s color and a texture for the car''s shininess (spheremap) then you NEED two textures (even though you can use only one texture unit simultaneously if you do it in multipass, but that''s a performance hit).
Do you mean that you don''t have a texture for the car''s color, but you have a single flat color instead ?

Share on other sites
ok i did a bad job explaing what i am doing...

I do have 2 textures for the car...(the normal texture and the sphere maped texture (shinnyness))

but i have the car divided up in to parts that are a bit more "reflective" IE windows. So i want them to show more of the sphere map...So i make an additional texture for the sphere map(with a greater contrast).

it would be nice to use glcolor4 and use one texture for the sphere map...but im getting by fine with a few

Share on other sites
if I understand correctly, you have :
- one rgb texture for the car''s color,
- one rgb (or luminance) texture for the car''s shininess,
- a set of call to glColor4f in order to have an alpha component.

And you want to :
- first render your car''s color (texture),
- secondly add the shininess (texture), modulated by an alpha component (glColor4f) so that some parts of the car are not shiny, some parts are a bit shiny and some parts are very shiny.

Is that right ?

Share on other sites
Yeah BLEND just combines the textures without being able to set the alpha (glcolor4)

and yeah you understand correctly

Share on other sites
The method described below assumes you don''t need the RGB component of glColor4f. If you need it, it is still possible but you need to use the ARB_texture_env_combine extension (or OpenGL1.3+).

for each vertex, you have to call glColor3f(shininess, shininess, shininess) where shininess is the intenisty of the spheremap texture between 0 and 1. That is, shininess will be very close to 1 when you''ll render the glasses.

And the algorithm is :

disable lighting

activate texture unit 0 and texture unit 1 and disable all other texture units (if your card supports more than 2 texture units).

in the first texture unit :
bind the car''s shininess texture (spheremap).
set the texture environment to MODULATE

in the second texture unit :
bind the car''s color texture.
set the texture environment to ADD (available in the ARB_texture_env_add extension, or in OpengL1.3+ kernel)

That''s all. Hope that does the trick.

Share on other sites
wow that sounds like just what i need! thanks!

ill give her a try

Share on other sites
quote:
Original post by vincoof
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 ?

Sorry About that, I did have 3 Textures at one stage, but forgot to remove that line.

quote:
because all todays graphics cards support OpenGL1.1 and a few cards still doesn''t support OpenGL1.3

I did not realizie this! I''m trying hard to get my games to work on as many machines as possible (including a work around for multiple textures). Are there many cards that don''t support multiple textures?

Thanks for pointing out GL_DECAL too

http://nap.mega.net.kg

Share on other sites
OpenGL1.3 is not available for everyone, but the GL_ARB_texture_env_combine extension can be used as well, so there''s something like 80%+ of todays graphics cards that supports that feature. That''s not real statistics, just my approximations.

Go to delphi3D.net and get to the 3D Hardware Info section. There you can see which graphics card/driver combo supports the ARB_texture_env_combine extension. Don''t forget to also check equivalent extensions such as EXT_texture_env_combine

Almost all todays graphics cards support multitexturing. Get to delphi3D.net again and look for the ARB_multitexture extension (and equivalent extensions too). I''d say (again, not real statistics) that 95%+ of todays graphics cards support multitexturing. Still, you have to do something for the other 5% - at the very least warn the user (eg through a dialog box) and exit, at best simulate multitexturing in multipass.

Share on other sites
That''s a very usefull page, thanks!

http://nap.mega.net.kg

• Forum Statistics

• Total Topics
628710
• Total Posts
2984325

• 23
• 11
• 9
• 13
• 14