From ddd1c89294e4c3495baf875f0cce1563c60c027d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 19 Dec 2017 10:54:30 -0800 Subject: [PATCH] Use one side for the X position in the multicolor MCAA vertex shader to avoid cracks --- shaders/gles2/common.inc.glsl | 1 - shaders/gles2/mcaa-multi.vs.glsl | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/shaders/gles2/common.inc.glsl b/shaders/gles2/common.inc.glsl index 8283ce2b..a54bfd11 100644 --- a/shaders/gles2/common.inc.glsl +++ b/shaders/gles2/common.inc.glsl @@ -150,7 +150,6 @@ vec2 computeMCAASnappedPosition(vec2 position, position = transformVertexPositionST(position, localTransformST); position = transformVertexPositionST(position, globalTransformST); position = convertClipToScreenSpace(position, framebufferSize); - //position.x = abs(mod(position.x, 1.0)) < 0.5 ? floor(position.x) : ceil(position.x); float xNudge = fract(position.x); if (xNudge < 0.5) diff --git a/shaders/gles2/mcaa-multi.vs.glsl b/shaders/gles2/mcaa-multi.vs.glsl index b96d8af4..8e41a259 100644 --- a/shaders/gles2/mcaa-multi.vs.glsl +++ b/shaders/gles2/mcaa-multi.vs.glsl @@ -85,8 +85,11 @@ void main() { float depth = convertPathIndexToViewportDepthValue(pathID); + // Use the same side--in this case, the top--or else floating point error during partitioning + // can occasionally cause inconsistent rounding, resulting in cracks. vec2 position; - position.x = mix(tlPosition.x, brPosition.x, quadPosition.x); + position.x = quadPosition.x < 0.5 ? tlPosition.x : trPosition.x; + if (quadPosition.y < 0.5) position.y = floor(min(tlPosition.y, trPosition.y)); else