Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Msdf generation fails on symbol with several nested holes #170

Closed
Dollab opened this issue Dec 4, 2022 · 4 comments
Closed

Msdf generation fails on symbol with several nested holes #170

Dollab opened this issue Dec 4, 2022 · 4 comments

Comments

@Dollab
Copy link

Dollab commented Dec 4, 2022

Hi, first of all thanks a lot for this amazing library.

I've encountered a specific shape that seems to produce an error in the output msdf. You can see below the svg file describing the shape, the resulting msdf and an example of a render using the msdf.

The upper left hand rectangle should be hollowed but it's marked as "filled".

The results can be reproduced with the following code :

#include "msdfgen.h"
#include "msdfgen-ext.h"
#include <iostream>

using namespace msdfgen;

int main()
{
    std::cout << "Converting svg..." << "\n";
    Shape shape;

    if (loadSvgShape(shape, "./assets/floor.svg", 0)) {
        shape.normalize();
        //                      max. angle
        edgeColoringSimple(shape, 2.0);
        //           image width, height
        Bitmap<float, 3> msdf(3*24, 3*24);
        //                     range, scale, translation
        generateMSDF(msdf, shape, 2.0, 3.0, Vector2(0.0, 0.0));
        savePng(msdf, "./textures/output.png");
        simulate8bit(msdf);

        Bitmap<float, 1> test(256, 256);
        renderSDF(test, msdf, 1.0, 0.5);
        savePng(test, "./textures/test.png");
        std::cout << "Success!" << "\n";

    }

    return 0;
}

floor
output
test

@Chlumsky
Copy link
Owner

Chlumsky commented Dec 4, 2022

You either need to provide a correctly formed shape with consistent contour windings or use the Skia preprocessing.

@Chlumsky Chlumsky closed this as completed Dec 4, 2022
@Dollab
Copy link
Author

Dollab commented Dec 4, 2022

Thanks a lot for the superfast response.
I'm not too versed in vcpkg, but I can't seem to find the skia feature ?

@Chlumsky
Copy link
Owner

Chlumsky commented Dec 4, 2022

Not sure what you mean, but the vcpkg feature is called geometry-preprocessing and it is enabled by default.

@Dollab
Copy link
Author

Dollab commented Dec 4, 2022

Yes, my bad It works perfectly thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants