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

Implement smooth depal lookups for Test Drive's strange usage. #15710

Merged
merged 4 commits into from
Aug 22, 2022

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Jul 19, 2022

This implements the path I suggested in #13355, where instead of first reducing the color to RGB565/RGB555 as happens on the real device (well, it's already that low bit depth in the frame buffer, just dithered), we take each channel at full precision according to the mask and do the lookup, linearly filtering the CLUT (palette) if it just contains a smooth gradient.

This makes the game look a lot nicer. Maybe somewhat inauthentic, but at least better than using the cheats that remove the color effect entirely, and I'd argue that within our enhanced high-color PSP world, this is definitely the best way to interpret the original intent.

Before (ignore the framerate, was in Debug mode and loaded a state):
ULES00637_00003

After:
ULES00637_00002

NOTE: Needs a bit more work - should add support to the standalone depal shaders also, not just the in-shader depal mode which is only used in GL and Vulkan currently.

Also should make sure filtering the palette works on all the backends.

@hrydgard hrydgard added the GE emulation Backend-independent GPU issues label Jul 19, 2022
@hrydgard hrydgard added this to the Future-Prio milestone Jul 19, 2022
@hrydgard hrydgard modified the milestones: Future-Prio, v1.14.0 Jul 29, 2022
@hrydgard hrydgard force-pushed the test-drive-smooth-depal branch from 69b4fb1 to 54e8324 Compare July 31, 2022 22:24
@hrydgard hrydgard force-pushed the test-drive-smooth-depal branch from 54e8324 to 18500b9 Compare August 16, 2022 22:42
@unknownbrackets
Copy link
Collaborator

Here you noted that they're nice ramps:
#13355 (comment)

I've seen these before in several games. I feel like we could detect this when building the CLUT texture (based on entries from 0 to the mask, maybe only when offset is 0 which is the common case.) We'd want to check if color or alpha test (other than > 0) is used, which are probably very unlikely anyway.

I think we could then do this without any compat flag, generally, maybe only when the user setting for texture filtering is set to other than NEAREST. I feel like this would make more games than just Test Drive look better. We could generalize it for all the 16-bit formats, or just also ignore the ramps for 4444.

-[Unknown]

@hrydgard
Copy link
Owner Author

hrydgard commented Aug 21, 2022

You're right that we could and probably should try to detect them, plan to do that when I get around to picking this up again. For now at least this branch serves as a proof of concept, there's more work to be done anyway before it's ready to go.

@hrydgard hrydgard force-pushed the test-drive-smooth-depal branch from 18500b9 to 97959f6 Compare August 21, 2022 21:46
@hrydgard
Copy link
Owner Author

Changed it to autodetect the ramp. Will clean up the sampler handling and enable it in regular depal too tomorrow.

@hrydgard hrydgard force-pushed the test-drive-smooth-depal branch from 97959f6 to 89d05b7 Compare August 22, 2022 08:32
@hrydgard hrydgard marked this pull request as ready for review August 22, 2022 09:08
@hrydgard hrydgard changed the title Special case depal lookups for Test Drive's strange usage. Implement smooth depal lookups for Test Drive's strange usage. Aug 22, 2022
This implements the hack I suggested in #13355, where instead of first
reducing the color to RGB565 as the real game does, we just take each
channel at full precision and do the lookup according to the mask,
linearly filtering the palette.

This makes the game look a lot nicer and is also a small optimization,
but the hack is very specific so kinda ugly in a way.
@hrydgard hrydgard force-pushed the test-drive-smooth-depal branch from 1d9717d to a2e2d00 Compare August 22, 2022 13:33
@hrydgard
Copy link
Owner Author

Rebased on master, implemented the new checks and stuff. I think this is ready now, unless I've forgotten something again.

@hrydgard hrydgard force-pushed the test-drive-smooth-depal branch from a2e2d00 to e3943f6 Compare August 22, 2022 13:34
@hrydgard hrydgard merged commit 15f51c3 into master Aug 22, 2022
@hrydgard hrydgard deleted the test-drive-smooth-depal branch August 22, 2022 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GE emulation Backend-independent GPU issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants