[Vulkan] Shaders moved to toolkit, primitive and scrolling shaders
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / graphics / shaders / image-visual-shader.vert
1 #version 430
2
3 layout( location = 0 ) in vec2 aPosition;
4
5 layout( set = 0, binding = 0, std140 ) uniform vertData
6 {
7     mat4 uModelMatrix;  // 0
8     mat4 uViewMatrix;   // 64
9     mat4 uProjection;   // 128
10     vec3 uSize;         // 192
11     vec4 pixelArea;     // 204
12     float uPixelAligned; // 220
13
14     //Visual size and offset
15     vec2 offset; // 224
16     vec2 size; // 232
17     vec4 offsetSizeMode; // 240
18     vec2 origin; // 256
19     vec2 anchorPoint; // 264
20     // 272
21 };
22
23 layout( location = 0 ) out vec2 vTexCoord;
24
25 vec4 ComputeVertexPosition()
26 {
27     vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
28     vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
29     return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
30 }
31
32 void main()
33 {
34     vec4 vertexPosition = uViewMatrix * uModelMatrix * ComputeVertexPosition();
35     vec4 alignedVertexPosition = vertexPosition;
36     alignedVertexPosition.xy = floor ( vertexPosition.xy ); // Pixel alignment
37     vertexPosition = uProjection * mix( vertexPosition, alignedVertexPosition, uPixelAligned );
38     vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );
39     gl_Position = vertexPosition;
40 }