我有以下片段着色器。当我按下某个按钮时,它会将视频更改为灰色。它有效,但有一个pb:设置着色器后,所有精灵都会向下移动几个像素。看起来整个屏幕在向下的方向上偏移几个像素
#ifdef GL_ES
precision mediump float;
precision mediump int;
#else
#define highp;
#endif
uniform sampler2D u_texture;
varying vec4 v_color;
varying vec2 v_texCoord;
const vec3 grayChange = vec3(0.299*0.4, 0.587*0.4, 0.114*0.4);
void main() {
vec4 texColor = texture2D(u_texture, v_texCoord);
vec3 grayCol = vec3(dot(texColor.rgb, grayChange));
gl_FragColor = vec4(grayCol.r, grayCol.g, grayCol.b, texColor.a * v_color.a);
}
这是顶点着色器:
uniform mat4 U_WORLD_VIEW;
attribute vec4 a_position;
attribute vec2 a_texCoord0;
attribute vec4 a_color;
varying vec4 v_color;
varying vec2 v_texCoord;
void main() {
gl_Position = U_WORLD_VIEW * vec4(a_position.xy,0,1);
v_texCoord = a_texCoord0;
v_color = a_color;
}