Archived

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

Lyve

Multitexturing problem (which rendering modes to use?)

Recommended Posts

Hello forum, I''ve got a little multitexturing problem: I have to render a smiley (as sphere) with a face on it. The smiley body (that thing that is usually yellow) should be able to be textured with a texture. Then, the smiley texture should be able to be colored with an RGB value (to modify a white body texture to be yellow, etc...). The face should be able to be colored with an RGB value, too. But note: The RGB value should be able to be another one as the one for the smiley body. The whole smiley should be able to receive light. I thought I could do it the following way: I use two texture units. The first one renders the smiley body, the second one the face. The face is given by a white texture that got an alpha texture that represents the face (so that only the face is rendered, the rest is transparent to show the smiley body). I''m currently rendering the face with mode GL_DECAL. Now I could color both textures individually with glTexEnvfv()? (hope, not testet yet...) The rest works quite good, but there is one problem: The face texture does not receive light. If I choose a white face, the mouth and eyes of the smiley are always white, even if I move the light away. Anyone any tips which rendering modes of the two texture can be combined to represent the result that I want? Many thanks, Lyve http://nils-music.tk

Share this post


Link to post
Share on other sites
I''d like to clarify a few things before continuing :

"Now I could color both textures individually with glTexEnvfv()?"
Do you mean that you want to use the texture environment color for coloring your texture ?

"The face texture does not receive light."
Do you mean that the body receives light ?

Also, could you please post the piece of code that configures texture units (calls to glActiveTexture and glTexEnv especially) ?

Share this post


Link to post
Share on other sites
>Do you mean that you want to use the texture environment color >for coloring your texture ?

Yes I wanted that but it doesn't seem to work (the color is still always white for the face).

>Do you mean that the body receives light ?
Yepp, exactly. The body does, the face doesn't.

>Also, could you please post the piece of code that configures >texture units (calls to glActiveTexture and glTexEnv >especially) ?

Yepp, here is the code (C++, a bit simplified). The state of this code: The face is rendered correctly on top of the body, but is always white (no face coloring) and is not lit. The body receives light but is also always white (no body color).


    
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );

glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, m_bodyColor );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // like default


m_pBodyTexture->Activate(); // I use my own class for textures, this works, don't worry


glActiveTextureARB( GL_TEXTURE1_ARB );
glEnable( GL_TEXTURE_2D );

glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, m_faceColor );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );

m_pFaceTexture->Activate(); // I use my own class for textures, this works, don't worry


// here comes the drawing code...



Lyve


[edited by - Lyve on November 8, 2002 2:47:25 PM]

Share this post


Link to post
Share on other sites
I understand why it does not work.
Your texture environment colors are never taken in account as you wish. You can find the details of texturing equations in OpenGL Specifications (you can download them for free at www.opengl.org).

Is your body really textured, or do you want to have a flat yellow body ?

Share this post


Link to post
Share on other sites
quote:
Original post by vincoof
Is your body really textured, or do you want to have a flat yellow body ?


Yes the body should be able to be textured.

Lyve (Just browsing opengl.org .....)

Share this post


Link to post
Share on other sites
(Sorry for the late answer, but I just recovered my Internet connection an hour ago)

Also, do you want to have different material properties for your body and your face ? For instance, body is not really shining but face is really shining ?

If you want different material properties, I''m afraid you _have _ to do it in multipass. OpenGL can not perform multiple lighting equations in single pass (unless you override OpenGL lighting equations which is pretty hard to do).

If you want unified material properties for both body and face, you can do in single pas, but :
- you need to support the texture_env_combine extension (available on 90%+ todays OpenGL-accelerated cards),
- you need more than two texture units (well, maybe not if you use register combiners).

Unless you really look for optimal performance, I recommend multipass which is much more flexible, and which is possible on ALL cards.

As a final note, let me say that it''s definately possible to do what you want in single pass IF you''re NOT willing to use texture environment colors. Unfortunately, I''m pretty sure that''s the real goal of the topic otherwise you would not have posted it.

Share this post


Link to post
Share on other sites