2019-06-05 20:20:12 -04:00
|
|
|
// pathfinder/shaders/tile_alpha_vertex.inc.glsl
|
2019-01-14 22:32:53 -05:00
|
|
|
//
|
2019-03-22 17:28:18 -04:00
|
|
|
// Copyright © 2019 The Pathfinder Project Developers.
|
2019-01-14 22:32:53 -05:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
uniform vec2 uFramebufferSize;
|
|
|
|
uniform vec2 uTileSize;
|
|
|
|
uniform vec2 uStencilTextureSize;
|
|
|
|
uniform vec2 uViewBoxOrigin;
|
|
|
|
|
|
|
|
in vec2 aTessCoord;
|
2019-04-15 16:21:24 -04:00
|
|
|
in uvec3 aTileOrigin;
|
2019-01-14 22:32:53 -05:00
|
|
|
in int aBackdrop;
|
2019-04-15 16:21:24 -04:00
|
|
|
in uint aTileIndex;
|
2019-01-14 22:32:53 -05:00
|
|
|
|
|
|
|
out vec2 vTexCoord;
|
|
|
|
out float vBackdrop;
|
|
|
|
out vec4 vColor;
|
|
|
|
|
2019-05-14 17:28:21 -04:00
|
|
|
vec4 getColor();
|
2019-03-22 17:28:18 -04:00
|
|
|
|
2019-01-14 22:32:53 -05:00
|
|
|
vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth) {
|
|
|
|
uint tilesPerRow = uint(stencilTextureWidth / uTileSize.x);
|
|
|
|
uvec2 tileOffset = uvec2(tileIndex % tilesPerRow, tileIndex / tilesPerRow);
|
|
|
|
return vec2(tileOffset) * uTileSize;
|
|
|
|
}
|
|
|
|
|
2019-03-22 17:28:18 -04:00
|
|
|
void computeVaryings() {
|
2019-04-15 16:21:24 -04:00
|
|
|
vec2 origin = vec2(aTileOrigin.xy) + vec2(aTileOrigin.z & 15u, aTileOrigin.z >> 4u) * 256.0;
|
|
|
|
vec2 pixelPosition = (origin + aTessCoord) * uTileSize + uViewBoxOrigin;
|
2019-02-18 16:42:30 -05:00
|
|
|
vec2 position = (pixelPosition / uFramebufferSize * 2.0 - 1.0) * vec2(1.0, -1.0);
|
2019-05-14 17:28:21 -04:00
|
|
|
vec2 maskTexCoordOrigin = computeTileOffset(aTileIndex, uStencilTextureSize.x);
|
|
|
|
vec2 maskTexCoord = maskTexCoordOrigin + aTessCoord * uTileSize;
|
2019-02-18 16:42:30 -05:00
|
|
|
|
2019-05-14 17:28:21 -04:00
|
|
|
vTexCoord = maskTexCoord / uStencilTextureSize;
|
2019-01-14 22:32:53 -05:00
|
|
|
vBackdrop = float(aBackdrop);
|
2019-05-14 17:28:21 -04:00
|
|
|
vColor = getColor();
|
2019-02-19 15:03:02 -05:00
|
|
|
gl_Position = vec4(position, 0.0, 1.0);
|
2019-01-14 22:32:53 -05:00
|
|
|
}
|
2019-03-22 17:28:18 -04:00
|
|
|
|