I update my game to cocos 3.15.1 and my shader don’t work
fraq
const char* qgShaderGlowLine_frag = STRINGIFY(
\n#ifdef GL_ES\n
precision mediump float;
\n#endif\n
uniform vec4 color;
uniform float begPos;
uniform float endPos;
uniform float endPart;
varying vec2 v_texCoord;
void main() {
if (v_texCoord.y < begPos || v_texCoord.y > endPos) {
discard;
}
gl_FragColor = color;
if (v_texCoord.x < 0.45) {
gl_FragColor.a *= 1.4 * v_texCoord.x;
} else if ( v_texCoord.x > 0.55) {
gl_FragColor.a *= 1.4 * (1.0 - v_texCoord.x);
}
if (v_texCoord.y < begPos + endPart) {
float x;
if (v_texCoord.x > 0.5) {
x = v_texCoord.x;
} else {
x = 0.5 - v_texCoord.x;
}
float y = v_texCoord.y - begPos;
float f = ( ((y/endPart/10.0 - 0.1) * x + 0.05)/0.05 ) * pow(y/endPart, 1.0/2.0);
gl_FragColor.a *= f;
}
if (v_texCoord.y > endPos - endPart) {
float x;
if (v_texCoord.x > 0.5) {
x = v_texCoord.x;
} else {
x = 0.5 - v_texCoord.x;
}
float y = - v_texCoord.y + endPos;
float f = ( ((y/endPart/10.0 - 0.1) * x + 0.05)/0.05 ) * pow(y/endPart, 1.0/2.0);
gl_FragColor.a *= f;
}
}
);
vert
const char* qgShaderGlowLine_vert = STRINGIFY(
attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec4 a_color;
\n#ifdef GL_ES\n
varying mediump vec2 v_texCoord;
\n#else\n
varying vec2 v_texCoord;
\n#endif\n
void main()
{
gl_Position = CC_PMatrix * a_position;
v_texCoord = a_texCoord;
}
);
create
line = Sprite::createWithTexture(genEmptyTexture(1, 1));
line->setAnchorPoint(Vec2(0.5, 0.0));
addChild(line);
GLProgram* p = ShaderLoader::createGlowLine();
p->link();
p->updateUniforms();
line->setGLProgram(p);
ShaderLoader::createGlowLine
#include "ShaderLoader.h"
#include "cocos2d.h"
#define STRINGIFY(A) #A
#include "ShaderGlowLine.vert"
#include "ShaderGlowLine.frag"
using namespace qg;
using namespace cocos2d;
cocos2d::GLProgram* ShaderLoader::createGlowLine () {
return GLProgram::createWithByteArrays(qgShaderGlowLine_vert, qgShaderGlowLine_frag);
}
what has changed in 3.15.1?