Skip to content

Commit

Permalink
Refactor the XCAA vertex shaders themselves, now that the common XCAA
Browse files Browse the repository at this point in the history
infrastructure has been refactored
  • Loading branch information
pcwalton committed Dec 2, 2017
1 parent dc5e3a0 commit 7e0d003
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 35 deletions.
17 changes: 8 additions & 9 deletions shaders/gles2/ecaa-curve.vs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ void main() {
leftNormalAngle,
rightNormalAngle,
uEmboldenAmount)) {
controlPointPosition = dilatePosition(controlPointPosition,
controlPointNormalAngle,
uEmboldenAmount);
controlPointPosition = hintPosition(controlPointPosition, uHints);
controlPointPosition = transformVertexPositionAffine(controlPointPosition,
pathTransformST,
pathTransformExt);
controlPointPosition = transformVertexPosition(controlPointPosition, uTransform);
controlPointPosition = convertClipToScreenSpace(controlPointPosition, uFramebufferSize);
controlPointPosition = computeECAAPosition(controlPointPosition,
controlPointNormalAngle,
uEmboldenAmount,
uHints,
pathTransformST,
pathTransformExt,
uTransform,
uFramebufferSize);
}

float depth = convertPathIndexToViewportDepthValue(pathID);
Expand Down
10 changes: 5 additions & 5 deletions shaders/gles2/ecaa-multi-edge-mask-curve.vs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ void main() {
pathTransformST,
pathTransformExt,
uTransform)) {
controlPointPosition = transformVertexPositionAffine(controlPointPosition,
pathTransformST,
pathTransformExt);
controlPointPosition = transformVertexPosition(controlPointPosition, uTransform);
controlPointPosition = convertClipToScreenSpace(controlPointPosition, uFramebufferSize);
controlPointPosition = transformECAAPositionToScreenSpace(controlPointPosition,
pathTransformST,
pathTransformExt,
uTransform,
uFramebufferSize);
}

float depth = convertPathIndexToViewportDepthValue(pathID);
Expand Down
31 changes: 14 additions & 17 deletions shaders/gles2/mcaa-cover.vs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,22 @@ void main() {

vec4 transformST = fetchFloat4Data(uPathTransformST, pathID, uPathTransformSTDimensions);

vec2 upperLeftPosition = hintPosition(aUpperLeftPosition, uHints);
vec2 lowerRightPosition = hintPosition(aLowerRightPosition, uHints);
vec2 upperLeftPosition = computeMCAAPosition(aUpperLeftPosition,
uHints,
transformST,
uTransformST,
uFramebufferSize);
vec2 lowerRightPosition = computeMCAAPosition(aLowerRightPosition,
uHints,
transformST,
uTransformST,
uFramebufferSize);

upperLeftPosition = transformVertexPositionST(upperLeftPosition, transformST);
lowerRightPosition = transformVertexPositionST(lowerRightPosition, transformST);

upperLeftPosition = transformVertexPositionST(upperLeftPosition, uTransformST);
lowerRightPosition = transformVertexPositionST(lowerRightPosition, uTransformST);

upperLeftPosition = convertClipToScreenSpace(upperLeftPosition, uFramebufferSize);
lowerRightPosition = convertClipToScreenSpace(lowerRightPosition, uFramebufferSize);

vec4 roundedExtents = vec4(floor(upperLeftPosition.x), ceil(upperLeftPosition.y),
ceil(lowerRightPosition));
vHorizontalExtents = vec2(upperLeftPosition.x, lowerRightPosition.x);

vec2 position = mix(roundedExtents.xy, roundedExtents.zw, aQuadPosition);
position = convertScreenToClipSpace(position, uFramebufferSize);
vec4 extents = vec4(upperLeftPosition.x, ceil(upperLeftPosition.y), lowerRightPosition);
vec2 position = computeXCAAClipSpaceQuadPosition(extents, aQuadPosition, uFramebufferSize);
float depth = convertPathIndexToViewportDepthValue(pathID);
gl_Position = vec4(position, depth, 1.0);

vHorizontalExtents = vec2(upperLeftPosition.x, lowerRightPosition.x);
gl_Position = vec4(position, depth, 1.0);
}
9 changes: 5 additions & 4 deletions shaders/gles2/mcaa-curve.vs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ void main() {
transformST,
uTransformST,
uHints)) {
controlPointPosition = hintPosition(aControlPointPosition, uHints);
controlPointPosition = transformVertexPositionST(controlPointPosition, transformST);
controlPointPosition = transformVertexPositionST(controlPointPosition, uTransformST);
controlPointPosition = convertClipToScreenSpace(controlPointPosition, uFramebufferSize);
controlPointPosition = computeMCAAPosition(controlPointPosition,
uHints,
transformST,
uTransformST,
uFramebufferSize);
}

float depth = convertPathIndexToViewportDepthValue(pathID);
Expand Down

0 comments on commit 7e0d003

Please sign in to comment.