3 layout(location=0) in vec2 aPosition;
4 layout(location=0) out vec2 vTexCoord;
6 // using specialization constants
7 layout(constant_id = 0) const int FACTOR_SIZE_X = 4;
8 layout(constant_id = 1) const int FACTOR_SIZE_Y = 4;
10 layout(set=0, binding=0, std140) uniform VertData
14 vec2 uNinePatchFactorsX[ FACTOR_SIZE_X ];
15 vec2 uNinePatchFactorsY[ FACTOR_SIZE_Y ];
17 //Visual size and offset
27 vec2 fixedFactor = vec2( uNinePatchFactorsX[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uNinePatchFactorsY[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].x );
28 vec2 stretch = vec2( uNinePatchFactorsX[ int( ( aPosition.x ) * 0.5 ) ].y, uNinePatchFactorsY[ int( ( aPosition.y ) * 0.5 ) ].y );
30 vec2 fixedTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );
31 vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );
34 vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
35 vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
37 vec4 vertexPosition = vec4( ( fixedFactor + ( visualSize.xy - fixedTotal ) * stretch / stretchTotal ) + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
38 vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );
40 vertexPosition = uMvpMatrix * vertexPosition;
42 vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );
44 gl_Position = vertexPosition;