Jump to content
  • Advertisement

Archived

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

Lord FlatHead

Multitexture blend functions ?

This topic is 6016 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

Hello. I''m playing around with the ARB_MULTITEXTURE extension and I''ve run into something weird. Consider the following code:
  	glActiveTextureARB(GL_TEXTURE0_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,  g_Texture[4]);

	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,  g_Texture[5]);

	glPushMatrix();
		
	glBegin(GL_QUADS);
		glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 0);
		glMultiTexCoord2fARB(GL_TEXTURE1_ARB, scroll, 1);	glVertex2f(0, 0);
		
		glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 0);
		glMultiTexCoord2fARB(GL_TEXTURE1_ARB, scroll+1, 1);	glVertex2f(1024,0);
		
		glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 1);
		glMultiTexCoord2fARB(GL_TEXTURE1_ARB, scroll+1, 0);	glVertex2f(1024,768);

		glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 1);
		glMultiTexCoord2fARB(GL_TEXTURE1_ARB, scroll, 0);	glVertex2f(0, 768);
	glEnd();

	glPopMatrix();  
I''m in Ortho mode, and I''m making a sky background. Texture 4 is a blue gradiant, texture 5 is a cloud texture shamelessly ripped from Quake 3 Arena. My problem is, when I multitexture the two together it multiplies the textures, which makes my sky look very, very dark. Is there a way to use different blend functions with multitexturing ? Like just call glBlendFunc(GL_ONE,GL_ONE) and have it blend the textures together that way ? Please help me out, I can''t bear to move along with the rest of my game until I get this fixed _________ "Maybe this world is another planet''''s hell." -- Aldous Huxley

Share this post


Link to post
Share on other sites
Advertisement
Search for ARB_texture_env_combine and NV_texture_env_combine4. You can also use register combiners if you use GF.

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
You can turn on the combine properties and increase the RGB gamma.

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);

Note: for me using 2 works pretty well.

Share this post


Link to post
Share on other sites
If you want exactly tha same effect as glBlendFunc(GL_ONE, GL_ONE), you can use the GL_ARB_texture_env_add extension (which is part of the core of OpenGL 1.3) by doing this :

  
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, g_Texture[4]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); /* new */
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, g_Texture[5]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); /* new */

glPushMatrix();
...


That will add texture 0 and texture 1 colors. I don't know if the textures you have will produce the effect you want, anyway that is exactly what glBlendFunc(GL_ONE, GL_ONE) would have rendered.

Note that thanks to GL_REPLACE, you don't have to call glColor3f(1, 1, 1).
If you want to modulate the textures with the color from glColor, it's a bit more complicated but it is still possible (just ask )

Also, don't forget to set the texture environments back for later use of texture units :

  
glActiveTextureARB(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);


[edited by - vincoof on June 24, 2002 4:40:57 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!