• Advertisement

Archived

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

Modulating textures

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there! You can combine two textures (on an two-textureunits-board)using "GL_MODULATE" or some other operator as argument to "glTexEnv". Now, how do u do this in two single passes? You could use blend to add textures, but modulate multiplies the colors.. Q3A allows you to turn off extensions (multitexture), and can still draw the lightmapped textures.. Thanks /Fredik Olsson

Share this post


Link to post
Share on other sites
Advertisement
Ok, but the is problem that I dont know how to combine the textures so that the lightmap modulates the underlying texture..?

EDIT: Wrote post too early (grammatical errors)...

Edited by - FXO on September 22, 2001 8:13:47 AM

Share this post


Link to post
Share on other sites
Basically, enable blending, set the texture mode to modulate (instead of replace), set the alpha (through glColor4f) to be translucent, then draw the lightmap poly over the other one.

Share this post


Link to post
Share on other sites
Now I use:

  
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);

glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);

glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);


I draw the triangle two times using this method, but the second triangle replaces the first one, it doesn't modulate it.

Do you mean that I should enable blending using

  
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); // ?


Should I set the lightmaps alpha to zero?

Anyways, thanks for your time!


Edited by - FXO on September 22, 2001 8:41:37 AM

Share this post


Link to post
Share on other sites
You could try the blendfunc GL_DST_COLOUR,GL_ONE_MINUS_SRC_COLOUR tho that is only a guess at which one to use. Depending on the blendfunc used, you may not have to touch the alpha value with glColor4f

Share this post


Link to post
Share on other sites
I added this before the drawing of the second texture (code above):

  
glEnable(GL_BLEND);
glColor4f(1,1,1,0.5);
glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_SRC_COLOR);


The second texture still covers the first one.
However if i use glBlendFunc(GL_ONE,GL_ONE), the texture colors are added correctly, but I want to modulate them,....

Share this post


Link to post
Share on other sites
zedzeek:

A/ yes, my card can do the combine + multitexture extensions

B/ Not really sure what you mean, but I draw the textured polygon twice when multitexturing is disabled (depthfunc:GL_LESS_EQUAL).

Found out how to do it - it was as you said Maximus, it had to do with the blendfunc operators, only it was:
glBlendFunc (GL_ZERO, GL_SRC_COLOR);

I don''t get it, I always thought that
operator1 + operator2 = result (ie. pixelcolor)

Does anybody know how it works or have any good places where I can read about how glBlendFunc() operators are used work?

Thanks for all the help!

Share this post


Link to post
Share on other sites

  • Advertisement