Jump to content
  • Advertisement

Archived

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

b3rs3rk

Bump mapping big problem

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

i''m trying to insert bump mapping in my 3d engine,but i have a big problem... assuming that i need to use vertex arrays (for speed), i''ve wrote a routine that loads 2 textures, creates a third RGBA texture and then shifts it''s coords by the light position.. but the only thing i''ve got is a quad with a moving texture on it.... how can i do? this is the body of my render function: /**********************************************/ glEnable( GL_LIGHTING ); MoveLight(); g_Camera.Update(); g_Camera.SetViewByMouse(); g_Camera.Look(); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, sizeof(CVector3), &(mesh[0])); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, sizeof(CVector3), &(normal[0])); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ZERO); glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, text2.id); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0); glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(CVector2), &(tcoord[0])); if(BUMP){ ShiftTextureCoords(); glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, text2.id); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD_SIGNED_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_ONE_MINUS_SRC_ALPHA); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(CVector2), &(bcoord[0])); } glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glActiveTextureARB(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); /**********************************************/ where''s the error?

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I think you should look at this tutorial :
http://www.paulsprojects.net/tutorials/simplebump/simplebump.html

Share this post


Link to post
Share on other sites
i''ve already seen that tutorial...

i think that the problem is in the alpha channel: seems that the TEXTURE0 is loaded but not TEXTURE1.. if i try to activate only TEXTURE1 i see only a blank quad :/

Share this post


Link to post
Share on other sites
there's something strange. i've changed my code: instead of using vertex arrays i've used the usual glVertex and glMultiTexCoord2fARB and WORKS! so the error is in the way i use vertex arrays...but where ?!? maybe in the multitexturing... somebody help me!

[edited by - b3rs3rk on May 12, 2004 8:41:53 AM]

Share this post


Link to post
Share on other sites
Don''t forget invoking glClientActiveTextureARB (together with glActiveTextureARB). A safe (and lazy) solution is to invoke both. The good solution is to look at the docs to figure which one does what (IIRC, the glClientActiveTextureARB concerns texture coordinates and glActiveTextureARB is for textures themselves).

Hope it helps.


SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.
The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)

Share this post


Link to post
Share on other sites

  • 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!