There some nice tricks that you can do with a separated alpha. For example, you can draw an object with certain parts opaque and other parts accumulated without changing blending factors.
There is a similar problem on iPhone, but you can solve it by using a custom PNG decoder. But so far I was unable to find any solution for Android. It's not mentioned in the documentation either. Still, there is a hope that I'm just missing something :) Any clue from Android devs? On May 31, 3:43 am, Anton <socialhac...@gmail.com> wrote: > No, I actually haven't been able to. It threw me for a loop > because I was expecting non-premultiplied because that's what the PNG > spec says. What do you want to do with non-premultiplied that you are > having trouble doing with premultiplied? > > -Anton > > On May 29, 4:40 am, djp <david.perou...@gmail.com> wrote: > > > I was wandering if you managed to load a RGBA texture without pre- > > multiplied alpha. > > > I'm working with an assumption that every texture is alpha pre- > > multiplied, because I was unable to load a RGBA texture without pre- > > multiplication (on G1). I'd love to know if it's possible or not. > > > Thanks, > > David > > > On May 28, 9:56 pm, Anton <socialhac...@gmail.com> wrote: > > > > The ball.png that you reference above is 30x30 pixels. As MrChaz > > > said, you must use power of two sized bitmaps. Otherwise the > > > texImage2D function will not accept your texture. It seems likely > > > that that is what is going on here. Also, this works in the 16 bits > > > per pixel modes as well. You don't need a separate alpha channel in > > > your frame buffer to do alpha compositing, so a simple RGB454 frame > > > buffer works, which is what you get if you use a SimpleEGLConfigChooser > > > (false) to select your pixel format. 16bpp formats are twice as fast > > > when it comes to rendering as 32bpp formats (if your fill rate > > > limited, and if you're rendering a 2D game with sprites then you > > > probably are). > > > > Another word of caution, PNG files are supposed to (if you follow > > > the spec) have non-premultiplied alpha channels. But it seems that > > > not many people actually follow the standard, and so you can find PNG > > > files that do it either way. If your PNG files are in fact using non- > > > premultiplied alpha then the glBlendFunction should be > > > (GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA). If they use > > > premultiplied alpha then it should be as MrChaz said (GL10.GL_ONE, > > > GL10.GL_ONE_MINUS_SRC_ALPHA). If you use the first and see dark halos > > > around all of your sprites then you probably have premultiplied alpha > > > PNGs. > > > > As a side note, premultiplied alpha is better for a number of > > > reasons. It simplifies a number of compositing operations and treats > > > all of the color and alpha channels in a uniform way. It also allows > > > for super-luminous pixels. > > > > -Anton > > > > On May 27, 7:00 pm, Nate <nathan.sw...@gmail.com> wrote: > > > > > I am rendering this PNG with no transparency just > > > > fine:http://n4te.com/temp/test.png > > > > However if I try to render this PNG (with transparency) with the exact > > > > same code, I just get a white box:http://n4te.com/temp/ball.png > > > > > I am loading the PNG into a texture like this: > > > > Bitmap bitmap = BitmapFactory.decodeStream(input); > > > > int[] temp = new int[1]; > > > > gl.glGenTextures(1, temp, 0); > > > > textureID = temp[0]; > > > > gl.glBindTexture(GL10.GL_TEXTURE_2D, textureID); > > > > gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, > > > > GL10.GL_NEAREST); > > > > gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, > > > > GL10.GL_NEAREST); // GL_LINEAR for quality. > > > > gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, > > > > GL10.GL_CLAMP_TO_EDGE); > > > > gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, > > > > GL10.GL_CLAMP_TO_EDGE); > > > > GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); > > > > bitmap.recycle(); > > > > > I am using this blending: > > > > gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); > > > > > How is it possible to render a PNG with transparency in OpenGL ES? > > > > > Thanks! > > > > -Nate > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---