diff --git a/shaders/gles2/common.inc.glsl b/shaders/gles2/common.inc.glsl index a54bfd11..7ee526b2 100644 --- a/shaders/gles2/common.inc.glsl +++ b/shaders/gles2/common.inc.glsl @@ -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, diff --git a/shaders/gles2/mcaa-multi.vs.glsl b/shaders/gles2/mcaa-multi.vs.glsl index 8e41a259..97e71ba2 100644 --- a/shaders/gles2/mcaa-multi.vs.glsl +++ b/shaders/gles2/mcaa-multi.vs.glsl @@ -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,