mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-05 11:02:40 +08:00
Merge pull request #409 from knoxHuang/v1.3
reset stencil program when alpha threshold is set to 1
This commit is contained in:
@@ -57,6 +57,7 @@ static void setProgram(Node *n, GLProgram *p)
|
||||
ClippingNode::ClippingNode()
|
||||
: _stencil(nullptr)
|
||||
,_stencilStateManager(new StencilStateManager())
|
||||
,_originStencilProgram(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -228,7 +229,6 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
|
||||
// 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
|
||||
|
||||
}
|
||||
@@ -315,6 +315,9 @@ void ClippingNode::setStencil(Node *stencil)
|
||||
_stencil->onEnterTransitionDidFinish();
|
||||
}
|
||||
}
|
||||
|
||||
if (_stencil != nullptr)
|
||||
_originStencilProgram = _stencil->getGLProgram();
|
||||
}
|
||||
|
||||
bool ClippingNode::hasContent() const
|
||||
@@ -329,6 +332,14 @@ GLfloat ClippingNode::getAlphaThreshold() const
|
||||
|
||||
void ClippingNode::setAlphaThreshold(GLfloat alphaThreshold)
|
||||
{
|
||||
#if CC_CLIPPING_NODE_OPENGLES
|
||||
if (alphaThreshold == 1 && alphaThreshold != _stencilStateManager->getAlphaThreshold())
|
||||
{
|
||||
// should reset program used by _stencil
|
||||
setProgram(_stencil, _originStencilProgram);
|
||||
}
|
||||
#endif
|
||||
|
||||
_stencilStateManager->setAlphaThreshold(alphaThreshold);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
protected:
|
||||
Node* _stencil;
|
||||
GLProgram* _originStencilProgram;
|
||||
|
||||
StencilStateManager* _stencilStateManager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user