@@ -391,6 +391,7 @@ float4 main(PSInput input) : SV_TARGET
391391 // figure out local alpha with sdf
392392 if (objType == ObjectType::LINE || objType == ObjectType::QUAD_BEZIER || objType == ObjectType::POLYLINE_CONNECTOR)
393393 {
394+ float distance = nbl::hlsl::numeric_limits<float >::max ;
394395 if (objType == ObjectType::LINE)
395396 {
396397 const float2 start = input.getLineStart ();
@@ -406,7 +407,6 @@ float4 main(PSInput input) : SV_TARGET
406407
407408 LineStyle style = lineStyles[styleIdx];
408409
409- float distance;
410410 if (!style.hasStipples () || stretch == InvalidStyleStretchValue)
411411 {
412412 distance = ClippedSignedDistance< nbl::hlsl::shapes::Line<float > >::sdf (lineSegment, input.position.xy, thickness, style.isRoadStyleFlag);
@@ -416,9 +416,6 @@ float4 main(PSInput input) : SV_TARGET
416416 LineStyleClipper clipper = LineStyleClipper::construct (lineStyles[styleIdx], lineSegment, arcLenCalc, phaseShift, stretch, worldToScreenRatio);
417417 distance = ClippedSignedDistance<nbl::hlsl::shapes::Line<float >, LineStyleClipper>::sdf (lineSegment, input.position.xy, thickness, style.isRoadStyleFlag, clipper);
418418 }
419-
420- const float antiAliasingFactor = globals.antiAliasingFactor;
421- localAlpha = 1.0f - smoothstep (-antiAliasingFactor, +antiAliasingFactor, distance);
422419 }
423420 else if (objType == ObjectType::QUAD_BEZIER)
424421 {
@@ -432,7 +429,6 @@ float4 main(PSInput input) : SV_TARGET
432429 const float worldToScreenRatio = input.getCurrentWorldToScreenRatio ();
433430
434431 LineStyle style = lineStyles[styleIdx];
435- float distance;
436432 if (!style.hasStipples () || stretch == InvalidStyleStretchValue)
437433 {
438434 distance = ClippedSignedDistance< nbl::hlsl::shapes::Quadratic<float > >::sdf (quadratic, input.position.xy, thickness, style.isRoadStyleFlag);
@@ -442,24 +438,20 @@ float4 main(PSInput input) : SV_TARGET
442438 BezierStyleClipper clipper = BezierStyleClipper::construct (lineStyles[styleIdx], quadratic, arcLenCalc, phaseShift, stretch, worldToScreenRatio);
443439 distance = ClippedSignedDistance<nbl::hlsl::shapes::Quadratic<float >, BezierStyleClipper>::sdf (quadratic, input.position.xy, thickness, style.isRoadStyleFlag, clipper);
444440 }
445-
446- const float antiAliasingFactor = globals.antiAliasingFactor;
447- localAlpha = 1.0f - smoothstep (-antiAliasingFactor, +antiAliasingFactor, distance);
448441 }
449442 else if (objType == ObjectType::POLYLINE_CONNECTOR)
450443 {
451444 const float2 P = input.position.xy - input.getPolylineConnectorCircleCenter ();
452- const float distance = miterSDF (
445+ distance = miterSDF (
453446 P,
454447 input.getLineThickness (),
455448 input.getPolylineConnectorTrapezoidStart (),
456449 input.getPolylineConnectorTrapezoidEnd (),
457450 input.getPolylineConnectorTrapezoidLongBase (),
458451 input.getPolylineConnectorTrapezoidShortBase ());
459452
460- const float antiAliasingFactor = globals.antiAliasingFactor;
461- localAlpha = 1.0f - smoothstep (-antiAliasingFactor, +antiAliasingFactor, distance);
462453 }
454+ localAlpha = smoothstep (+globals.antiAliasingFactor, -globals.antiAliasingFactor, distance);
463455 }
464456 else if (objType == ObjectType::CURVE_BOX)
465457 {
@@ -567,7 +559,6 @@ float4 main(PSInput input) : SV_TARGET
567559
568560 const float dist = sqrt (closestDistanceSquared);
569561 localAlpha = 1.0f - smoothstep (0.0 , globals.antiAliasingFactor, dist);
570-
571562 }
572563
573564 LineStyle style = lineStyles[mainObjects[currentMainObjectIdx].styleIdx];
@@ -576,7 +567,7 @@ float4 main(PSInput input) : SV_TARGET
576567 {
577568 float3 msdfSample = msdfTextures.Sample (msdfSampler, float3 (frac (input.position.xy / HatchFillMSDFSceenSpaceSize), float (textureId))).xyz;
578569 float msdf = nbl::hlsl::text::msdfDistance (msdfSample, MSDFPixelRange, HatchFillMSDFSceenSpaceSize / MSDFSize);
579- localAlpha = smoothstep (- globals.antiAliasingFactor / 2.0 , + globals.antiAliasingFactor / 2.0f , msdf);
570+ localAlpha = smoothstep (+ globals.antiAliasingFactor / 2.0 , - globals.antiAliasingFactor / 2.0f , msdf);
580571 }
581572 }
582573 else if (objType == ObjectType::FONT_GLYPH)
@@ -591,7 +582,7 @@ float4 main(PSInput input) : SV_TARGET
591582
592583 // localAlpha = smoothstep(-globals.antiAliasingFactor, 0.0, msdf);
593584 // IDK why but it looks best if aa is done on the inside of the shape too esp for curved and diagonal shapes, it may make the shape a tiny bit thinner but worth it
594- localAlpha = smoothstep (- globals.antiAliasingFactor, + globals.antiAliasingFactor, msdf);
585+ localAlpha = smoothstep (+ globals.antiAliasingFactor, - globals.antiAliasingFactor, msdf);
595586 }
596587 }
597588 else if (objType == ObjectType::IMAGE)
0 commit comments