Skip to main content
GameDev.net gamedev.net
🔒 Locked

Bump mapping big problem

Started by b3rs3rk May 8, 2004 at 7:13 PM 5 replies 600+ views
Original Post
b3rs3rk
b3rs3rk
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?
Bourricot
Bourricot
Hi,

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

b3rs3rk
b3rs3rk
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 :/
b3rs3rk
b3rs3rk
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]
rodzilla
rodzilla
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)
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)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.