What is the proper way to disable a custom shader?

What is the proper way to disable a custom shader?
0

#1

I have a script that loads a custom shader in order to achieve a certain effect on my sprites, but I’d like to be able to enable/disable it at will. What would be the proper way to disable it?

I’m currently using a default shader when I want to disable the effects like follows:

varying vec2 v_texCoord;
varying vec4 v_fragmentColor;

void main() {
  vec4 textureColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord).rgba;
  gl_FragColor = textureColor;
}

Is there a simpler way to go back to the default shader rather than writing my own and using it?


#2

See if anyone still need this:

use the following line to “disable”
sprite._sgNode.setState(0);

Not the best method, but it works. See if there are any other better method