2017-08-16 22:51:13 -04:00
|
|
|
// pathfinder/shaders/gles2/ecaa-cover.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-16 22:51:13 -04:00
|
|
|
|
|
|
|
precision highp float;
|
|
|
|
|
2017-09-12 22:43:43 -04:00
|
|
|
uniform vec4 uTransformST;
|
2017-10-05 22:14:52 -04:00
|
|
|
uniform vec4 uHints;
|
2017-08-16 22:51:13 -04:00
|
|
|
uniform ivec2 uFramebufferSize;
|
|
|
|
uniform ivec2 uBVertexPositionDimensions;
|
2017-08-17 15:47:50 -04:00
|
|
|
uniform ivec2 uBVertexPathIDDimensions;
|
2017-08-22 21:25:32 -04:00
|
|
|
uniform ivec2 uPathTransformDimensions;
|
2017-08-16 22:51:13 -04:00
|
|
|
uniform sampler2D uBVertexPosition;
|
2017-08-17 15:47:50 -04:00
|
|
|
uniform sampler2D uBVertexPathID;
|
2017-08-22 21:25:32 -04:00
|
|
|
uniform sampler2D uPathTransform;
|
2017-08-16 22:51:13 -04:00
|
|
|
|
|
|
|
attribute vec2 aQuadPosition;
|
2017-08-17 23:09:18 -04:00
|
|
|
attribute vec4 aUpperPointIndices;
|
|
|
|
attribute vec4 aLowerPointIndices;
|
2017-08-16 22:51:13 -04:00
|
|
|
|
|
|
|
varying vec2 vHorizontalExtents;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
// Fetch B-vertex positions.
|
2017-08-17 23:09:18 -04:00
|
|
|
ivec4 pointIndices = ivec4(unpackUInt32Attribute(aUpperPointIndices.xy),
|
|
|
|
unpackUInt32Attribute(aUpperPointIndices.zw),
|
|
|
|
unpackUInt32Attribute(aLowerPointIndices.xy),
|
|
|
|
unpackUInt32Attribute(aLowerPointIndices.zw));
|
2017-08-16 22:51:13 -04:00
|
|
|
vec2 upperLeftPosition = fetchFloat2Data(uBVertexPosition,
|
|
|
|
pointIndices.x,
|
|
|
|
uBVertexPositionDimensions);
|
|
|
|
vec2 upperRightPosition = fetchFloat2Data(uBVertexPosition,
|
|
|
|
pointIndices.y,
|
|
|
|
uBVertexPositionDimensions);
|
|
|
|
vec2 lowerLeftPosition = fetchFloat2Data(uBVertexPosition,
|
|
|
|
pointIndices.z,
|
|
|
|
uBVertexPositionDimensions);
|
|
|
|
vec2 lowerRightPosition = fetchFloat2Data(uBVertexPosition,
|
|
|
|
pointIndices.w,
|
|
|
|
uBVertexPositionDimensions);
|
|
|
|
|
2017-10-05 16:30:32 -04:00
|
|
|
upperLeftPosition.y = min(upperLeftPosition.y, upperRightPosition.y);
|
|
|
|
lowerRightPosition.y = max(lowerLeftPosition.y, lowerRightPosition.y);
|
|
|
|
|
2017-08-22 21:25:32 -04:00
|
|
|
int pathID = fetchUInt16Data(uBVertexPathID, pointIndices.x, uBVertexPathIDDimensions);
|
|
|
|
|
|
|
|
vec4 transform = fetchFloat4Data(uPathTransform, pathID, uPathTransformDimensions);
|
|
|
|
|
2017-10-05 22:14:52 -04:00
|
|
|
upperLeftPosition = hintPosition(upperLeftPosition, uHints);
|
|
|
|
lowerRightPosition = hintPosition(lowerRightPosition, uHints);
|
2017-09-09 16:12:51 -04:00
|
|
|
|
2017-08-22 21:25:32 -04:00
|
|
|
upperLeftPosition = transformVertexPositionST(upperLeftPosition, transform);
|
|
|
|
lowerRightPosition = transformVertexPositionST(lowerRightPosition, transform);
|
2017-08-16 22:51:13 -04:00
|
|
|
|
2017-09-12 22:43:43 -04:00
|
|
|
upperLeftPosition = transformVertexPositionST(upperLeftPosition, uTransformST);
|
|
|
|
lowerRightPosition = transformVertexPositionST(lowerRightPosition, uTransformST);
|
|
|
|
|
|
|
|
upperLeftPosition = convertClipToScreenSpace(upperLeftPosition, uFramebufferSize);
|
|
|
|
lowerRightPosition = convertClipToScreenSpace(lowerRightPosition, uFramebufferSize);
|
|
|
|
|
2017-10-05 16:30:32 -04:00
|
|
|
vec4 roundedExtents = vec4(floor(upperLeftPosition), ceil(lowerRightPosition));
|
2017-08-16 22:51:13 -04:00
|
|
|
|
2017-08-23 22:18:24 -04:00
|
|
|
vec2 position = mix(roundedExtents.xy, roundedExtents.zw, aQuadPosition);
|
2017-08-16 22:51:13 -04:00
|
|
|
position = convertScreenToClipSpace(position, uFramebufferSize);
|
2017-08-23 22:18:24 -04:00
|
|
|
float depth = convertPathIndexToViewportDepthValue(pathID);
|
2017-08-16 22:51:13 -04:00
|
|
|
gl_Position = vec4(position, depth, 1.0);
|
|
|
|
|
2017-10-05 16:30:32 -04:00
|
|
|
vHorizontalExtents = vec2(upperLeftPosition.x, lowerRightPosition.x);
|
2017-08-16 22:51:13 -04:00
|
|
|
}
|