duckstation icon indicating copy to clipboard operation
duckstation copied to clipboard

Add "Advanced Settings" option for rounding texture coordinates from an upscaled internal resolution

Open Superstarxalien opened this issue 2 years ago • 4 comments

The problem

In order to prevent issues with displaying textures in games with upscaled internal resolutions, DuckStation floors all texture coordinates whenever vertex offset values are multiplied according to the internal resolution upscaling option. To my understanding, at least.

Flooring the texture coordinates doesn't work best for certain games, however. The Crash Bandicoot series of platformers shows jagged edges on the textures of crates whenever the game is upscaled, which is a pretty noticeable error throughout the entire games. For these games, rounding the texture coordinates instead of flooring them provides more "accurate" behavior, in regards to looking the closest to what the game looks like with its internal resolution unchanged.

These are screenshots I took of the games Crash Bandicoot, Crash Bandicoot 2: Cortex Strikes Back, and Crash Bandicoot: WARPED. Beyond the settings mentioned in each screenshot, I also enabled the "True Color" option to disable dithering.

1x Internal Resolution

4x Internal Resolution (texture coordinates are floored, normal DuckStation behavior)

4x Internal Resolution (texture coordinates are rounded, modified DuckStation behavior)

What this commit does

This commit adds an option to force texture coordinates to always be rounded even when the internal resolution of the game is upscaled, found in the "Advanced Settings" category. While it would seem like a no-brainer to force this setting to be enabled for the games that look better with it, such as Crash Bandicoot...

It isn't actually perfect. Errors like these can be fixed simply by enabling PGXP, but, of course, that only benefits the people that wish to play with PGXP on. For such users, however, this option would be a no-brainer to enable.

P.S. the above screenshots were all with PGXP off, the game only looks bad right about there

Thanks to @ManDude for tipping me off on this problem and its (band-aid) solution.

Superstarxalien avatar Jan 30 '23 21:01 Superstarxalien

Yeah, that's why I never did myself.. my concern would be that it breaks more than it fixes.

I suppose you could try limiting it to 3D polygons (either by ignoring it for sprites, or using the Z from PGXP).

stenzek avatar Jan 31 '23 02:01 stenzek

so after some investigation, the glitch that occurs in crash 1's title screen when enabling this option can probably be fixed

that title screen is made up by Rect16x16TexBlend gpu calls, or in other words rectangle primitives; they're about the only graphics that get really messed up with this option on, so I figure that if the emulator checks for those and sets the texture coordinates to floor on those only it wouldn't be an issue anymore, looking for your thoughts though

Superstarxalien avatar Feb 04 '23 19:02 Superstarxalien

Right, that's why I said "ignoring it for sprites" ;)

stenzek avatar Feb 05 '23 03:02 stenzek

well this is certainly how you can tell I'm less experienced in this subject matter lol yeah I would go for that but I don't really know how to do it, so I wanted to ask you on that

Superstarxalien avatar Feb 05 '23 03:02 Superstarxalien

I ended up implementing this independently in https://github.com/stenzek/duckstation/commit/8455c9c3c6f099425765aec4c73789c13a557065.

Added all the plumbing/tracking for separate pipelines for sprites, and... it seems I don't get the glitches shown above? Which is weird. Hopefully it's not vendor-specific, as round() has caused problems there before... but hopefully not roundEven().

Anyway, that code can be re-used for separate texture filters for sprites.

stenzek avatar Jun 16 '24 09:06 stenzek