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

Limit SDF dowscaling #7652

Open
brunoabinader opened this issue Nov 30, 2018 · 3 comments
Open

Limit SDF dowscaling #7652

brunoabinader opened this issue Nov 30, 2018 · 3 comments
Labels

Comments

@brunoabinader
Copy link
Member

brunoabinader commented Nov 30, 2018

Given the following style.json render test example:

{
  "version": 8,
  "metadata": {
    "test": { "height": 256, "width": 256 }
  },
  "center": [ 0, 0 ],
  "zoom": 0,
  "sources": {
    "point": {
      "type": "geojson",
      "data": {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": { "name": "Napoli", "name_en": "Naples" },
            "geometry": {
              "type": "Point",
              "coordinates": [ 0, 0 ]
            }
          }
        ]
      }
    }
  },
  "glyphs": "local://glyphs/{fontstack}/{range}.pbf",
  "layers": [
    {
      "id": "text",
      "type": "symbol",
      "source": "point",
      "layout": {
        "text-field": ["format",
            ["get", "name_en"], { "font-scale": 48 },
            "Italy", { "font-scale": 16 } ,
            "\n", {},
            ["get", "name"], { "font-scale": 16, "text-font": ["literal", [ "NotoCJK" ]] }
        ],
        "text-font": [
          "Open Sans Semibold",
          "Arial Unicode MS Bold"
        ],
        "text-size": 1
      }
    }
  ]
}

In the example above, text-size is set to 1, while font-scale is set to different values. This generates downscaled SDF textures that produces unreadable results.

Rendered result:
actual

/cc @ansis @ChrisLoer

@ChrisLoer
Copy link
Contributor

From Slack, @ansis commented:

Hmm, although that is a slightly surprising usage it sounds like there is a bug caused by not adjusting the sdf blurring distance for the scaled size. I think this should be fixable. Can you open an issue and tag Chris?

Passing variable halo distance (or really, variable text-size) to the shaders would require us to do something like a paint property binder whenever we used format expressions. The current implementation takes advantage of being able to implement "font-scale" purely by changing the layout vertices. This has the advantage that no extra data has to get passed to the GPU to support multiple "scales" in a single draw call, but leads to these artifacts with large font-scales. See discussion at #6994 (comment).

Putting an explicit limit on font-scale might help guide people in the right direction here. Maybe .25 <= font-scale <= 4?

@ansis
Copy link
Contributor

ansis commented Dec 3, 2018

I think text-size is already always data-driven so baking it in there wouldn't require any extra binding. I'm not familiar with the formatted text implementation. Would it be hard to implement it with this?

@ChrisLoer
Copy link
Contributor

You're right, I think we can do it that way.

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

No branches or pull requests

4 participants