Archived

This topic is now archived and is closed to further replies.

Normal maps

This topic is 5430 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! I'm trying to implement normal-maps, i read this, http://tfpsly.planet-d.net/english/3d/pplight_bump.html I would be very happy if someone explained how to implement it Some test code i wrote
      
//...Enable GL_LIGHT0...


glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
 
//...Bind texture...

 
// I'm not sure about this

glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_RGB_SCALE_EXT,1);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
 
//...Bind normalmap...

 
// Taken from the URL. 0x8741 = GL_DOT3_RGBA_EXT (google)

glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT, 0x8741);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT,GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);

glBegin(GL_QUADS);
	glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,0);
	glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
	glNormal3f(0,1,0);
	glVertex3f(-30.0f, 0, -30.0f);

	glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,12);
	glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,12);
	glNormal3f(0,1,0);
	glVertex3f(-30.0f, 0,  30.0f);

	glMultiTexCoord2fARB(GL_TEXTURE0_ARB,12,12);
	glMultiTexCoord2fARB(GL_TEXTURE1_ARB,12,12);
	glNormal3f(0,1,0);
	glVertex3f( 30.0f, 0,  30.0f);

	glMultiTexCoord2fARB(GL_TEXTURE0_ARB,12,0);
	glMultiTexCoord2fARB(GL_TEXTURE1_ARB,12,0);
	glNormal3f(0,1,0);
	glVertex3f( 30.0f, 0, -30.0f);
glEnd();

glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);
      
Cheers! [edited by - Sunray on March 7, 2003 6:25:44 AM] [edited by - Sunray on March 7, 2003 6:26:25 AM] [edited by - Sunray on March 7, 2003 6:26:45 AM]

Share this post


Link to post
Share on other sites