1 attribute mediump vec2 aPosition;
3 uniform mediump mat4 uMvpMatrix;
5 uniform vec4 uTextureRect;
7 varying vec2 vTexCoord;
9 uniform mediump vec2 uTopLeft;
10 uniform mediump vec2 uBottomRight;
14 mediump vec4 position = vec4(aPosition, 0.0, 1.0);
15 position.xyz *= uSize;
16 gl_Position = uMvpMatrix * position;
18 // The line below is doing the same as the following commented lines:
20 // vec2 imageSize = uTextureRect.zw - uTextureRect.xy;
21 // vec2 topLeft = uTextureRect.xy + uTopLeft * imageSize;
22 // vec2 bottomRight = uTextureRect.xy + uBottomRight * imageSize;
23 // vec2 texCoord = (aTexCoord - uTextureRect.xy) / imageSize;
24 // vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );
26 vec2 texCoord = aPosition + vec2(0.5);
27 vTexCoord = uTextureRect.xy + uTopLeft * ( uTextureRect.zw - uTextureRect.xy ) + ( texCoord - uTextureRect.xy ) * ( uBottomRight - uTopLeft );