In multicolor XCAA, cap the slope to a reasonable amount to prevent line segments from shooting way up or down

This commit is contained in:
Patrick Walton 2017-12-19 13:47:57 -08:00
parent ddd1c89294
commit 097e909d07
2 changed files with 15 additions and 11 deletions

View File

@ -145,7 +145,7 @@ vec2 computeMCAASnappedPosition(vec2 position,
vec4 localTransformST,
vec4 globalTransformST,
ivec2 framebufferSize,
float tanTheta) {
float slope) {
position = hintPosition(position, hints);
position = transformVertexPositionST(position, localTransformST);
position = transformVertexPositionST(position, globalTransformST);
@ -157,10 +157,7 @@ vec2 computeMCAASnappedPosition(vec2 position,
else
xNudge = 1.0 - xNudge;
position.x += xNudge;
position.y += xNudge * tanTheta;
return position;
return position + vec2(xNudge, xNudge * slope);
}
bool computeMCAAQuadPosition(out vec2 outPosition,

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#define MAX_SLOPE 10.0
precision highp float;
uniform vec4 uTransformST;
@ -44,8 +46,13 @@ void main() {
vec4 color = fetchFloat4Data(uPathColors, pathID, uPathColorsDimensions);
vec2 topVector = trPosition - tlPosition, bottomVector = brPosition - blPosition;
float topTanTheta = topVector.y / topVector.x;
float bottomTanTheta = bottomVector.y / bottomVector.x;
float topSlope = topVector.y / topVector.x;
float bottomSlope = bottomVector.y / bottomVector.x;
if (abs(topSlope) > MAX_SLOPE)
topSlope = sign(topSlope) * MAX_SLOPE;
if (abs(bottomSlope) > MAX_SLOPE)
bottomSlope = sign(bottomSlope) * MAX_SLOPE;
// Transform the points, and compute the position of this vertex.
tlPosition = computeMCAASnappedPosition(tlPosition,
@ -53,13 +60,13 @@ void main() {
transformST,
uTransformST,
uFramebufferSize,
topTanTheta);
topSlope);
trPosition = computeMCAASnappedPosition(trPosition,
uHints,
transformST,
uTransformST,
uFramebufferSize,
topTanTheta);
topSlope);
tcPosition = computeMCAAPosition(tcPosition,
uHints,
transformST,
@ -70,13 +77,13 @@ void main() {
transformST,
uTransformST,
uFramebufferSize,
bottomTanTheta);
bottomSlope);
brPosition = computeMCAASnappedPosition(brPosition,
uHints,
transformST,
uTransformST,
uFramebufferSize,
bottomTanTheta);
bottomSlope);
bcPosition = computeMCAAPosition(bcPosition,
uHints,
transformST,