Browse Source

Version 1.13

Chlumsky 2 weeks ago
parent
commit
1874bcf7d9
7 changed files with 23 additions and 15 deletions
  1. 13 0
      CHANGELOG.md
  2. 5 1
      README.md
  3. 0 10
      core/MSDFErrorCorrection.cpp
  4. 1 1
      core/contour-combiners.cpp
  5. 2 1
      core/edge-selectors.cpp
  6. 1 1
      main.cpp
  7. 1 1
      vcpkg.json

+ 13 - 0
CHANGELOG.md

@@ -1,4 +1,17 @@
 
 
+## Version 1.13 (2025-11-30)
+
+- Improved BMP file output - support for BGRA (`mtsdf` mode), optimized size of grayscale files
+    - For builds without PNG support, BMP replaces TIFF as the default output format
+- Fixed incorrect output with asymmetrical distance range when inversion occurs due to winding correction (`-guesswinding` / `-reversewinding`) or scanline pass (`-scanline`)
+- The library now operates on bitmap section references (instead of contiguous bitmap references), which makes it possible to generate a distance field directly into a subsection of a larger bitmap or a bitmap with the opposite row ordering
+- Improved semantics of specifying Y-axis orientation (upward / downward)
+- Improved precision of cubic curve distance computation
+- Fixed a bug incorrectly adjusting convergent edge segments in shape normalization
+- Renamed options `-guesswinding`, `-reversewinding`, `-keepwinding` from `-guessorder`, ... for clarity (old names kept for compatibility)
+- Adjusted the Readme example shader to improve anti-aliasing in a rotated frame
+- Minor CMake fixes
+
 ### Version 1.12.1 (2025-05-31)
 ### Version 1.12.1 (2025-05-31)
 
 
 - Fixed a bug applying error correction incorrectly if shape's Y-axis is inverted (mainly affected SVG input)
 - Fixed a bug applying error correction incorrectly if shape's Y-axis is inverted (mainly affected SVG input)

+ 5 - 1
README.md

