Shader compilation tool for dali-toolkit
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / graphics / shaders / image-region-effect.vert
1 attribute mediump vec2 aPosition;
2
3 uniform mediump mat4 uMvpMatrix;
4 uniform vec3 uSize;
5 uniform vec4 uTextureRect;
6
7 varying vec2 vTexCoord;
8
9 uniform mediump vec2 uTopLeft;
10 uniform mediump vec2 uBottomRight;
11
12 void main()
13 {
14   mediump vec4 position = vec4(aPosition, 0.0, 1.0);
15   position.xyz *= uSize;
16   gl_Position = uMvpMatrix * position;
17
18     // The line below is doing the same as the following commented lines:
19     //
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 );
25
26   vec2 texCoord = aPosition + vec2(0.5);
27   vTexCoord = uTextureRect.xy + uTopLeft * ( uTextureRect.zw - uTextureRect.xy ) + ( texCoord - uTextureRect.xy ) * ( uBottomRight - uTopLeft );
28 }