PDA

View Full Version : Texture environment



goldwire32767
01-17-2004, 01:27 PM
Im trying to find some documentation and examples of how to use texuture environment functions including the new extensions from ARB.
Can you string together more than one effect? Im trying to do bumpmapping using dot3, but i also want to add other effects too, like highlights, reflections etc. any info would be greatly appreciated.

Jan
01-17-2004, 01:52 PM
"including the new extensions from ARB"

Which extensions exactly do you mean?

Texture environment usually means ARB_texture_env_combine etc.

The "new" functions are ARB_fragment_program and ARB_shading_language_100.

Their is a HEAVY difference between them, therefore you should be more precise about what you want to use.

Jan.

goldwire32767
01-17-2004, 02:00 PM
i just meant the recently new additions to texture environments.

goldwire32767
01-17-2004, 06:27 PM
For example, I see alot of examples how to implement multitexture, and dot3
bumpmapping. But im wondering if you can do both effects at the same time. Any
ideas lemme know. Thanks
Chris-

Ostsol
01-17-2004, 07:23 PM
Ah. . . Multi-texturing isn't exactly new, but I get what you mean. DOT3 bumpmapping, BTW, is a specific implementation of multitexturing, not a separate effect.

Anyways, for a DOT3 bumpmapping tutorial, check out the following tutorial:
http://www.paulsprojects.net/tutorials/simplebump/simplebump.html

Also make sure to check out the specs for ARB_texture_env_combine and ARB_texture_env_dot3 (usually used for DOT3 bumpmapping).
http://oss.sgi.com/projects/ogl-sample/registry/

Here's some basic info on how multitexturing works for applying a detail texture to a base texture:



// set the active texture unit
glActiveTextureARB (GL_TEXTURE0_ARB);
// bind a texture
glBindTexture (GL_TEXTURE_2D, baseTexture);
// enable 2D textures
glEnable (GL_TEXTURE_2D);

// set the texture environment mode for this texture unit to GL_COMBINE_ARB
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
// set the texture combining operation
glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);

// set the source parameter for the operation to the bound texture
glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

// set the next texture unit
glActiveTextureARB (GL_TEXTURE1_ARB);
// bind the texture
glBindTexture (GL_TEXTURE_2D, detailTexture);
// enable 2D textures
glEnable (GL_TEXTURE_2D);

// set the texture environment mode for this texture unit to GL_COMBINE_ARB
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
// set the texture combining operation
glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);

// GL_MODULATE requires two paramters

// set the first parameter to the bound texture
glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

// set the second paramter to the result of the previous operation
glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);

[This message has been edited by Ostsol (edited 01-17-2004).]

goldwire32767
01-17-2004, 07:42 PM
the question was NOT, how do i combine multitexturing and bumbmapping. I really want to know. If i want to apply 10 different affects, how would I do it. How can you combine 2 textures and a constant color. Or how about 6-7 different textures.

Ostsol
01-17-2004, 09:22 PM
It depends on your video card. At best you'll be able to combine 8 textures in a single pass -- and that's with ATI's Radeon 9500+ and higher (I think. . . I'm not sure if the 4 pixel pipeline cards allow 8 texture units in the fixed function pipeline). The latest Geforces seem to only allow 4 texture units to be accessed in the fixed function pipeline. The only way around that restriction is to either use fragment programs (via ARB_fragment_program -- or fragment shaders via ARB_fragment_shader) on the newer Radeons) or to use a multi-pass algorithm with blending.

Anyway, if you'll look in the extension specs there's a token for accepting the polygon's primary colour as a parameter in texture combining. As long as you know exactly what kind of multitexturing you want to do (how you want the textures combined) it's not much more difficult than that detail texture sample I posted. You simple keep on binding textures and multitexturing operations to successive texture units.