@@ -184,9 +184,13 @@ I would suggest precomputing `unitRange` as a uniform variable instead of `pxRan
 ```glsl
 ```glsl
 uniform float pxRange; // set to distance field's pixel range
 uniform float pxRange; // set to distance field's pixel range
 
 
+vec2 sqr(vec2 x) { return x*x; } // squares vector components
+
 float screenPxRange() {
 float screenPxRange() {
     vec2 unitRange = vec2(pxRange)/vec2(textureSize(msdf, 0));
     vec2 unitRange = vec2(pxRange)/vec2(textureSize(msdf, 0));
-    vec2 screenTexSize = vec2(1.0)/fwidth(texCoord);
+    // If inversesqrt is not available, use vec2(1.0)/sqrt
+    vec2 screenTexSize = inversesqrt(sqr(dFdx(texCoord))+sqr(dFdy(texCoord)));
+    // Can also be approximated as screenTexSize = vec2(1.0)/fwidth(texCoord);
     return max(0.5*dot(unitRange, screenTexSize), 1.0);
     return max(0.5*dot(unitRange, screenTexSize), 1.0);
 }
 }
 ```
 ```

+ 0 - 10
core/MSDFErrorCorrection.cpp

@@ -274,16 +274,6 @@ static float interpolatedMedian(const float *a, const float *l, const float *q,
     ));
     ));
 }
 }
 
 
-/// Determines if the interpolated median xm is an artifact.
-static bool isArtifact(bool isProtected, double axSpan, double bxSpan, float am, float bm, float xm) {
-    return (
-        // For protected texels, only report an artifact if it would cause fill inversion (change between positive and negative distance).
-        (!isProtected || (am > .5f && bm > .5f && xm <= .5f) || (am < .5f && bm < .5f && xm >= .5f)) &&
-        // This is an artifact if the interpolated median is outside the range of possible values based on its distance from a, b.
-        !(xm >= am-axSpan && xm <= am+axSpan && xm >= bm-bxSpan && xm <= bm+bxSpan)
-    );
-}
-
 /// Checks if a linear interpolation artifact will occur at a point where two specific color channels are equal - such points have extreme median values.
 /// Checks if a linear interpolation artifact will occur at a point where two specific color channels are equal - such points have extreme median values.
 template <class ArtifactClassifier>
 template <class ArtifactClassifier>
 static bool hasLinearArtifactInner(const ArtifactClassifier &artifactClassifier, float am, float bm, const float *a, const float *b, float dA, float dB) {
 static bool hasLinearArtifactInner(const ArtifactClassifier &artifactClassifier, float am, float bm, const float *a, const float *b, float dA, float dB) {

+ 1 - 1
core/contour-combiners.cpp

@@ -32,7 +32,7 @@ static double resolveDistance(const MultiDistance &distance) {
 }
 }
 
 
 template <class EdgeSelector>
 template <class EdgeSelector>
-SimpleContourCombiner<EdgeSelector>::SimpleContourCombiner(const Shape &shape) { }
+SimpleContourCombiner<EdgeSelector>::SimpleContourCombiner(const Shape &) { }
 
 
 template <class EdgeSelector>
 template <class EdgeSelector>
 void SimpleContourCombiner<EdgeSelector>::reset(const Point2 &p) {
 void SimpleContourCombiner<EdgeSelector>::reset(const Point2 &p) {

+ 2 - 1
core/edge-selectors.cpp

@@ -11,6 +11,7 @@ TrueDistanceSelector::EdgeCache::EdgeCache() : absDistance(0) { }
 
 
 void TrueDistanceSelector::reset(const Point2 &p) {
 void TrueDistanceSelector::reset(const Point2 &p) {
     double delta = DISTANCE_DELTA_FACTOR*(p-this->p).length();
     double delta = DISTANCE_DELTA_FACTOR*(p-this->p).length();
+    // Since minDistance.distance is initialized to -DBL_MAX, at first glance this seems like it could make it underflow to -infinity, but in practice delta would have to be extremely high for this to happen (above 9e291)
     minDistance.distance += nonZeroSign(minDistance.distance)*delta;
     minDistance.distance += nonZeroSign(minDistance.distance)*delta;
     this->p = p;
     this->p = p;
 }
 }
@@ -60,7 +61,7 @@ void PerpendicularDistanceSelectorBase::reset(double delta) {
     nearEdgeParam = 0;
     nearEdgeParam = 0;
 }
 }
 
 
-bool PerpendicularDistanceSelectorBase::isEdgeRelevant(const EdgeCache &cache, const EdgeSegment *edge, const Point2 &p) const {
+bool PerpendicularDistanceSelectorBase::isEdgeRelevant(const EdgeCache &cache, const EdgeSegment *, const Point2 &p) const {
     double delta = DISTANCE_DELTA_FACTOR*(p-cache.point).length();
     double delta = DISTANCE_DELTA_FACTOR*(p-cache.point).length();
     return (
     return (
         cache.absDistance-delta <= fabs(minTrueDistance.distance) ||
         cache.absDistance-delta <= fabs(minTrueDistance.distance) ||

+ 1 - 1
main.cpp

@@ -361,7 +361,7 @@ static const char *writeOutput(const BitmapConstSection<float, N> &bitmap, const
 
 
 static const char *const versionText =
 static const char *const versionText =
     "MSDFgen v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n"
     "MSDFgen v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n"
-    "(c) 2016 - " STRINGIZE(MSDFGEN_COPYRIGHT_YEAR) " Viktor Chlumsky";
+    "(c) 2014 - " STRINGIZE(MSDFGEN_COPYRIGHT_YEAR) " Viktor Chlumsky";
 
 
 static const char *const helpText =
 static const char *const helpText =
     "\n"
     "\n"

+ 1 - 1
vcpkg.json

@@ -1,7 +1,7 @@
 {
 {
     "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/master/docs/vcpkg.schema.json",
     "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/master/docs/vcpkg.schema.json",
     "name": "msdfgen",
     "name": "msdfgen",
-    "version": "1.12.1",
+    "version": "1.13.0",
     "default-features": [
     "default-features": [
         "extensions",
         "extensions",
         "geometry-preprocessing",
         "geometry-preprocessing",