зеркало из https://github.com/microsoft/cocos2d-x.git
Merge pull request #5649 from dabingnn/develop_fix_clippingNodeShaderBug
closed #4315: fixed clippingNode alphaTest Bug
This commit is contained in:
Коммит
2aa5c7aadd
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче