我正在尝试根据我在本教程中看到的代码将凹凸贴图应用于 2D 纹理:http: //www.paulsprojects.net/tutorials/simplebump/simplebump.html
我已经更改了代码以使用我的设置(不使用客户端状态,使用 glVertex 而不是 glDrawElements 绘制顶点等......)但是当我运行程序时,我得到这个输出:
http://www.tiikoni.com/tis/view/?id=cf02ea7
这是代码:(x、y、z、w、h、st 都是有效值)
//Bind normal map to texture unit 0
glBindTexture(GL_TEXTURE_2D, bump->texnum);
glEnable(GL_TEXTURE_2D);
//Bind normalisation cube map to texture unit 1
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, draw_ncm);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glActiveTextureARB(GL_TEXTURE0_ARB);
//Set up texture environment to do (tex0 dot tex1)*color
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_DOT3_RGB_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBegin( GL_QUADS );
glTexCoord2f( st[0], st[1] );
glVertex3f( x, y, z );
glTexCoord2f( st[0], st[3] );
glVertex3f( x, y+h, z );
glTexCoord2f( st[2], st[3] );
glVertex3f( x+w, y+h, z );
glTexCoord2f( st[2], st[1] );
glVertex3f( x+w, y, z );
glEnd();
// texture pass
glBindTexture (GL_TEXTURE_2D, pic->texnum);
glBegin( GL_QUADS );
glTexCoord2f( st[0], st[1] );
glVertex3f( x, y, z );
glTexCoord2f( st[0], st[3] );
glVertex3f( x, y+h, z );
glTexCoord2f( st[2], st[3] );
glVertex3f( x+w, y+h, z );
glTexCoord2f( st[2], st[1] );
glVertex3f( x+w, y, z );
glEnd();