Convert shaders in dali-demo to use shader compilation tool
[platform/core/uifw/dali-demo.git] / examples / color-transition / shaders / color-transition-controller-composite.vert
1 precision mediump float;
2
3 // <DALI>
4 uniform mat4 uMvpMatrix;
5 uniform vec3 uSize;
6 // </DALI>
7
8 uniform float uFlow;
9 uniform vec4 uUvTransform; // rotation, scale (initial, target))
10
11 attribute vec2 aPosition;
12
13 varying vec2 vUv;
14 varying vec2 vUvFlow;
15
16 void main()
17 {
18   vec4 position = uMvpMatrix * vec4(aPosition * uSize.xy, 0., 1.);
19
20   gl_Position = position;
21
22   vec2 uv = position.xy / (position.ww * 2.);
23   vUv = uv + vec2(.5);
24
25   float alpha = uFlow * .5 + .5;
26   vec2 uvRotationScale = mix(uUvTransform.xy, uUvTransform.zw, alpha);
27   float c = cos(uvRotationScale.x) * uvRotationScale.y;
28   float s = sin(uvRotationScale.x) * uvRotationScale.y;
29   vec4 uvMatrix = vec4(c, -s, s, c);
30   uv = vec2(dot(uvMatrix.xy, uv), dot(uvMatrix.zw, uv));
31
32   // N.B. +y is down which is well aligned with the inverted y of the off-screen render,
33   // however we need to flip the y of the uvs for the flow map.
34   vUvFlow = vec2(uv.x + .5, .5 - uv.y);
35 }