Bump mapping on iphone opengl

Forum for Objective-C iPhone games and OpenGL related topics including programming doubts, books and other resources for iPhone game development

Bump mapping on iphone opengl

Postby iamjayanth » Wed Jan 06, 2010 7:39 am

Hi,

I am trying to draw a sphere and provide some bump mapping in iphone opengl ES 1.1 in XCode 3.1.4 . But since iphone opengl doesnt support stencil buffer i need to look at different methods for bump mapping. I read somewhere that we can do dot 3 bump mapping but nobody saying how. I cant find any tutorial or example programs. This is the code i tried to do dot 3 bump mapping

Code: Select all
glActiveTexture(GL_TEXTURE0);
   glClientActiveTexture(GL_TEXTURE0);
   glEnable(GL_TEXTURE_2D);
   glBindTexture(GL_TEXTURE_2D, textures[0]);
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
   glTexCoordPointer(2, GL_FLOAT, 0,texCoord);     
      
   
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE , GL_COMBINE);
   glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
   glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB,GL_TEXTURE);
   glTexEnvi(GL_TEXTURE_ENV,GL_SRC1_RGB, GL_PRIMARY_COLOR);
   glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
   glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
   
   
   
   
   glActiveTexture(GL_TEXTURE1);
   glClientActiveTexture(GL_TEXTURE1);
   glEnable(GL_TEXTURE_2D);
   glBindTexture(GL_TEXTURE_2D, textures[1]);
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
   glTexCoordPointer(2, GL_FLOAT, 0,texCoord);   
   
   
   glActiveTexture(GL_TEXTURE1);
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
   glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,GL_DOT3_RGBA);
   glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
   glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
   glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
   glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
   

//   glTranslatef(-0.0, 0.0, 0.5);
//   glColor4f(1.0, 0.0, 0.0,1.0);
   glDrawElements(GL_TRIANGLE_STRIP,12000, GL_UNSIGNED_SHORT,gridIndices);


texture[0] is a plane blue texture and texture[1] is a png image i used as bump texture. I got this code from following link

http://forum.unity3d.com/viewtopic.php?t=15749[quote][/quote]

I still doesnt understand the code. Is there any way we can do bumpmapping in iphone opengl
iamjayanth
 
Posts: 2
Joined: Fri Jan 01, 2010 6:06 am

Return to iPhone OpenGL ES 3D Game Development Forum

Who is online

Users browsing this forum: No registered users and 1 guest

cron