Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ways to counteract sprite glitches caused by upscaling / texture filtering?
10-26-2014, 11:49 PM
Post: #3
RE: Ways to counteract sprite glitches causes by upscaling / texture filtering?
My apologies in advance... massive wall of inane text incoming...

(10-26-2014 08:24 PM)[Unknown] Wrote:  One problem with linear filtering is rounding. We've had (and still have) issues because of not always matching the rounding on a PSP.

At 2x, though, you start to have "impossible" problems .... Ack.

Thank you for the explaination and the examples of one of the main culprits of these glitches! I've read countless postings about the issues back in the PCSX2 forums in the past and this is the first time I saw things described in laymans terms.

That all made a lot of sense and its entirely understandable that the programmers wouldn't shoot for perfection in those cases. If it looks correct on the only resolution the the system will ever have it wouldn't make sense to waste any more time on it.

I appreciate the info.



(10-26-2014 08:24 PM)[Unknown] Wrote:  The "best" solution to this problem is an extra step that snaps the coordinates to what they would be at 1x. So, for example, 1.3 would get rounded down, and 2.5 would get rounded up. Then we would draw (1, 1) to (3, 3) and it'd look fine.

The reasons we haven't done this yet are:
* It's slower. Snapping would have to be done after transform, and probably in the GPU. We'd probably have to move the viewport transform into the shader as well, not sure.
* My example was positions, but the problem applies to texture coordinates as well, which increases perf hit / complexity.
* It would hurt visual quality of 3D models or games written by Mr. Smartypants above. Animation will look more fluid without the snapping.
* No one has written it yet.

The main problems should be solvable by making it an option. Possibly a separate option for depth as well (which I'm pretty sure not snapping there is causing problems in at least Phantasy Star Portable 1.)

Based on the examples you gave that solution does seem like it would solve a lot of the glitches like the Unchained Blades faces and the countless games where the 2D HUD or in-game menus have gaps and the like.

I can understand how that would make things slower as well. On the bright side the games that suffer the most from the sprite glitches are generally those that are 2D heavy and are already quite fast even on lower end systems.

I also agree that such a thing should be optional if implemented. This way the user can have more influence on whether they want sprites to look "right" or better performance. It would also allow people to turn it off for 3D games and avoid the hit to the quality of 3D visuals and animation.

When you're talking about depth write issues in Phantasy Star Portable 1 I assume you're talking about the issue where text doesn't show?

I saw that one occuring when I tried out my copy of the game. I also saw similar things when trying out Valhalla Knights 2. The "monster encyclopedia" (forget what its called in game) that you can view from the inventory menu in-game seems likes it drawing the stuff to the screen in the wrong order, or at the wrong depth, since the monster models and information isn't there... its just the blank book page with darkened areas where that stuff should be.


My programming experience is fairly limited, and my emulation related "work" consists solely of making a CRC hack to disable the blurring effects in Disgaia 2 for use in PCSX2 and finding a workaround to the Growlanser Generations saving freeze when running it through PCSX2. Please forgive me for anything I'm about to say thats impossible or stupid! I know just barely enough about this stuff to get my foot up and into my mouth making me look like an idiot, so I can't imagine anything I'm about to say its even plausible, but...

Out of curiousity, does PPSSPP have any way of "knowing" when its working with 2D as opposed to 3D? Like a flag or some such?

If it has a way to differentiate between 2D and 3D then, in regards to the idea of this "best solution" of rounding down / up, is it possible for that method of rounding to be applied only when PPSSPP is dealing with 2D and not when its dealing with 3D?

I admit to knowing nothing about the inner workings of PPSSPP, its all black magic and miracles to me, so the above idea is based solely on wondering if there is some way for the program to differentiate between the two.



Alternatively, would it be possible to "draw" all of the 2D textures that are about to be drawn on screen to a seperate buffer as one "whole", single, texture and then to upscale and filter that?

I remember having to jerry-rig something along these lines once when working on an Xbox Live Arcade project back in the day that was having some issues with its sprites at different resolutions. Changing the sizes of the games map sprite and object sprites seperately was causing issues so instead it was necessary to draw one "frame" of the screen with all its sprites as they would appear at the native resolution into a buffer as a single texture. Then we'd take that texture of what the whole screen should look like with all the sprites on it and upscale / downscale it to the desired resolution. Once that was done it would just be applied to the screen.

Using the Unchained Blades dialogue sprites as an example, since the 3D part of the game is the background with the 2D stuff overlayed on top of it. Would it be plausible to store all the 2D sprites (characters, HUD, etc) as they would display on the screen at 1x resolution as a single texture and then do the upscaling and filtering of that texture as a whole before displaying it to the screen?



Mostly curious about the above stuff because when you turn "Texture Filtering" to "Nearest" the game (Unchained Blades) is able to display the sprites as they'd look at native resolution while still keeping the 3D at high resolutions. Which made me wonder if there is a way for PPSSPP to distinguish between the two. Though I suppose its just the 3D models themselves being at a high resolution and not necessarily the 2D textures on those models.




(10-26-2014 08:24 PM)[Unknown] Wrote:  That said, maybe there's some better way. It'd be nice to not have an option that needs to be customized per game. I don't know what PCSX2 does because I usually play games on most systems at 1x.

I agree that it would be nice to not have a need to customize options for each game.

This was one of the main things that caught me off guard when checking out PPSSPP for the first time. When I first started using PPSSPP I was shocked that there was very little setup required to run a game and that most games looked and ran great with default settings.

With PCSX2 there wasn't really a default setting, aside from native, that would be optimal for all games or often even different games in the same series or using the same engine. There would often be various settings you'd need to tweak or adjust, especially when using higher resolutions, to get the "optimal" mix of performance and quality.

This is a lot of the reason that I started this thread. I was so accustomed to dicking around with settings and tweaking things for each game in PCSX2. In PPSSPP whenever I encountered anything odd I wasn't really sure what all options were at my disposal to attempt to "fix" anything I encountered.

I confess I found pushing games well beyond their limits and tweaking settings until they looked and ran "best" was addicting to me and kind of a good portion of my enjoyment with the PCSX2 emulator. Unless something too majorly restricted me I usually ran most PS2 games at 4x to 6x resolutions so I got quite familiar with the various options and tweaks that could "fix" a given issue.


As far as I know the majority of the sprite glitches in PCSX2 were also caused by rounding issues. Being that its open source, it even uses github and Orphis Buildbot like PPSSPP does, maybe it would be possible to find some "solutions" for the PPSSPP sprite glitches in the coding of PCSX2? While I'm sure the overall inner workings are quite different, I'd imagine that the various methods of dealing with rounding and displaying textures in PCSX2 could be applied to PPSSPP.

Most of the tweaking that could be done in PCSX2 was found in the GSDX (PCSX2's primary graphics plugin) settings. GSDX was created by "Gabest" who also made the movie player "Media Player Classic", now called "Media Player Classic - Home Cinema". Gabest seems to like doing things in relation to graphics a good bit... it would likely even possible to contact him regarding PPSSPP.... he always seemed a fairly friendly and level headed sort.

The GSDX options that had the most affect on sprite glitches caused by filtering or upscaling were...

Texture Filtering - There were three different settings, though I'm not sure specifcally what they did as they weren't named like in PPSSPP. Instead it was either fully on, half on, or off.

And Hardware hacks like...

Half Pixel Offset - used to fix misaligned fog, bloom, or blending effects.

Sprite Hack - Used to get rid of black inner lines in some filtered sprites. Had a full, half, or off option. Full fixed issues involved in the game Tales of Destiny. The half option fixed things in Mana Khemia and Ar tonelico.

Wildarms Offset - Lowered GS precision to avoid gaps between pixels when upscaling. Primarily used to address glitches in the Wild Arms series, hence the naming, but could also be used to correct dialogue sprite issues in Ar tonelico.

Texture Coordinates Offset Hack - This was a user customizable hack. It was an offset for ST/UV texture coordinates and fixed some texture issues and post processing aligment issues. Often times a value of 250, 500, or 1000 to the X or Y offset was enough to fix some game glitches. Although, its use could also throw other things out of whack though like when a game uses a flipped version of a sprite such as Mana Khemia 2 having the same dialogue sprite just mirrored depending on whether they were the one talking or the one responding.






(10-26-2014 08:24 PM)[Unknown] Wrote:  Another problem can be caused by increased sampling. When the OpenGL is generating more pixels near the edge, it may want to sample more texels than before (especially depending on the texture size vs. drawing size.) In the case of a sprite sheet, this can cause texels of completely wrong colors to be filtered in (iirc this is a problem in FF4.) This is a major problem when alpha or color testing is used (e.g. when fuchsia is used as transparent.)

And then there's texture scaling, which brings even more problems to the table, since it is (somewhat necessarily) applied to entire textures, not just the sampled regions. This worsens the problems mentioned above.

When you're talking about sprite sheets here you're talking about it accidentally reading pixel information from other sprites on the sheet near the one the emulator is trying to work with correct?

If thats what you're talking about then I can completely understand that causing some complications. If thats not what you meant then I apologize but thats all stuff a bit over my head and beyond my limited knowledge on the subject.





(10-26-2014 08:24 PM)[Unknown] Wrote:  So, it's definitely a complicated issue for which there's not a single silver bullet, at least not that I know of.

-[Unknown]

Yeah I can imagine its quite a complicated issue. Especially since each game is likely to be just different enough that a solution for one wouldn't work in another... or could even make it worse or break it entirely.

Thats the majority of why I started this thread. I was so used to tweaking PCSX2 settings for games that upon seeing PPSSPP's more streamlined options I wasn't quite sure what I could or should do to address any issues I encountered.

I know that PPSSPP is still quite young, but is it likely that it will end up like PCSX2 down the road and have a plethora of more game specific hacks / toggles or is PPSSPP going to be more stricly a streamlined emulator?

Aside from running games in 1x native resolution or using "Texture Filtering" set on "Nearest" are there any other currently implemented options that do or may be able to be used to "fix" various glitches? Those are the only two things I've found so far.



In closing, thank you very much for your posting. I thoroughly enjoyed reading it and it was quite informative.

Additionally, I hope that nothing I've said was taken as demands, requests, or anything of the sort as none of it was meant like that. It was all entirely out of curiousity or to point out that I've seen similar issues addressed elsewhere in certain ways. I've seen a number of times in threads and github postings where people pointed to JCPSP and the way that they handled things so I figured referencing PCSX2 wouldn't be considered too out of line for any reason. I sincerely appreciate all the work that the PPSSPP "team", as a whole, has put into making PPSSPP. Its been a blast so far being able to enjoy all my old games again in all their beefed up glory!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Ways to counteract sprite glitches causes by upscaling / texture filtering? - Kolrath - 10-26-2014 11:49 PM

Forum Jump: