Jump to content
  • Advertisement
Sign in to follow this  
methe

texture coordinate generation + multitexturing

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

Hi there, I've followed a tutorial (http://cityintherain.com/howtotex.html) on how to enable automatic texture coordinate with multitexturing on. Here is the set up of the stuff:
           // Parameter used by the automatic texture coordinate generation
           // Define how the S parameter depends on x, y, z, w
          GLfloat paramS[ ] = {1.0, 0.0, 0.0, 0.0};

          // Define how the T parameter depends on x, y, z, w
          GLfloat paramT[ ] = {0.0, 1.0, 0.0, 0.0};

           //We give the elevation as texture 0
          glActiveTexture(GL_TEXTURE0);
          glEnable(GL_TEXTURE_2D);
          glBindTexture(GL_TEXTURE_2D, gl_altitude_id);
          glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

           //Set automatic coord generation for texture 1
          //Set automatic texture coord generation for S axis
          glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
          glTexGenfv(GL_S, GL_OBJECT_PLANE, paramS);

          //Set automatic texture coord generation for T axis
          glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
          glTexGenfv(GL_T, GL_OBJECT_PLANE, paramT);

          //Enable automatic texture coordinate generation for S and T axis
          glEnable(GL_TEXTURE_GEN_S);
          glEnable(GL_TEXTURE_GEN_T);

          //We give the normal as texture 1
          glActiveTexture(GL_TEXTURE1);
          glEnable(GL_TEXTURE_2D);
          glBindTexture(GL_TEXTURE_2D, gl_normal_id);
          glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

          //Set automatic coord generation for texture 2
          //Set automatic texture coord generation for S axis
          glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
          glTexGenfv(GL_S, GL_OBJECT_PLANE, paramS);

          //Set automatic texture coord generation for T axis
          glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
          glTexGenfv(GL_T, GL_OBJECT_PLANE, paramT);

          //Enable automatic texture coordinate generation for S and T axis
          glEnable(GL_TEXTURE_GEN_S);
          glEnable(GL_TEXTURE_GEN_T);

          glActiveTexture(GL_TEXTURE2);
          glDisable(GL_TEXTURE_2D);

          glBegin(GL_POLYGON);
//             glMultiTexCoord2f(GL_TEXTURE0, 0.0, 0.0);
//             glMultiTexCoord2f(GL_TEXTURE1, 0.0, 0.0);
            glVertex2f(0.0, 0.0);
//             glMultiTexCoord2f(GL_TEXTURE0, 1.0, 1.0);
//             glMultiTexCoord2f(GL_TEXTURE1, 1.0, 1.0);
            glVertex2f(1.0, 1.0);
//             glMultiTexCoord2f(GL_TEXTURE0, 0.0, 1.0);
//             glMultiTexCoord2f(GL_TEXTURE1, 0.0, 1.0);
            glVertex2f(0.0, 1.0);
          glEnd();

Note that if I comment all code for automatic texture coord generation and uncomment the manual glMultiTexCoord2f() calls, everything works fine, proving the mistake is not in other part of the setup but simply the texture coord generation. Your eyes and wisdom are appreciated. :) [Edited by - methe on September 20, 2006 7:25:48 AM]

Share this post


Link to post
Share on other sites
Advertisement
Well the problem is simply that the textures don't show up. Both the automatic texture generation and the by-hand (commented glMultiTexCoord2f()) should produce the same result and they obviously don't. I can't find what's wrong with the coordinate generation.
Now, to get the full story, theses textures are used in a shader turned on just before the pasted code. These shaders work perfectly in the case of by-hand texture coordinate and not in the automatic way. If there is nothing special to do in shaders when using multitexturing then I suppose the texture generation initialization is wrong which I have no clue where and how, leading to my request. :)

Share this post


Link to post
Share on other sites
This explains it all...
And now I'm gonna slap the guy next door for having stolen my Orange Book.

thanks for the answer anyway!

Share this post


Link to post
Share on other sites
Added coord generation in my shader and everything works great! Thanks guys. Only detail: The shader works great on my computer but I have a shader compile error on another one! 0_o gonna inquiry that.
log:
Internal error: assembly compile error for vertex shader at offset 9388:
-- error message --
line 137, column 11: error: invalid operand variable
line 141, column 11: error: invalid operand variable
line 143, column 27: error: invalid operand variable

with about 200 lines below of stuffs. Ö_°


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!