diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index d243f38481..ed2e2b700b 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -231,7 +231,7 @@ void ClippingNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool #else // since glAlphaTest do not exists in OES, use a shader that writes // pixel only if greater than an alpha threshold - GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // set our alphaThreshold program->use(); diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 9f84a59840..773cd01234 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -49,6 +49,7 @@ typedef struct _hashUniformEntry const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositionTextureColor_noMVP"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest"; +const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV = "ShaderPositionTextureColorAlphaTest_NoMV"; const char* GLProgram::SHADER_NAME_POSITION_COLOR = "ShaderPositionColor"; const char* GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP = "ShaderPositionColor_noMVP"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture"; diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 68a29ad539..545a964201 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -82,6 +82,7 @@ public: static const char* SHADER_NAME_POSITION_TEXTURE_COLOR; static const char* SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP; static const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST; + static const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV; static const char* SHADER_NAME_POSITION_COLOR; static const char* SHADER_NAME_POSITION_COLOR_NO_MVP; static const char* SHADER_NAME_POSITION_TEXTURE; diff --git a/cocos/2d/CCShaderCache.cpp b/cocos/2d/CCShaderCache.cpp index 7567d265df..e7f3179c22 100644 --- a/cocos/2d/CCShaderCache.cpp +++ b/cocos/2d/CCShaderCache.cpp @@ -36,6 +36,7 @@ enum { kShaderType_PositionTextureColor, kShaderType_PositionTextureColor_noMVP, kShaderType_PositionTextureColorAlphaTest, + kShaderType_PositionTextureColorAlphaTestNoMV, kShaderType_PositionColor, kShaderType_PositionColor_noMVP, kShaderType_PositionTexture, @@ -118,6 +119,10 @@ void ShaderCache::loadDefaultShaders() loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST, p) ); + // Position Texture Color alpha test + p = new GLProgram(); + loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTestNoMV); + _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV, p) ); // // Position, Color shader // @@ -199,6 +204,10 @@ void ShaderCache::reloadDefaultShaders() p->reset(); loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); + // Position Texture Color alpha test + p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + p->reset(); + loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTestNoMV); // // Position, Color shader // @@ -288,6 +297,15 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type) p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; + case kShaderType_PositionTextureColorAlphaTestNoMV: + p->initWithByteArrays(ccPositionTextureColor_noMVP_vert, ccPositionTextureColorAlphaTest_frag); + + p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); + p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); + + break; + case kShaderType_PositionColor: p->initWithByteArrays(ccPositionColor_vert ,ccPositionColor_frag);