msdf-error-correction.h 1.9 KB

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include "types.h"
  3. #include "Vector2.hpp"
  4. #include "Projection.h"
  5. #include "Shape.h"
  6. #include "BitmapRef.hpp"
  7. #include "generator-config.h"
  8. namespace msdfgen {
  9. /// Predicts potential artifacts caused by the interpolation of the MSDF and corrects them by converting nearby texels to single-channel.
  10. void msdfErrorCorrection(const BitmapRef<float, 3> &sdf, const Shape &shape, const Projection &projection, real range, const MSDFGeneratorConfig &config = MSDFGeneratorConfig());
  11. void msdfErrorCorrection(const BitmapRef<float, 4> &sdf, const Shape &shape, const Projection &projection, real range, const MSDFGeneratorConfig &config = MSDFGeneratorConfig());
  12. /// Applies the simplified error correction to all discontiunous distances (INDISCRIMINATE mode). Does not need shape or translation.
  13. void msdfFastDistanceErrorCorrection(const BitmapRef<float, 3> &sdf, const Projection &projection, real range, real minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio);
  14. void msdfFastDistanceErrorCorrection(const BitmapRef<float, 4> &sdf, const Projection &projection, real range, real minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio);
  15. /// Applies the simplified error correction to edges only (EDGE_ONLY mode). Does not need shape or translation.
  16. void msdfFastEdgeErrorCorrection(const BitmapRef<float, 3> &sdf, const Projection &projection, real range, real minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio);
  17. void msdfFastEdgeErrorCorrection(const BitmapRef<float, 4> &sdf, const Projection &projection, real range, real minDeviationRatio = ErrorCorrectionConfig::defaultMinDeviationRatio);
  18. /// The original version of the error correction algorithm.
  19. void msdfErrorCorrection_legacy(const BitmapRef<float, 3> &output, const Vector2 &threshold);
  20. void msdfErrorCorrection_legacy(const BitmapRef<float, 4> &output, const Vector2 &threshold);
  21. }