我想将相机预览SurfaceTexture
与一些叠加纹理混合。我正在使用这些着色器进行处理:
private final String vss = "attribute vec2 vPosition;\n"
+ "attribute vec2 vTexCoord;\n"
+ "varying vec2 texCoord;\n"
+ "void main() {\n"
+ " texCoord = vTexCoord;\n"
+ " gl_Position = vec4 ( vPosition.x, vPosition.y, 0.0, 1.0 );\n"
+ "}";
private final String fss = "#extension GL_OES_EGL_image_external : require\n"
+ "precision mediump float;\n"
+ "uniform samplerExternalOES sTexture;\n"
+ "uniform sampler2D filterTexture;\n"
+ "varying vec2 texCoord;\n"
+ "void main() {\n"
+" vec4 t_camera = texture2D(sTexture,texCoord);\n"
//+" vec4 t_overlayer = texture2D(filterTexture, texCoord);\n"
//+ " gl_FragColor = t_overlayer;\n" + "}";
+ " gl_FragColor = t_camera;\n" + "}";
我的目标是混合t_camera
和t_overlayer
. 当我显示t_camera
或t_overlayer
单独显示时,它可以工作(显示相机预览或纹理)。但是当我取消注释时t_overlayer
,就会t_camera
变成黑色(不知何故采样不好)。我的覆盖层纹理是 512x512 和CLAMPT_TO_EDGE
. 此问题仅在以下情况下发生:Android Emulator、HTC Evo 3D。但在 SGS3、HTC One X 上,它工作得很好。
怎么了?是 Evo 3D 缺少一些扩展还是什么?