Set Shader for Tiled Map or TmxLayer

Hi there.

I tried to set a shader (gray or pixelshader) for the layers of the tiled map. But when I use the default gray shader which is built in of cocos2d-x, the layer is frozen (does not move) and is not scaled anymore.

If I use another shader, the layer is not visible anymore.

I set the shader per layer via this code:

mMap = TMXTiledMap::create(mFilename + ".tmx");
mMap->setAnchorPoint(Vec2(0, 1));

auto& children = mMap->getChildren();
SpriteBatchNode* child = nullptr;

GLProgram* shaderProgram = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccPositionTexture_GrayScale_frag);
CCASSERT(shaderProgram != nullptr, "Invalid operation. Cannot create shader program");

shaderProgram->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
shaderProgram->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
shaderProgram->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);

auto glProgramState = GLProgramState::getOrCreateWithGLProgram(shaderProgram);

for (const auto &obj : children) 
      	child = dynamic_cast<SpriteBatchNode*>(obj);

I am really stuck on this.
Thanks for any help!
@ stevetranby: If you are still active, maybe you can have a look?

I think you should be setting the shader on the tilemap’s layers.
I’m doing it like this:

auto layers = _tileMap->getChildren();
for (auto l : layers)
    TMXLayer* layer = dynamic_cast<TMXLayer*>(l);
    if (layer)
        auto programState = createColorGradingProgramStateForLut(_lutBackground);