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

Pixel-perfect positioning of hardmask & softmask atlas #65

Closed
Chlumsky opened this issue Jan 21, 2023 · 5 comments
Closed

Pixel-perfect positioning of hardmask & softmask atlas #65

Chlumsky opened this issue Jan 21, 2023 · 5 comments

Comments

@Chlumsky
Copy link
Owner

In hardmask and softmask atlas -types, there are no special considerations to ensure that the glyph quads can be placed exactly onto the pixel grid. Instead, the plane bounds dictate that each glyph can be shifted by a different fractional pixel amount. This should be resolved.

@pha3z
Copy link

pha3z commented Feb 7, 2023

I'm curious to know why the plane bound construct exists.

I looked at this thread:
#47

I notice your suggested solution is to simply add planeBound (*size) to the atlasBound for each glyph to get quad placement. If I understand this math correctly, doesn't this mean calculation could be done for every single glyph once to reduce it to a single atlasBound rectangle??

The fact that there are two separate structures makes me wonder if there is a case where they would need to be handled independently at runtime. ???

@Chlumsky
Copy link
Owner Author

Chlumsky commented Feb 7, 2023

Where did I suggest to add plane bounds to atlas bounds? Plane bounds = world coordinates, atlas bounds = texture coordinates.

@pha3z
Copy link

pha3z commented Feb 8, 2023

I'm an idiot. I totally misread the code from the other thread, which colored my question poorly.

Ok now I see. The planeBounds is used to offset the quad in worldspace. I was previously only thinking about locating atlas position of the glyph.

Thank you!

@Chlumsky
Copy link
Owner Author

Chlumsky commented Sep 9, 2023

A fix for this issue is now available in the branch pixel-alignment. Before merging, I need to add the choice between the old and new method so that users can choose between more consistent pixel alignment and slightly more compact atlases. I'd like to also add a way to only lock alignment for just one axis as it makes much more sense to pixel-align the baseline since the glyph advances (and therefore all horizontal positions) will almost always be fractional.

@Chlumsky
Copy link
Owner Author

Chlumsky commented Mar 3, 2024

Merged in ae441c9, the default setting is to pixel-align baseline only (vertical alignment) for all modes.

@Chlumsky Chlumsky closed this as completed Mar 3, 2024
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