Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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? – fiddler Nov 1 '12 at 14:40
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) – fiddler Nov 1 '12 at 16:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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