hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.45k stars 2.19k forks source link

Rendering glitch in Lego Harry Potter Y1-4 #17242

Closed hrydgard closed 12 months ago

hrydgard commented 1 year ago

Reported by perhaps on Discord.

Game: Lego Harry Potter Y1-4

Device: Galaxy A21, Vulkan

Tested on 1.14.4 and latest build.

SmartSelect_20230404-210337_PPSSPP

Nearby save:

ULUS10500DATA00.zip

Occurs in the Chamber of Secrets (2nd door), quest Collecting Ingredients

unknownbrackets commented 1 year ago

A GE frame dump would be more helpful. Might be some kind of Z fighting...

-[Unknown]

mayhaps3500 commented 1 year ago

First time creating a dump. Let me know if I've done something wrong.

ULUS10500_0003.ppdmp.zip

unknownbrackets commented 1 year ago

Even in a PSP playback of that framedump, something funny is happening: #17242_ULUS10500_lego_harry_potter_scrambling

The scene initially is drawn like this, which looks nice and all (2382/4468): Brighter scene without artifacting

But it then darkens everything one by one (4425/4468) and that's when we've gotten the artifact: Darker

The initial darkening of that specific area occurs at 3414/4468. This actually looks more or less right to me: After initial darkening

But then it touches the same area again at 3437/4468 and 3438/4468, which makes it nearly black and gives it that weird pattern. To confirm, skipping those two draws makes it look as one would expect:

Scene without strange artifacting

The first darkening is a simple triangle strip, made up of two triangles: X Y Z
290.119141 19.013916 2996.390625
279.134521 61.373779 2979.410156
243.680420 24.455322 3011.021484
X Y Z
243.680420 24.455322 3011.021484
279.134521 61.373779 2979.410156
231.450928 65.311646 2994.353516
The second two draws are one triangle each with: X Y Z
231.450928 65.311646 2994.353516
290.119141 19.013916 2996.390625
279.134521 61.373779 2979.410156
X Y Z
243.680420 24.455322 3011.021484
290.119141 19.013916 2996.390625
231.450928 65.311646 2994.353516

While these are technically the same points, the triangle is drawn in a different order (first is TR BR TL, TL BR BL, second is BL TR BR, TL TR BL.) This is done as well with a >= depth test, and I think the depth ends up being slightly different because of the order (actually doesn't matter because the texture would make it ugly anyway just on == depth.) Anyway, the texture is different and I think this was intended to be the other side. Both are the same clockwise order, so there's no face culling.

And just to confirm, I tried quickly stripping these two triangles out and running on a PSP, which does look good: #17242_ULUS10500_lego_harry_potter_scrambling_edit

It might be there's some CPU emulation bug causing the game to do these extra triangles, but to me this looks like a game bug.

-[Unknown]

hrydgard commented 1 year ago

Interesting. If it's indeed a game bug like tha, but the Z fighting glitches just look a bit different than on the real PSP, yeah, there's probably not much worth doing here...

hrydgard commented 12 months ago

Somewhat oddly, neither pixel nor vertex depth rounding does anything to improve the look of it on PowerVR, and it does look weirdly worse there. Still, I don't see that we have any good options here, and given that it also does appear to be a game bug, I'm going to close this.