3
\$\begingroup\$

I've been experimenting with Ray Wenderlich's tutorial about masking sprite using shaders with cocos2D 2.0.

It works pretty well but now I'd like to rotate the mask independently of the masked texture.

Does anyone have any idea about how to achieve it ?

\$\endgroup\$
2
\$\begingroup\$

you can use 2 different varying coordinates one for the texture and one for the mask. then you need to add a uniform to your vertex shader program which indicates how much MaskTextureCoordinates should be rotated.

\$\endgroup\$
  • \$\begingroup\$ Thanks, I managed to make it work in the case where images are not inside a spritesheet. But if they are, I guess I need to provide extra uniforms for the position of mask/texture area inside the spritesheet, right? \$\endgroup\$ – sdabet Nov 1 '12 at 14:40
  • \$\begingroup\$ Well, finally I 'kind of' made it work if both texture & mask images are in the same spritesheet, by providing 3 uniforms: rotation angle, translation between the 2 image areas inside the spritesheet and center of the texture (for the rotation) \$\endgroup\$ – sdabet Nov 1 '12 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.