PDA

View Full Version : ARB_texture_env_combine problem



e1mffel
09-03-2003, 04:17 AM
Hi there,

I am new to OpenGL ARB texture combine stuff. I am trying to combine 2 textures using a third one as an interpolant.
I have not found examples using the INTERPOLATE_ARB combine option. According to the OpenGL doc, it looks very much like what I am trying to achieve where Arg0 is my first texture Arg1 is my second texture and Arg2 is the interpolant texture, which in my case is a gray shaded textures. What is the proper syntax to use?

Also while I do understand what EXTURE and PREVIOUS_ARB stand for, I do not understand what PRIMARRY_COLOR_ARB and CONSTANT_ARB refer to.

I would appreciate any help on that matter.

Note that I know that I could perform such operation using the fragment program, unfortunately my portable with mobility 9000 does not recognize the ARB_fragment_program extension (for now).

Thanks for any feedback

Eric

Bob
09-03-2003, 05:18 AM
What you require is not possible with texture_env_combine. You have to read two textures in the second texture unit (the texture with the interpolation factor and the second texture to be interpolated), but you can only read one. You will have to look into more advanced extensions which provides other combine formulas.

However, if possible, you can combine the texture with interpolation factors and one of the other textures. Put the interpolation factors in the alpha channel of the other texture. This way you only need one texture in the second stage, and you use the alpha channel as interpolation factor.

PRIMARY_COLOR is the promary color, the color spcified by glColor or similar commands, and CONSTANT is a just constant color you can set with glTexEnv.

zeckensack
09-03-2003, 05:18 AM
PRIMARY_COLOR_ARB is the interpolated fragment color. It's the same color you'd get without any texturing, ie the one you control with the glColor* calls (and glShadeModel(GL_SMOOTH); or GL_FLAT).

GL_CONSTANT_ARB is a per-texture unit constant available as input to the blending equations. You set it up like this:

float opaque_green[4]={0.0f,0.0f,1.0f,1.0f};
float transparent_red[4]={1.0f,0.0f,0.0f,0.0f};
glActiveTextureARB(GL_TEXTURE0_ARB);
glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,opa que_green);
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,tra nsparent_red);
The texture combine equation on unit 0 will now see (0;0;1;1) if it references GL_CONSTANT_ARB, and likewise (1;0;0;0) on unit 1.

Mazy
09-03-2003, 05:47 AM
Many cards that have env_combine, or all that supports opengl 1.4 has the crossbar functionallity. that is you can set not only GL_TEXTURE as source, but even GL_TEXTUREn as source into a combiner, so you can access up to 3 textures in the same pass.

but even without that, read the alpha in the first stage, load it into the alpha part of the pipeline, then image1 in tmu1 (pass through the alpha), and you can interpolate between previous and gl_texture with previous.alpha

e1mffel
09-03-2003, 12:19 PM
Thanks all for the quick reply to my problem. Now I understand the limitation of the pure ARB_texture_env_combine extension. I am working with a mobility 9000 and geforcefx cards at work and the crossbar is available and should work as Mazy mentioned.
As my interpolant texture is changing from place to place, I do not known yet how to blend this properly within the alpha channel... but I have found an easy solution to the problem because my interpolant texture is nothing more than a ramp black & white texture. I removed it and assign white colors to all the vertices with a changign alpha channel. Doing so I can then use the GL_INTERPOLATE_ARB with the SOURCE2 being the GL_PRIMARY_COLOR. I noticed that the color which is specified using vertex arrays is not active unless I enable GL_COLOR_MATERIAL. I still need to get the proper lighting on the surface and therefore modulate the first texture.
Well for now, it works. I will keep exploring what the crossbar allows me to perform and check for performance penalty in doing so.

Thanks

Eric