Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Modulating textures


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 FXO   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 September 2001 - 03:27 PM

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

Sponsor:

#2 Maximus   Members   -  Reputation: 124

Like
Likes
Like

Posted 21 September 2001 - 07:00 PM

Just draw the same triangle twice, once as the base texture and then once as the lightmap or such.

#3 FXO   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 2001 - 12:54 AM

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

#4 Maximus   Members   -  Reputation: 124

Like
Likes
Like

Posted 22 September 2001 - 01:07 AM

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.

#5 FXO   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 2001 - 01:29 AM

How do i set the

#6 FXO   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 2001 - 01:38 AM

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

#7 Maximus   Members   -  Reputation: 124

Like
Likes
Like

Posted 22 September 2001 - 01:57 AM

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

#8 FXO   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 2001 - 04:34 AM

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,....


#9 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 22 September 2001 - 10:39 AM

fxo your code is ok, no need for blending.
A/ can your card do the combine + multitexture extensions
B/ how do u draw the texture?

#10 FXO   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 2001 - 01:02 PM

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!



#11 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 22 September 2001 - 04:12 PM

ok i read the ''Now I use:'' post , inreply to the original question + the latest.
to see how blending works check an app on my news page. also the multitexturing demo on my site will let u draw the quad either in one pass with multitexturing or 2 passes using blending check it out perhaps thats of interest.

#12 FXO   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 September 2001 - 12:43 PM

ok, I had some troubles connecting to your site, it is your "homepage" in your profile right?

#13 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 24 September 2001 - 02:34 PM

quote:
Original post by FXO
ok, I had some troubles connecting to your site, it is your "homepage" in your profile right?


yeah, i havent been able to add any new stuff to my site for ages, i think the recession has hit xoom. when i get some cash ill get me own site. could take a while




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS