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

Text render resolution #1132

Merged
merged 5 commits into from
Dec 30, 2020
Merged

Conversation

blunted2night
Copy link
Contributor

@blunted2night blunted2night commented Dec 22, 2020

This patch changes the text glyph atlas to render at the displays physical resolution fixing scaling artifacts that exist when running at scaling factors other than 1. It addresses issue #1116.

It accomplishes this by adding a scaleing factor to the sprite sheet rendering pipeline. This is added via a new resource node, though it could also probably be merged into the existing TextureAtlasSprite resource node.

This improves text quality, but there still appears to some glyph placement issues that could be resolved in this PR or another one.

@blunted2night blunted2night force-pushed the text-render-resolution branch 2 times, most recently from 9440aab to cb46e92 Compare December 22, 2020 17:58
@memoryruins memoryruins added the A-Rendering Drawing game state to the screen label Dec 22, 2020
@cart
Copy link
Member

cart commented Dec 28, 2020

Ideally we don't need to send the scale factor to the gpu. Thats extra data transfer that isn't required. I think we should do that work on the cpu if we can.

@blunted2night
Copy link
Contributor Author

Ideally we don't need to send the scale factor to the gpu. Thats extra data transfer that isn't required. I think we should do that work on the cpu if we can.

I suppose the transformation matrix passed to the shader could be reworked to be in physical coordinates for text rendering. Is that what you are getting at?

@cart
Copy link
Member

cart commented Dec 28, 2020

I suppose the transformation matrix passed to the shader could be reworked to be in physical coordinates for text rendering. Is that what you are getting at?

Not quite. One way to go about it is:

  1. the matrix should continue to be in logical coordinates
  2. the texture atlas shader shouldn't need to be touched at all
  3. the text layout could happen in "logical" space operating under the assumption that text is unscaled
  4. the text glyphs could be generated at scale_factor * font_size instead of font_size (giving them the "correct" scale factor despite being positioned using the "logical" scale.
  5. set the sprite transform scale to inverse_scale_factor to ensure the sprites are rendered at the correct size

@cart
Copy link
Member

cart commented Dec 28, 2020

At least ... I think that would work?

@blunted2night
Copy link
Contributor Author

I tried that route initially, but couldn't get it to work. The details are a little fuzzy right now, but it came down to the scale affecting placement of the glyphs making it tricky to get the transform right. It should be possible, but I think it comes down to reproducing physical coordinates one way or another.

I choose this rout since I figured it would be useful for sprite sheets to be able to scale the sprites similar to the same capability for non-sprite-sheet sprites. I choose to pass a scaling factor instead of an explicit size, which makes it inconsistent though.

@cart
Copy link
Member

cart commented Dec 28, 2020

Yeah my only major hangup with this impl is the extra data passed to the shader. If you can eliminate that / use the existing shader without making changes to it, then the other details matter less to me.

@cart
Copy link
Member

cart commented Dec 30, 2020

Nice! Glad this ended up being a relatively straightforward impl. I made a few small changes:

  • removed the TextureAtlasScale component and binding as they are no longer used
  • removed the Text2d component you added as a distinguisher in favor of the MainPass component. It works just as well (at least from what I can tell). I'm just generally biased toward fewer components.
  • removed the print line.

I think is is good to go, but feel free to comment on any of the changes.

@blunted2night
Copy link
Contributor Author

Thanks for cleaning it up. I had considered using the MainPass but thought it might cause problems with a potential future use of text components such as maybe text3d. We can certainly cross that bridge if it comes up at that point though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants