【发布时间】:2014-03-25 21:24:54
【问题描述】:
我正在尝试在 Galaxy Tab 3 上使用我的自定义着色器,但它们无法编译或链接。这是代码。 这是顶点着色器
attribute vec4 a_position;
attribute vec2 a_texCoord;
uniform sampler2D u_texture;
varying vec2 blurs[8];
uniform vec2 blurSize;
#ifdef GL_ES
varying lowp vec2 v_texCoord;
#else
varying vec2 v_texCoord;
#endif
void main()
{
gl_Position = CC_MVPMatrix * a_position;
v_texCoord = a_texCoord;
blurs[0] = v_texCoord + vec2(-0.016, 0.0) * blurSize;
blurs[1] = v_texCoord + vec2(-0.012, 0.0) * blurSize;
blurs[2] = v_texCoord + vec2(-0.008, 0.0) * blurSize;
blurs[3] = v_texCoord + vec2(-0.004, 0.0) * blurSize;
blurs[4] = v_texCoord + vec2( 0.004, 0.0) * blurSize;
blurs[5] = v_texCoord + vec2( 0.008, 0.0) * blurSize;
blurs[6] = v_texCoord + vec2( 0.012, 0.0) * blurSize;
blurs[7] = v_texCoord + vec2( 0.016, 0.0) * blurSize;
}
这是片段着色器
#ifdef GL_ES
precision lowp float;
#endif
varying vec2 v_texCoord;
varying vec2 blurs[8];
uniform sampler2D u_texture;
//uniform vec2 blurSize;
uniform vec4 substract;
void main() {
gl_FragColor = vec4(0.0);
gl_FragColor += texture2D(u_texture, blurs[0])*0.0443;
gl_FragColor += texture2D(u_texture, blurs[1])*0.0776;
gl_FragColor += texture2D(u_texture, blurs[2])*0.1158;
gl_FragColor += texture2D(u_texture, blurs[3])*0.1473;
gl_FragColor += texture2D(u_texture, v_texCoord )*0.1595;
gl_FragColor += texture2D(u_texture, blurs[4])*0.1473;
gl_FragColor += texture2D(u_texture, blurs[5])*0.1158;
gl_FragColor += texture2D(u_texture, blurs[6])*0.0776;
gl_FragColor += texture2D(u_texture, blurs[7])*0.0443;
}
在 ipad、nexus 设备、galaxy s3/s4 和 note 3 中运行良好。但是在galaxy tab 3(使用vivante gc1000 gpu)中无法编译或链接;我不确定哪个失败了。 以下是来自 logcat 的错误:
03-25 20:59:36.328 D/v_gal (3167): [tid=3179] gcmONERROR: status=-10(gcvSTATUS_TOO_COMPLEX) @ _GenerateStates(10194)
03-25 20:59:36.328 D/v_gal (3167): [tid=3179] gcmONERROR: status=-10(gcvSTATUS_TOO_COMPLEX) @ gcLINKTREE_GenerateStates(11342)
03-25 20:59:36.328 D/v_gal (3167): [tid=3179] gcmERR_BREAK: status=-10(gcvSTATUS_TOO_COMPLEX) @ gcLinkShaders(7831)
03-25 20:59:36.328 D/cocos2d-x debug info(3167): cocos2d: ERROR: Failed to link program: 25
03-25 20:59:36.328 D/cocos2d-x debug info(3167): cocos2d: ERROR LOG PROGRAM: (null)
03-25 20:59:36.328 D/v_gal (3167): [tid=3179] gl2mERROR: result=0x0501 @ glGetShaderiv(886)
03-25 20:59:36.328 D/cocos2d-x debug info(3167): cocos2d: ERROR LOG VERTEX: (null)
03-25 20:59:36.328 D/v_gal (3167): [tid=3179] gl2mERROR: result=0x0501 @ glGetShaderiv(886)
03-25 20:59:36.328 D/cocos2d-x debug info(3167): cocos2d: ERROR LOG FRAG: (null)
ERROR LOG PROGRAM、ERROR LOG VERTEX、ERROR LOG FRAG 是对 glGetProgramInfoLog 和 glGetShaderInfoLog 的调用。他们都返回null
【问题讨论】:
-
安德烈斯,这种模糊对你有用吗?我假设垂直模糊还有第二遍,对吧?有截图吗?
标签: android opengl-es cocos2d-x