Alpha channel in OpenGL shaders

344 Views Asked by At

I have texture with alpha channel (from .png file for example) and I want to mask it with another texture with complex alpha painting. With .jpg files it works great, but if texture have alpha itself, I get some sort of "ghosty" colors, like this

http://i.gyazo.com/5ba2f6594a0027584a6eaf57356588c5.png

So, my question is: why glFragColor = vec4(r, g, b, 0.0) isn't transparent when one of r, g, b color is above zero? Or is there any other way to achieve my task?

Working on iOS with cocos2d-x v3.5, by the way.

1

There are 1 best solutions below

0
Nikolai Ischuk On

It seams problem was in blend function. I've set blend function to {GL_SRC_ALPHA, GL_ONE} and it worked great.