@@ -12,7 +12,6 @@ cbuffer ConstBuffer : register(b0)
12
12
float4 gammaRatios;
13
13
float enhancedContrast;
14
14
float underlineWidth;
15
- float doubleUnderlineWidth;
16
15
float curlyLineHalfHeight;
17
16
float shadedGlyphDotSize;
18
17
}
@@ -171,19 +170,15 @@ Output main(PSData data) : SV_Target
171
170
}
172
171
case SHADING_TYPE_CURLY_LINE:
173
172
{
174
- // The curly line has the same thickness as a double underline.
175
- // We halve it to make the math a bit easier.
176
- float strokeWidthHalf = doubleUnderlineWidth * data.renditionScale.y * 0.5f ;
173
+ // The curly line has the same thickness as an underline.
174
+ // We halve it to get the stroke width and make the math a bit easier.
175
+ float strokeWidthHalf = underlineWidth * data.renditionScale.y * 0.5f ;
177
176
float center = curlyLineHalfHeight * data.renditionScale.y;
178
177
float amplitude = center - strokeWidthHalf;
179
- // We multiply the frequency by pi/2 to get a sine wave which has an integer period.
180
- // This makes every period of the wave look exactly the same.
181
- float frequency = 1.57079632679489661923f / (curlyLineHalfHeight * data.renditionScale.x);
182
- // At very small sizes, like when the wave is just 3px tall and 1px wide, it'll look too fat and/or blurry.
183
- // Because we multiplied our frequency with pi, the extrema of the curve and its intersections with the
184
- // centerline always occur right between two pixels. This causes both to be lit with the same color.
185
- // By adding a small phase shift, we can break this symmetry up. It'll make the wave look a lot more crispy.
186
- float phase = 1.57079632679489661923f ;
178
+ // This calculates a frequency that results in one 1 period per cell.
179
+ float frequency = (4.0f * 1.57079632679489661923f ) / (backgroundCellSize.x * data.renditionScale.x);
180
+ // This shifts the wave so that the peak is in the middle of the cell.
181
+ float phase = 3.0f * 1.57079632679489661923f ;
187
182
float sine = sin (data.position.x * frequency + phase);
188
183
// We use the distance to the sine curve as its alpha value - the closer the more opaque.
189
184
// To give it a smooth appearance we don't want to simply calculate the vertical distance to the curve:
0 commit comments