OpenGL ES adds noise to texture

I’m reading Beginning Android Games: Second Edition and near the end of chapter 10 there’s an example where you make a 3D spinning textured cube. I didn’t like the texture provided, so I made a very simple 8x8 texture to use. The problem is though, that OpenGL is adding noise to the texture by itself for some reason.

Here are the texture(s) I made:

And this is what OpenGL renders on a Kindle Fire running Android 2.3.4: http://i.imgur.com/oXNWkjO.png
Last but not least, here’s the class: http://pastebin.com/yQUmZPr8

The other three sprites also render with noise, but it’s not as obvious as the crate sprite. It’s only noticeable if you check the colors in an image editing program.

The Texture and Vertices3 classes referenced hold the texture and vertices/texture coordinates/indices of the cube. I can provide them if needed, but they’ve been used before with no problem.

I have no idea why this happens and I couldn’t find anything from searching on Google. All help would be appreciated. Thanks!

It is quite possible that the OpenGL drivers use a low bit-depth for the render-target as an optimisation.

They probably only use 16 bit for the hole rgb color space(5-6-5).
As you can see, because of this you can not represent a grey value in these color-spaces.

This behavior is OS, driver or hardware specific so do some google searches for your kindle fire + version + hardware.

Also, there could be the possibility to force OpenGL to use a full 3x8(24bit) color-space. Google should help there also or someone else on this board.

You are right - it is OS, driver, or hardware specific. I couldn’t figure that out before because the only Android device I have is my Kindle. :slight_smile: Using the device emulator running a Nexus 4 didn’t have this problem. Making the image a GIF instead of a PNG fixed the issue, but increased the image size from 291 bytes to 923 bytes. …that’s about 3x the image size and although 630 bytes isn’t much, it could add up when using a full sprite sheet. I’m assuming there are other Android devices that do this, but I haven’t found a way to force OpenGL to use the full bit depth of an image. Does anyone else know how to do this?

this shouldn’t have anything to do with the image format. Can you show us how you upload the texture?

It’s done with the Texture class from the book.
Here: http://pastebin.com/egncgVYh

As you can see from the previous snippet, the texture is initialized in the constructor and the bind() method is called before it’s drawn.

What texture format you are using?

24-bit PNG. As I said earlier, Using a GIF fixes the problem but a JPG or 8-bit PNG doesn’t.

Those are image formats not texture formats.

Looking at the screenshot, does the quality degradation matter ? I think it rather enhanced the texture.
Or You just want to know why ?