Multi shader cocos2d-x 2.2.1

Hi everyone, iam newbie at cocos2d-x and shader and i have some quesiton. :;qst
*How can i apply more two shader at one CCSprite in cocos2d-x. Example : i want to extract bright, blur the bright parts, and recombine the blurred image with the original image to make bloom effect
*How can i improve my writting shader skill, now, i can only write easy shaders, i can’t do things i want :frowning: , can you share my your experience

Thanks for reading, sr if my writting english skill so bad :slight_smile:

1 Like

You can’t do that in one pass you need to extract the highlights and render it to a texture. Then render that with a blur (which usually takes an additional two passes).

David Leroy wrote:

You can’t do that in one pass you need to extract the highlights and render it to a texture. Then render that with a blur (which usually takes an additional two passes).
Yes, i know this but i don’t know how to apply 2 shader into 1 ccsprite, can you help me?

You can’t do that, but you could create a texture (CCRenderTexture), extracts the bright part then render to that texture, then you can combine those 2 textures

Hao Wu wrote:

You can’t do that, but you could create a texture (CCRenderTexture), extracts the bright part then render to that texture, then you can combine those 2 textures

Thanks you so much, it worked :smiley: , one more question, in cocos2d-x,i only can pass float,int and matrix values to shader, how i can pass more two texture into shader to do something like
uniform sampler2D diffuseMap; uniform sampler2D lightingMap;

anyone help me :frowning:

glUniform1i(location, textureUnit);

Multi-texture is currently not supported, you must hack your way to enable multi textures:(