Jump to content
  • Advertisement
Sign in to follow this  


This topic is 2839 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've been studying the iPhone 3d programming "Bumpy" example, which demonstrates how to do bumpmapping.
The example-code can be found here: http://examples.oreilly.com/9780596804831/readme.html

However I've noticed that the used image ( converted into a header-file in the example) appears to be strange.
The tangentspace.png texture (blue-ish) is converted into a header-file looks like below:

A32BIT TangentSpaceNormals[] = {

/* Header */
0x00000034, /* dwHeaderSize */
0x00000400, /* dwHeight */
0x00000200, /* dwWidth */
0x00000000, /* dwMipMapCount */
0x00010415, /* dwpfFlags */
0x00180000, /* dwDataSize */
0x00000018, /* dwBitCount */
0x00ff0000, /* dwRBitMask */
0x0000ff00, /* dwGBitMask */
0x000000ff, /* dwBBitMask */
0x00000000, /* dwAlphaBitMask */
0x21525650, /* dwPVR */
0x00000001, /* dwNumSurfs */

/* Data */

So if I interpret that correctly, it looks like the "Green" channel is always 0xFF - i.e. it is a green-ish colored texture...
To prove it, I changed the shader to not do any normal-mapping, but instead output the color directly:

void main(void)

// Extract the perturbed normal from the texture:
highp vec3 tangentSpaceNormal = texture2D(Sampler, TextureCoord).yxz * 2.0 - 1.0;
// ... ... ...

and replace replace it with a "Texture2D (Sampler, TextureCoord).yxz and gl_FragColor = vec4(texel, 1);"
but that gives I get a red-tinted texture.
If I take XYZ instead, it's the green (like to be expected from the texture-data up above..)

So it's really confusing... where is my blue-ish normal-map texture? Why are the color channels mixed up?
Any clues anyone what is going on here?

Thanks for any help!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!