Multitexturing alpha based blending?
I''m making some terrain, at a higher y value I want there to be snow and at a lower heights rock.
In between the rock and the snow I want there to be a blending of both. The rock I have bound under GL_TEXTURE1_ARB and the snow under GL_TEXTURE0_ARB. I set the alpha values for the snow per vertex using glColor4f().
How do I set up the glTexEnvi to draw the snow over the rock depending on its alpha value?
Thanks for any help.
I don''t think glTexEnvi will do the trick. Just choose a good blending mode with glBlendFunc, draw your tiles with per-vertex alpha data, and enable blending and you should be set.
<- Cow Soft, free software I''ve made
"Unfortunatly, when I sent the email, instead of writing "Best Regards" I ended up writing "Best Retards." - boolean
<- Cow Soft, free software I''ve made
"Unfortunatly, when I sent the email, instead of writing "Best Regards" I ended up writing "Best Retards." - boolean
Well after a LOT of searching I found this which is supposed to do the trick, but it looks the same GL_DECAL.
This doesn't work. I would really like to be able to do this without doing second poly pass, any suggestions?
[edited by - skow on February 29, 2004 6:15:18 PM]
// Init texture unit 0 glActiveTexture( GL_TEXTURE0 ); // Set up texture function for RGB and alpha channel glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE ); glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE ); // Modulate the RGB components of the primary color and texture glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR ); // Replace the alpha component glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA ); // Init texture unit 1 glActiveTexture( GL_TEXTURE1 ); // Set up texture function for RGB and alpha channel glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV ); glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD ); glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE ); // Interpolate the RGB components of the first and second texture // using the alpha primary color glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_ONE_MINUS_SRC_COLOR ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_TEXTURE ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_SRC_COLOR ); // Replace the alpha component glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA );
This doesn't work. I would really like to be able to do this without doing second poly pass, any suggestions?
[edited by - skow on February 29, 2004 6:15:18 PM]
If you only have 2 textures, use GL_COMBINE with GL_INTERPOLATE.
This will smoothly blend between 2 textures based on the supplied alpha value. look for the specs here: http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_env_combine.txt
Good luck.
Waramp.
"Before you insult a man, walk a mile in his shoes.
That way, when you do insult him, you''ll be a mile away, and you''ll have his shoes."
This will smoothly blend between 2 textures based on the supplied alpha value. look for the specs here: http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_env_combine.txt
Good luck.
Waramp.
"Before you insult a man, walk a mile in his shoes.
That way, when you do insult him, you''ll be a mile away, and you''ll have his shoes."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement