cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.2k stars 7.06k forks source link

Shaders not working properly for sprite made using Sprite Sheets #18249

Closed hussain-sohaib closed 7 years ago

hussain-sohaib commented 7 years ago
    Sprite* star1=Sprite::createWithSpriteFrameName("Stars_1.png");
//Sprite::create("Stars_1.png");
    node->addChild(star1,20);
    star1->setPosition(Vec2(272,1118));
    star1->setAnchorPoint(Vec2::ANCHOR_MIDDLE);

  auto glprogram = GLProgram::createWithFilenames("Shaders/Shader_WaveFlow.vert", 
   "Shaders/Shader_WaveFlow.frag");
  auto glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram);
  star1->setGLProgramState(glprogramstate);

glprogramstate->setUniformFloat("xx", 10.0f);
glprogramstate->setUniformFloat("yy", 15.0f);

if we make a sprite from an image in sprite sheet, than the shaders effect is not as should be. Sprite made like below produce the right effect. How can we fix it? Sprite* star1=Sprite::create("Stars_1.png");

hussain-sohaib commented 7 years ago

@minggo @dumganhar please have a look at this issue. Its urgent.

hussain-sohaib commented 7 years ago

hello,

the attached folder contains video for correct behavior and issue behavior. When we make stars from spritesheet the shader dont works correctly.

@minggo @dumganhar please have a look.

thanks

spritesheetshaderissue.zip

dumganhar commented 7 years ago

@hussain-sohaib , could you provide the shader and png/plist file?

hussain-sohaib commented 7 years ago

Ok i will email you now. Not here but on your email.

On Tue, 12 Sep 2017 at 10:41, James Chen notifications@github.com wrote:

@hussain-sohaib https://github.com/hussain-sohaib , could you provide the shader and png/plist file?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cocos2d/cocos2d-x/issues/18249#issuecomment-328742734, or mute the thread https://github.com/notifications/unsubscribe-auth/ACC8gzPTPjeh2E8oXow-BcEkaYeRJhHbks5shhmFgaJpZM4PTEoL .

-- Best Regards Sohaib Hussain

hussain-sohaib commented 7 years ago

I have emailed you the resources.

On Tue, Sep 12, 2017 at 10:42 AM, Sohaib Hussain sohaib.hussain7@gmail.com wrote:

Ok i will email you now. Not here but on your email.

On Tue, 12 Sep 2017 at 10:41, James Chen notifications@github.com wrote:

@hussain-sohaib https://github.com/hussain-sohaib , could you provide the shader and png/plist file?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cocos2d/cocos2d-x/issues/18249#issuecomment-328742734, or mute the thread https://github.com/notifications/unsubscribe-auth/ACC8gzPTPjeh2E8oXow-BcEkaYeRJhHbks5shhmFgaJpZM4PTEoL .

-- Best Regards Sohaib Hussain

-- Best Regards Sohaib Hussain

dumganhar commented 7 years ago

@hussain-sohaib I used the code you provide. But there are not any xx and yy uniform in your shaders. Did you forget something?

hussain-sohaib commented 7 years ago

Emailed you.

On Tue, 12 Sep 2017 at 11:25, James Chen notifications@github.com wrote:

@hussain-sohaib https://github.com/hussain-sohaib I used the code you provide. But there are not any xx and yy uniform in your shaders. Did you forget something?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cocos2d/cocos2d-x/issues/18249#issuecomment-328750753, or mute the thread https://github.com/notifications/unsubscribe-auth/ACC8gz1f8ZJuccTyDvQgGVzCbBRvSOLKks5shiO9gaJpZM4PTEoL .

-- Best Regards Sohaib Hussain