AtlasEngine: Fix curly line rendering on rows with line renditions (#17679)

This fixes several scaling issues with double width/height rows.

## Validation Steps Performed
* Run `RenderTests` 
This commit is contained in:
Leonard Hecker 2024-08-07 22:19:01 +02:00 committed by GitHub
parent 9d0180a554
commit d4c1dad0fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -174,10 +174,11 @@ Output main(PSData data) : SV_Target
// The curly line has the same thickness as a double underline.
// We halve it to make the math a bit easier.
float strokeWidthHalf = doubleUnderlineWidth * data.renditionScale.y * 0.5f;
float amplitude = (curlyLineHalfHeight - strokeWidthHalf) * data.renditionScale.y;
float center = curlyLineHalfHeight * data.renditionScale.y;
float amplitude = center - strokeWidthHalf;
// We multiply the frequency by pi/2 to get a sine wave which has an integer period.
// This makes every period of the wave look exactly the same.
float frequency = data.renditionScale.x / curlyLineHalfHeight * 1.57079632679489661923f;
float frequency = 1.57079632679489661923f / (curlyLineHalfHeight * data.renditionScale.x);
// At very small sizes, like when the wave is just 3px tall and 1px wide, it'll look too fat and/or blurry.
// Because we multiplied our frequency with pi, the extrema of the curve and its intersections with the
// centerline always occur right between two pixels. This causes both to be lit with the same color.
@ -199,7 +200,7 @@ Output main(PSData data) : SV_Target
//
// The expanded sine form of cos(atan(cos(x))) is 1 / sqrt(2 - sin(x)^2), which results in:
// abs(pixel.y - sin(pixel.x)) * rsqrt(2 - sin(pixel.x)^2)
float distance = abs(curlyLineHalfHeight - data.texcoord.y - sine * amplitude) * rsqrt(2 - sine * sine);
float distance = abs(center - data.texcoord.y - sine * amplitude) * rsqrt(2 - sine * sine);
// Since pixel coordinates are always offset by half a pixel (i.e. data.texcoord is 1.5f, 2.5f, 3.5f, ...)
// the distance is also off by half a pixel. We undo that by adding half a pixel to the distance.
// This gives the line its proper thickness appearance.