Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a GL_MAX blend equation equivalent using other methods

I'm trying to figure a way to recreate or at least have a similar result to the max clamp blend equation in OpenGl es 2.0 on Android devices.

Unfortunately, glBlendEquation(GL_MAX_EXT) is not supported on Android. GL_MAX enum is defined in the gl header in Android but when executing, the result is a GL_INVALID_ENUM​, 0x0500 error.

I have a solution using shaders and off screen textures where each render ping-pongs back and forth between textures using the shader to calculate the max pixel value.

However, this solution isn't fast enough for any real time execution on most Android devices.

So given this limitation, is there any way to recreate a similar result using just different blend equations and blend factors?

I have tried many blend function combinations, the closest have been:

glBlendFunction(GL_SRC_ALPHA, GL_ONE_MINUS_ALPHA) : This comes close but textures become too transparent. Textures with low alpha values are difficult to see.

glBlendFunction(GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA) : This also comes some what close but the alpha accumulates too much and the colors become darker than intended.

like image 454
William Chen Avatar asked Dec 15 '25 14:12

William Chen


1 Answers

If you could do GL_MAX blending without needing a special blend function... OpenGL would never have added it in the first place. So your options are to do without or to use your shader method.

like image 169
Nicol Bolas Avatar answered Dec 19 '25 06:12

Nicol Bolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!