2017-08-18 20:12:58 -04:00
|
|
|
// pathfinder/shaders/gles2/ecaa-curve.vs.glsl
|
|
|
|
//
|
2017-10-03 18:32:03 -04:00
|
|
|
// Copyright (c) 2017 The Pathfinder Project Developers.
|
|
|
|
//
|
|
|
|
// 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.
|
2017-08-18 20:12:58 -04:00
|
|
|
|
|
|
|
precision highp float;
|
|
|
|
|
2017-11-23 00:10:51 -05:00
|
|
|
uniform mat4 uTransform;
|
2017-10-05 22:14:52 -04:00
|
|
|
uniform vec4 uHints;
|
2017-08-18 20:12:58 -04:00
|
|
|
uniform ivec2 uFramebufferSize;
|
2017-11-29 13:50:47 -05:00
|
|
|
uniform ivec2 uPathTransformSTDimensions;
|
|
|
|
uniform sampler2D uPathTransformST;
|
|
|
|
uniform ivec2 uPathTransformExtDimensions;
|
|
|
|
uniform sampler2D uPathTransformExt;
|
2017-10-09 17:14:24 -04:00
|
|
|
uniform ivec2 uPathBoundsDimensions;
|
|
|
|
uniform sampler2D uPathBounds;
|
|
|
|
uniform vec2 uEmboldenAmount;
|
2017-08-18 20:12:58 -04:00
|
|
|
|
|
|
|
attribute vec2 aQuadPosition;
|
2017-10-06 19:11:53 -04:00
|
|
|
attribute vec2 aLeftPosition;
|
|
|
|
attribute vec2 aControlPointPosition;
|
|
|
|
attribute vec2 aRightPosition;
|
|
|
|
attribute float aPathID;
|
2017-11-23 00:10:51 -05:00
|
|
|
attribute vec3 aNormalAngles;
|
2017-08-18 20:12:58 -04:00
|
|
|
|
|
|
|
varying vec4 vEndpoints;
|
|
|
|
varying vec2 vControlPoint;
|
2017-10-09 17:14:24 -04:00
|
|
|
varying float vWinding;
|
2017-08-18 20:12:58 -04:00
|
|
|
|
|
|
|
void main() {
|
2017-10-06 19:11:53 -04:00
|
|
|
vec2 leftPosition = aLeftPosition;
|
|
|
|
vec2 controlPointPosition = aControlPointPosition;
|
|
|
|
vec2 rightPosition = aRightPosition;
|
|
|
|
int pathID = int(aPathID);
|
2017-10-09 17:14:24 -04:00
|
|
|
float leftNormalAngle = aNormalAngles.x;
|
|
|
|
float controlPointNormalAngle = aNormalAngles.y;
|
|
|
|
float rightNormalAngle = aNormalAngles.z;
|
2017-08-22 21:25:32 -04:00
|
|
|
|
2017-11-29 13:50:47 -05:00
|
|
|
vec2 pathTransformExt;
|
|
|
|
vec4 pathTransformST = fetchPathAffineTransform(pathTransformExt,
|
|
|
|
uPathTransformST,
|
|
|
|
uPathTransformSTDimensions,
|
|
|
|
uPathTransformExt,
|
|
|
|
uPathTransformExtDimensions,
|
|
|
|
pathID);
|
2017-10-09 17:14:24 -04:00
|
|
|
vec4 bounds = fetchFloat4Data(uPathBounds, pathID, uPathBoundsDimensions);
|
2017-08-22 21:25:32 -04:00
|
|
|
|
2017-08-18 20:12:58 -04:00
|
|
|
// Transform the points, and compute the position of this vertex.
|
|
|
|
vec2 position;
|
2017-10-09 17:14:24 -04:00
|
|
|
float winding;
|
|
|
|
if (computeECAAQuadPosition(position,
|
|
|
|
winding,
|
|
|
|
leftPosition,
|
|
|
|
rightPosition,
|
|
|
|
aQuadPosition,
|
|
|
|
uFramebufferSize,
|
2017-11-29 13:50:47 -05:00
|
|
|
pathTransformST,
|
|
|
|
pathTransformExt,
|
2017-11-23 00:10:51 -05:00
|
|
|
uTransform,
|
2017-10-09 17:14:24 -04:00
|
|
|
uHints,
|
|
|
|
bounds,
|
|
|
|
leftNormalAngle,
|
|
|
|
rightNormalAngle,
|
|
|
|
uEmboldenAmount)) {
|
2017-12-02 16:13:54 -05:00
|
|
|
controlPointPosition = computeECAAPosition(controlPointPosition,
|
|
|
|
controlPointNormalAngle,
|
|
|
|
uEmboldenAmount,
|
|
|
|
uHints,
|
|
|
|
pathTransformST,
|
|
|
|
pathTransformExt,
|
|
|
|
uTransform,
|
|
|
|
uFramebufferSize);
|
2017-08-18 20:12:58 -04:00
|
|
|
}
|
|
|
|
|
2017-08-23 22:18:24 -04:00
|
|
|
float depth = convertPathIndexToViewportDepthValue(pathID);
|
2017-08-18 20:12:58 -04:00
|
|
|
|
|
|
|
gl_Position = vec4(position, depth, 1.0);
|
|
|
|
vEndpoints = vec4(leftPosition, rightPosition);
|
|
|
|
vControlPoint = controlPointPosition;
|
2017-10-09 17:14:24 -04:00
|
|
|
vWinding = winding;
|
2017-08-18 20:12:58 -04:00
|
|
|
}
|