IPhone opengl es alpha-blending. I have a black color in the edge

I am developing an iPhone game. I have the original image below to draw it against the background. The original image has an alpha of 0x00 and gradation around the edge, and the background alpha is 0xff. When I draw the original image on the background, I have a black color, as if you can see the image of the result. I am using the OpenGL ES method glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). I have changed all possible arguments, but every time it does not move.

Why is my color black at the edge of the original image? What is the problem? Don't all iphone games use gradation?

Do I need to make the original image without gradation?

Does anyone know a solution?

Original Image:

alt text

Image Results:

alt text

+7
source share
3 answers

Does your image have pre-multiplied alpha? Then you should use

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 

Here are a few explanations of what it is.

Note: I rewrote the answer after doing some research. The rotoglup article mentioned has some idea of โ€‹โ€‹what is going on, and it makes more sense than my original formula. I also tried to understand what other people use in their code, and it seems that this formula is the most used. It's amazing how such a basic thing in 3D graphics like alpha blending can be so controversial, and everyone seems to be inventing a wheel and coming up with their own solutions.

+14
source

Just check the view in which you draw is opaque or not. set the opaque property to false

0
source

One way can happen if you incorrectly configured glTexParameteri for minimize and increase filters, as well as your clamp method. See Adam Redwood Commentary here . Please note that questions about the strength of two textures, texture boundaries, etc. Also may come into play.

 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); 
0
source

All Articles