[Vulkan] Builtin shaders and shaders offline compilation script
[platform/core/uifw/dali-core.git] / dali / graphics / vulkan / shaders / npatch-visual-3x3-shader.vert
1 #version 430
2
3 layout(location=0) in vec2 aPosition;
4 layout(location=0) out vec2 vTexCoord;
5
6 layout(set = 0, binding = 0, std140) uniform VertData
7 {
8     mat4 uModelMatrix;
9     mat4 uMvpMatrix;
10     vec3 uSize;
11     vec2 uFixed[ 3 ];
12     vec2 uStretchTotal;
13
14
15     //Visual size and offset
16     vec2 offset;
17     vec2 size;
18     vec4 offsetSizeMode;
19     vec2 origin;
20     vec2 anchorPoint;
21 };
22
23 void main()
24 {
25   vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
26   vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
27
28   vec2 size         = visualSize.xy;
29
30   vec2 fixedFactor  = vec2( uFixed[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uFixed[ int( ( aPosition.y  + 1.0 ) * 0.5 ) ].y );
31   vec2 stretch      = floor( aPosition * 0.5 );
32   vec2 fixedTotal   = uFixed[ 2 ];
33
34   vec4 vertexPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );
35   vertexPosition.xy -= size * vec2( 0.5, 0.5 );
36   vertexPosition.xy =  vertexPosition.xy + anchorPoint*size + (visualOffset + origin)*uSize.xy;\
37
38   vertexPosition = uMvpMatrix * vertexPosition;
39
40   vTexCoord = ( fixedFactor + stretch * uStretchTotal ) / ( fixedTotal + uStretchTotal );
41
42   gl_Position = vertexPosition;
43 }