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

Random pixelated fonts #738

Closed
ghost opened this issue Mar 20, 2016 · 29 comments
Closed

Random pixelated fonts #738

ghost opened this issue Mar 20, 2016 · 29 comments

Comments

@ghost
Copy link

ghost commented Mar 20, 2016

After few changes in font rendering engine, some text looks worse than before in some resolutions.

Few examples:
schowek01
schowek02
schowek03

@ghost ghost added this to the alpha-0.1.7 milestone Mar 20, 2016
@krzys-h
Copy link
Member

krzys-h commented Mar 20, 2016

Define 'some resolutions'. I don't seem to be able to reproduce this.

@ghost
Copy link
Author

ghost commented Mar 20, 2016

First two are default 800x600 windowed screen mode. The third screenshot is also default 800x600, but I maximized the window while I was in main menu before I started any level.

@krzys-h
Copy link
Member

krzys-h commented Mar 20, 2016

I tried the exact same resolutions and couldn't reproduce this. Maybe show your graphics settings?

@ghost
Copy link
Author

ghost commented Mar 20, 2016

Well, I tested with some graphic settings - it doesn't really depends on texture filtering, MSAA, etc. Experimenting with window size helps to fix readable of some words, but starting with default settings there's still some places that text is messed up.

@ghost
Copy link
Author

ghost commented Mar 20, 2016

It also have nothing to do with the game's UI language. I changed the language, restarted the game and still the "Missions" button is messed up in 800x600 window from very beginning.

I guess it's something wrong with refreshing text resolution in few places, because most of the text is looking good in any resolution.

@piotrdz
Copy link
Contributor

piotrdz commented Mar 21, 2016

@RaptorParkowsky: can you check if this issue occurred before my commit 8baccb0? It's possible that I broke something when optimizing texture generation in text rendering.

@krzys-h
Copy link
Member

krzys-h commented Mar 21, 2016

@piotrdz: He already said that this occurs since text rendering changes

@ghost
Copy link
Author

ghost commented Mar 21, 2016

@piotrdz Yeah, I can confirm that occured after your fixes. I also remember that "Missions" button in main menu even long before that commit was a little strange, but possibly this is more related to UI though.

This is how it was looking before on standard 800x600 window:
schowek03
A little bit strange, but still readable. The new one that's in latest dev build is almost completely unreadable in standard 800x600 window.

@piotrdz
Copy link
Contributor

piotrdz commented Mar 21, 2016

@RaptorParkowsky: Just like @krzys-h , I can't reproduce it on my machine. I'll look over my code later and see what could be causing this.

@krzys-h
Copy link
Member

krzys-h commented Mar 21, 2016

I just got some similar text rendering artifacts after resizing window from 1280x1024 to 800x600 while having mission 1.3 loaded. Those are most visible on the black background of the debug stats, but if you look closely you can see them in other places too.
image

piotrdz added a commit that referenced this issue Mar 22, 2016
Explicitly set byte alignment in pixel transfer operations
@piotrdz
Copy link
Contributor

piotrdz commented Mar 22, 2016

Please check if my last commit fixes this problem.If it still occurs, then it may be a problem with using GL_NEAREST or with float rounding of texture coords and I can prepare a separate branch for testing that.
In either case, I'm trying to fix this blindly because I haven't been able to reproduce the issue on my hardware.

@ghost
Copy link
Author

ghost commented Mar 22, 2016

Unfortunately after that fixes this pixelated fonts still occurs in the same locations.

Now I also found it also occurs here, in the ending splashscreen, if it would be helpful to know (it was also before yours totay fixes):
schowek01

@krzys-h
Copy link
Member

krzys-h commented Mar 24, 2016

I managed to reproduce it again by randomly switching resolutions. @piotrdz, could you see if you can reproduce it like that?
It's still a lot less visible than for @RaptorParkowsky though, mostly as single pixels near the edge of the characters (in this case it looks to be the space character?).
Now that I think about it, my one might be a completly different issue, as it appears for all characters of given type on screen.
image
image

@ghost ghost modified the milestones: alpha-0.1.8, alpha-0.1.7 Mar 24, 2016
@krzys-h
Copy link
Member

krzys-h commented Mar 24, 2016

I've managed to "fix" my issue, but it's not the cleanest fix ever...

-        Math::Point texCoord1(static_cast<float>(tex.charPos.x) / FONT_TEXTURE_SIZE.x,
-                              static_cast<float>(tex.charPos.y) / FONT_TEXTURE_SIZE.y);
-        Math::Point texCoord2(static_cast<float>(tex.charPos.x + tex.tileSize.x) / FONT_TEXTURE_SIZE.x,
-                              static_cast<float>(tex.charPos.y + tex.tileSize.y) / FONT_TEXTURE_SIZE.y);
+        float dx = 0.5f/FONT_TEXTURE_SIZE.x;
+        float dy = 0.5f/FONT_TEXTURE_SIZE.y;
+        Math::Point texCoord1(static_cast<float>(tex.charPos.x) / FONT_TEXTURE_SIZE.x + dx,
+                              static_cast<float>(tex.charPos.y) / FONT_TEXTURE_SIZE.y + dy);
+        Math::Point texCoord2(static_cast<float>(tex.charPos.x + tex.tileSize.x) / FONT_TEXTURE_SIZE.x - dx,
+                              static_cast<float>(tex.charPos.y + tex.tileSize.y) / FONT_TEXTURE_SIZE.y - dy);

piotrdz added a commit that referenced this issue Mar 25, 2016
Align text rendering to character, not tile size
@piotrdz
Copy link
Contributor

piotrdz commented Mar 25, 2016

@krzys-h: well, with your fix I get pixelated text everywhere.
Instead, I think that my commit 4e331f1 will solve this as a kind of workaround. Now, only characters will be rendered, not characters and their surrounding tiles. There should be no overlap, unless the width of character falls exactly on power of 2 boundary, which is unlikely.

@ghost
Copy link
Author

ghost commented Mar 25, 2016

Well, that's true. After that fix it get even more pixelated bugs:
schowek01
schowek02
schowek03
schowek04

@krzys-h
Copy link
Member

krzys-h commented Mar 25, 2016

My fix didn't even get applied in the repo (and it does not cause pixelated text for me). @piotrdz's fix made no noticeable difference at all for me

@muzscaly
Copy link
Member

I can confirm this bug (graphics engine: gl14 | res: 800x600)
But for me appears in another form...
confirmed

@tomangelo2
Copy link
Member

@Davivad: which OS do you have?

@muzscaly
Copy link
Member

Windows 7 Home Premium x64

@MrSimbax
Copy link
Contributor

Not sure if this is related, but guess what, odd font rendering happened for me too.

piotrdz added a commit that referenced this issue Apr 3, 2016
Add one-pixel boundary and fix texture coordinates for font characters
This should finally fix the issue of pixelated text
@piotrdz
Copy link
Contributor

piotrdz commented Apr 3, 2016

I've finally reproduced this issue by using software renderer. It should be fixed by 72f966b.

@MrSimbax
Copy link
Contributor

MrSimbax commented Apr 3, 2016

It's better, but there are still little bugs.

edit:

In SatCom they are more noticeable, although on other font sizes there is less bugs.

@krzys-h
Copy link
Member

krzys-h commented Apr 3, 2016

I can't reproduce this issue anymore, although in my case there was never any text deforming, only characters from neighboring tiles being visible.

@piotrdz
Copy link
Contributor

piotrdz commented Apr 6, 2016

As I suspected, the root cause of the remaining rendering artifacts is floating-point rounding. I have a very ugly fix for this which I will commit once I clean it up a little bit.
However, to clean this up properly and avoid similar problems in the future means rewriting UI positioning and size calculations everywhere. I wonder if this is worth the effort if we are to move to CEGUI anyway.

piotrdz added a commit that referenced this issue Apr 6, 2016
Text rendering is now done in window coordinates corresponding to window
pixels to avoid floating-point rounding errors that show up as rendering
artifacts
@krzys-h
Copy link
Member

krzys-h commented Apr 7, 2016

After 71a77c7, the text looks a lot different than it used to. Additionally, underlines on links in SatCom are invisible.

Before:
image

After:
image

@piotrdz
Copy link
Contributor

piotrdz commented Apr 8, 2016

@krzys-h: I've fixed the display of highlights.

It's not surprising that the text looks different because now it is actually aligned to pixel boundaries, as it should be. Previously, it was almost always rendered at some uneven pixel position and blended onto the surrounding pixels which made it look a bit thicker than it would normally be.

@MrSimbax
Copy link
Contributor

MrSimbax commented Apr 8, 2016

This issue no longer occurs for me.

@krzys-h
Copy link
Member

krzys-h commented Apr 8, 2016

Yup, everything seems to be fine now.

@krzys-h krzys-h closed this as completed Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants