1
\$\begingroup\$

As I understand it; by default all bitmaps will will get the alpha channel premultiplied in Android if loaded using BitmapFactory.

My setup: I have a 32bit bitmap(.bmp) where the alpha channel has a gloss map and the rgb is a specular map.

Issue: I found out that I can load the bitmap without being premultiplied using the bitmap option:

opts.inPremultiplied = false;

Result: When I render the alpha channel of the texture like this in the shader:

gl_FragColor.rgb = vec3(texture.a);

The resulting mesh is all white and not shades of gray as expected.

I upload the texture with this method:

GLUtils.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image, 0);

I have also tried using this approach

GLES20.glteximage

as well with the same result although I might have done something wrong there.

Can anyone spot where I have gone wrong or what else I need to do?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ maybe do gl_FragColor = vec4(vec3(texture.a), 1.0f); \$\endgroup\$ Commented Nov 6, 2014 at 13:20

1 Answer 1

1
\$\begingroup\$

It is very likely that your bmp loader does not load the alpha channel and fills it with a default value, as BMP with alpha channel is non-standard. Try using a .png file instead. From wikipedia:

"An integrated alpha channel has been introduced with the undocumented BITMAPV3INFOHEADER and with the documented BITMAPV4HEADER (since Windows 95) and is used within Windows XP logon and theme system as well as Microsoft Office (since v2000); it is supported by some image editing software, such as Adobe Photoshop since version 7 and Adobe Flash since version MX 2004 (then known as Macromedia Flash). It is also supported by GIMP, Google Chrome, Microsoft PowerPoint and Microsoft Word."

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .