Is it possible to achieve MAX(As,Ad) openGL blending?
- by Jeff B
I am working on a game where I want to create shadows under a series of sprites on a grid. The shadows are larger than the sprites themselves and the sprites are animated (i.e. move and rotate).
I cannot simply render them into the sprite png, or the shadows will overlap adjacent sprites.
I also cannot simply put shadows on a lower layer by themselves, because when they overlap, they will create dark bands at their intersection.
These sprites are animated, so it is not feasible to render these en masse.
Basically, I want the sprites' shadows to blend together such that they max out at a set opacity. Example:
I believe this is equivalent to an openGL blending of (Rs,Gs,Bs,Max(As,Ds)), where I don't really care about R,G, and B, as it will always be the same color in src and dst.
However, this is not a valid openGL blending mode. Is there an easy way to accomplish this, especially in cocos2d-iphone?
I would be able to approximate this by making the shadow sprites opaque, then applying them both to a parent sprite, and making the parent sprite 40% opacity. However, the way cocos2d works, this only sets the opacity of each child to 40%, rather than the combined sprite image, which results in the same stripe.