PDA

View Full Version : Bump mapping on iphone opengl



quint- iphone designer
01-06-2010, 12:32 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


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_TEXTURE0);
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_TEXTURE1);
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);
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

I still doesnt understand the code. Is there any way we can do bumpmapping in iphone opengl

Abdallah DIB
01-06-2010, 02:02 AM
did u check out this link : it is an old implementation for bump mapping using texture combiners:

http://www.paulsprojects.net/tutorials/simplebump/simplebump.html

now if ur application target the Iphone3GS wich support shaders (AFAIK) u can use modern code for bump mapping.

arekkusu
01-06-2010, 08:57 AM
The stencil buffer has nothing to do with bumpmapping.

IMG's PolyBump (http://www.imgtec.com/powervr/insider/demos/polybump.asp) demo in their SDK (http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES1xMBX.asp) demonstrates how to do object-space bumpmapping in ES1.

Ragnemalm
02-20-2010, 01:16 AM
Texture combiners are scary IMHO. Not that I can't use them if I have to, but the functionality is limited and it really feels outdated. Shaders is so much better. Now, what is the state of shaders on the iPhone? I don't develop on iPhone yet but the plan is to port my animation code there, hopefully soon.

scratt
02-22-2010, 08:20 PM
On the newer devices i.e. iPhone 3GS and iPod 3rd Gen (32 & 64MB) the GPU is GLES2.0 and supports shaders.

Older devices do not support shaders.

I've found that the shader capability on the newer iPhone / iPod GPUs is very capable, easily up to the kind of things I was doing on chips like the ATI x1600 a year or two ago.