dot3 bumpmap problem

Hello there,

I’m trying to implement bumpmap with Opengl ES 1.1 for my android phone.

I found an example from nokia:

http://library.forum.nokia.com/index.jsp…/doc/index.html

http://library.forum.nokia.com/index.jsp…cpp-source.html

however, it doesn’t work on my android

the code example basically uses two different texture maps. one normal map, one texture

it computes the lighting based on the normal map (the light direction is saved to vertex color), and blend the second color texture onto the result.

the setup of the two textures is as below:


        	gl.glClearColor(1, 0, 1, 1);

            gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

            /*
             * Now we're ready to draw some 3D objects
             */

            gl.glMatrixMode(GL10.GL_MODELVIEW);
            gl.glLoadIdentity();
            gl.glTranslatef(0, 0, -3.0f);
            gl.glRotatef(mAngleX, 0, 1, 0);
            gl.glRotatef(mAngleY, 1, 0, 0);

            gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
            gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

            gl.glEnableClientState( GL10.GL_TEXTURE_COORD_ARRAY );
            gl.glDisable( GL10.GL_BLEND );
             

            gl.glClientActiveTexture(GL10.GL_TEXTURE0);
            gl.glActiveTexture( GL10.GL_TEXTURE0 );
            gl.glEnable( GL10.GL_TEXTURE_2D );   
            
            // Use first loaded texture as bumpmap
            gl.glBindTexture( GL10.GL_TEXTURE_2D, bumpmapID );
           
            // Configure the texture combiner to do the DOT3 bumpmapping calculation
            gl.glTexEnvf( GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE );
            gl.glTexEnvf( GL10.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB,  GL11.GL_DOT3_RGB );
            
            // The first colour for each fragment operation is gotten from the bumpmap texture
            gl.glTexEnvf( GL10.GL_TEXTURE_ENV, GL11.GL_SRC0_RGB,  GL10.GL_TEXTURE );
            gl.glTexEnvf( GL10.GL_TEXTURE_ENV, GL11.GL_OPERAND0_RGB, GL10.GL_SRC_COLOR );
            
            // The second colour for each fragment operation is gotten from the primary colour
            gl.glTexEnvf( GL10.GL_TEXTURE_ENV, GL11.GL_SRC1_RGB,  GL11.GL_PRIMARY_COLOR );
            gl.glTexEnvf( GL10.GL_TEXTURE_ENV, GL11.GL_OPERAND1_RGB, GL10.GL_SRC_COLOR );            
      

                 // UNIT 1
                 // Configure the second texture combiner to modulate the base texture
                 // by N.L
                 gl.glClientActiveTexture(GL10.GL_TEXTURE1);
                 gl.glActiveTexture( GL10.GL_TEXTURE1 );
                 gl.glEnable( GL10.GL_TEXTURE_2D );
                 // Use second loaded texture as the "traditional" texture map
                 gl.glBindTexture( GL10.GL_TEXTURE_2D,textureID);
                 // Configure the texture combiner to modulate the colour with the texture
                 gl.glTexEnvf( GL10.GL_TEXTURE_ENV,  GL10.GL_TEXTURE_ENV_MODE,  GL11.GL_COMBINE );
                 gl.glTexEnvf(  GL10.GL_TEXTURE_ENV,  GL11.GL_COMBINE_RGB,   GL10.GL_MODULATE );
                 // The first colour for each fragment operation is gotten from the previous texture combiners output
                 gl.glTexEnvf(  GL10.GL_TEXTURE_ENV,  GL11.GL_SRC0_RGB,    GL11.GL_PREVIOUS  );
                 gl.glTexEnvf(  GL10.GL_TEXTURE_ENV,  GL11.GL_OPERAND0_RGB,  GL10.GL_SRC_COLOR );
                 // The second colour for each fragment operation is gotten from the texture bitmap
                 gl.glTexEnvf(  GL10.GL_TEXTURE_ENV,   GL11.GL_SRC1_RGB,   GL11.GL_PREVIOUS );
                 gl.glTexEnvf(  GL10.GL_TEXTURE_ENV,   GL11.GL_OPERAND1_RGB,  GL10.GL_SRC_COLOR );
               
             
              

if i disable the second texture map, I can see the bumpmap seems to be correctly computed.

however, if i enable the second texture map, with is the color map, the object becomes transparent. i guess the alpha channels are become 0

i don’t know why.

is there anybody who has tried dot3 bumpmap before?

thanks.

i kinda think this is a bug of the android system.
because on their simulator, the object is not transparent, but on the actual phone, it is.

and, on the simulator, the texture map is twisted.