attribute vec4 a_Position;
attribute vec4 a_TexCoordinate;
uniform mat4 mMatrix;
uniform mat4 mTextureMatrix;
varying vec4 v_TexCoord;
void main()
{
v_TexCoord = mTextureMatrix * a_TexCoordinate;
gl_Position = mMatrix * a_Position;
}
1
2
3
4
5
6
7
8
9
10
11
12
增加mTextureMatrix纹理矩阵,mTextureMatrix作用在纹理坐标上。
片段shader修改如下:
#extension GL_OES_EGL_image_external : require
precision mediump float;
uniform samplerExternalOES u_Texture;
varying vec4 v_TexCoord;
void main()
{
gl_FragColor = texture2D(u_Texture, v_TexCoord.xy);
}
1
2
3
4
5
6
7
8
9
10
v_TexCoord类型由vec2变为vec4,采样的时候使用v_TexCoord.xy。
获取mTextureMatrix纹理矩阵参数句柄,代码如下: