Open 1078559858 opened 8 years ago
@liamcindy Please take a look on this issue, Thanks.
On mobile LayerColor
set as stencil,
should setAlphaThreshold(1);
it is work
some source code
void ClippingNode::setAlphaThreshold(GLfloat alphaThreshold)
{
#if CC_CLIPPING_NODE_OPENGLES
if (alphaThreshold == 1 && alphaThreshold != _stencilStateManager->getAlphaThreshold())
{
// should reset program used by _stencil
if (_stencil)
setProgram(_stencil, _originStencilProgram);
}
#endif
_stencilStateManager->setAlphaThreshold(alphaThreshold);
}
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
#if CC_CLIPPING_NODE_OPENGLES
// since glAlphaTest do not exists in OES, use a shader that writes
// pixel only if greater than an alpha threshold
GLProgram *program = GLProgramCache::getInstance()->getGLProgram(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();
program->setUniformLocationWith1f(alphaValueLocation, alphaThreshold);
// we need to recursively apply this shader to all the nodes in the stencil node
// FIXME: we should have a way to apply shader to all nodes without having to do this
setProgram(_stencil, program);
#endif
}
void StencilStateManager::onAfterDrawStencil()
{
// restore alpha test state
if (_alphaThreshold < 1)
{
#if CC_CLIPPING_NODE_OPENGLES
// FIXME: we need to find a way to restore the shaders of the stencil node and its children
#else
// manually restore the alpha test state
glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef);
if (!_currentAlphaTestEnabled)
{
glDisable(GL_ALPHA_TEST);
}
#endif
}
}
@xiaofeng11 i hava tested cocos2dx v3.8, v3.10 using Language c++ , it works in pc but not work in android After create a new project and copying the code , you can Repetition of this problem. Thanks
code: