-
Notifications
You must be signed in to change notification settings - Fork 65
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
Try different SDF granularities #38
Comments
8 looks great to me |
This should likely be configurable by font. Simple serif and sans-serif fonts render quite cleanly with significantly reduced granularity, but curvy, swooping fonts like Mister K Pro Regular degrade in quality more quickly.
I may have the style mixed up a bit through, as I was trying to render Mister K at a larger size and even the rendering without reduced granularity appears much lower quality than @amyleew's. Is the screenshot below from a Mapnik rendering or GL? Could this particular font simply be ill-suited for SDF rendering? |
@mikemorris Was testing the FF Font - Mister K. Screenshot directly from TM2. |
So 48px SDFs at granularity 4 look great for rendering curvy fonts like Mister K (even at large font sizes like 72px), but unecessarily bloat the SDFs for simpler fonts like Open Sans Regular at more typical font sizes. Open Sans Regular
Maybe this calls for investigating 2-channel signed distance fields? |
Interesting results! We should definitely explore more here and make the font size configurable (currently it is hard coded to 24px). We could also explore not computing the SDF on the server, but on the client, and just send the antialiased glyph to the client. Similarly, another paper describes how to use the gradients in the distance field to compute sharper outlines and corners. |
You may find this interesting @rasagy, refs mapbox/mapbox-gl-js#3286 |
I need to try a 48px CJK font, where to change the granularity param now? If Btw, no need to modify mapbox-gl-js to use generated 48px glyphs, right? |
IIRC the font size you're looking for is hardcoded as Line 322 in d65c204
It looks like it's also passed in to Line 335 in d65c204
This should likely be made consistent to use the same variable instead of hardcoding values twice, and possibly made more modular, as the file size/clarity tradeoff can be different for more complex font styles.
I don't remember, there may be some logic in there expecting glyphs of a certain size, or it could be reading those metrics from the protobufs. If this was made modular, would need to ensure the frontend rendering displayed glyphs as expected independent of node-fontnik render params. |
We can get better compression ratios by reducing the granularity of the SDFs -- the following commit rounds each value to the nearest multiple of 8:
c213c12
Visually it's hard to see much difference once rendered and here is the space saving for a 0-255 range:
This is a nice boost we can get now roughly for free since it doesn't affect the format/integrating projects -- later we may try other encodings for the bitmap (PNG, etc.) but those will be format-breaking.
Next actions
The text was updated successfully, but these errors were encountered: