ppsspp icon indicating copy to clipboard operation
ppsspp copied to clipboard

Metal Slug XX - texture issue at combat school

Open MojoJojoDojo opened this issue 3 years ago • 5 comments

Game or games this happens in

ULUS10495 Metal Slug XX v 1.01

What area of the game

When you are going to the Combat School option in the game you could see that when the character sprite mouth moves.

What happens

There is what some people call "misaligned texture" around the mouth area. You can see it here: unknown

What should happen

There should be no issue with the graphics there. Note: You can still notice this happens even without upscaling its just less obvious. Also , this happens on both Vulkan and OpenGL.

GE frame capture

ULUS10495.zip

Platform

Linux / BSD

Mobile phone model or graphics card

AMD Radeon 530/Intel UHD 620

PPSSPP version affected

1.13.1

Last working version

No response

Graphics backend (3D API)

Vulkan

Checklist

  • [X] Test in the latest git build in case it's already fixed.
  • [X] Search for other reports of the same issue.
  • [X] Try resetting settings or older versions and include if the issue is related.
  • [X] Try changing graphics settings to determine if one causes the glitch (especially speed hacks or enhancements/replacements.)
  • [X] Include logs or screenshots of issue.

MojoJojoDojo avatar Jul 30 '22 10:07 MojoJojoDojo

Curiously the game shows the character properly wiith upscaling on MelonDS (which is notorious for having many misaligned texture issues on other games). unknown

In addition, this issue still happens on PPSSPP even with software renderer enabled: image

ghost avatar Jul 30 '22 10:07 ghost

Just to confirm, a PSP does render this frame dump properly: #15755_ULUS10495_metal_slug_face

Vulkan gets it right too, but only at 1x. I explain here why it's problematic to handle these cases at higher resolutions: https://forums.ppsspp.org/showthread.php?tid=13556 For this game, it might be better to just use an upscaling shader instead of a higher render resolution.

Anyway, in software it draws the face like this: Texture with mouth and chin next to partial render

It's a triangle strip rectangle, in transform (3D) mode, and the coordinates are not very accurate:

X Y Z U V
300.687500 87.000000 10000.000000 151.978500 88.387581
332.625000 87.000000 10000.000000 183.454727 88.387581
300.687500 118.937500 10000.000000 151.978500 119.984131
332.625000 118.937500 10000.000000 183.454727 119.984131

If I disable Rasterizer::DetectRectangleFromStrip(), it draws correctly, so this must be some issue with the math specifically in DrawRectangle when S/T aren't even.

As I described in the posted link, this is a case of "bad math." Software is a bug, but hardware at 2x is just doubling all the coordinates. Snapping to pixels will make 3D graphics look worse at higher render resolutions.

Screen positions are 31.9375x31.9375 from a texture that's 31.476227x31.59655. That should end up close enough (it seems) at 1x, but the higher the resolution, the more those diverge.

-[Unknown]

unknownbrackets avatar Oct 01 '22 05:10 unknownbrackets

Vulkan gets it right too, but only at 1x

ULUS10495_00002

On 1x there is a rectangle below her mouth for some reason... I tried to capture it but it's not that easy as well(you can notice it if you squint hard enough) , it only happens when her mouth flaps move though. This is on the latest PPSSPP I just recently updated.

ghost avatar Oct 01 '22 07:10 ghost

To me, that just looks slightly off-color, I wonder if it's a slightly different bitdepth and dither/etc. solves it on actual hardware. Does that happen in the software renderer?

-[Unknown]

unknownbrackets avatar Oct 01 '22 14:10 unknownbrackets

To me, that just looks slightly off-color, I wonder if it's a slightly different bitdepth and dither/etc. solves it on actual hardware. Does that happen in the software renderer?

-[Unknown]

No the coloring seems fine there. Now I found another issue with one of the logos in the intro. There is an additional black line you can notice at the right corner next to the logo. image

Also uploaded a frame capture here as well: ULUS10495.zip

ghost avatar Oct 01 '22 18:10 ghost

I believe #16241 fixes all the software renderer issues noted here.

Looking more closely at Vulkan, you're right that it's rendering this wrong - even with anisotropic set to off. It seems like it ends up sampling or drawing slightly outside where it should. This might still be tricky to fix due to the math concerns I mentioned, but I was hoping we wouldn't see issues of this at 1x...

-[Unknown]

unknownbrackets avatar Oct 17 '22 02:10 unknownbrackets

Didn't tested this before, but currently it seems to render fine with x1 render res at least on vulkan and using the 2 dumps provided, it also works in software renderer, it can also be completely hidden by texture scaling, but this might depend on the resolution used, on my 4k TV only x6 texture scaling completely hidden it and we don't have that in official releases.

x1 render res vulkan ULUS10495_00002

software renderer ULUS10495_00001

x6 xBRZ texture scaling(probably less is enough for smaller res) ULUS10495_00000

Texture replacement would probably be the best way to deal with(I mean for the end user, not a weird built-in workaround). At least assuming the actual game isn't running on some emulator and replacement is usable.

LunaMoo avatar Dec 30 '23 21:12 LunaMoo

Loked at the actual game now and found some BS happening here:

  • we don't have any problem with emulation in here now, imo it looks as it should given what it has to work with at x1 render res,
  • some original textures of this character face have missmatched colors in PSP version, this is probably caused by using incorrect resizing software that messed up color palete while porting to PSP and this is what causes noticeable seams with some expressions in x1 render res. Clipboard02 an example of color difference on part of the cloth between different textures(taken from original unmodified textures of different face expressions)

The only way to "fix" it is to mod those textures correcting colors in them(Edit: althrough LCD persistence shader can minimize it to the point of not being seen, potentially why this was good enough for release).

To work around the seams above x1 render res the usual work:

  • xbrz texture scaling or replacement above render res,
  • enforcing nearest texture filter.

LunaMoo avatar Dec 31 '23 18:12 LunaMoo