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

UV clipping hack for Tales of Rebirth screen tearing #12127

Closed
wants to merge 1 commit into from

Conversation

TJnotJT
Copy link

@TJnotJT TJnotJT commented Dec 27, 2024

Description of Changes

This is a PR to address the screen tearing problem in #12100 for SW rendering. The main change is to clip UV values of individually rasterized pixels to the bounding box of the (rounded) UV) values of the poly. This is still very much for testing purposed as it only applies to SW renderers without the JIT recompiler (so it's very slow) and the code is hacky. This is for testing purposes at this point, but if it accepted I would add it to the JIT recompilers and clean it up. Also, the changes only apply to texture mapping in UV mode, though it might be able to be modifited to work with ST mode also.

Rationale behind Changes

The problem is that some times bilinear interpolation causes interpolated UV values to go outside the area where they are expected to be. These edge UV values cause sampling from incorrect texels causing alpha tests to fail and leave tears in the poly. I don’t know if this is a game bug that is being correctly emulated or an emulation bug. Either way, the effect is not desirable.

The fix I suggest is to clip the UV values during rasterization against the min/max integer values of the UV values of the vertices of the poly. I don’t have enough experience to know if this is a viable solution or if it would cause worse issues elsewhere, so any help testing this on games or feedback would be much appreciated.

Suggested Testing Steps

I have tested this on a GS dump of provided in the thread #12100 and it seems to fix that issue. I would suggest testing this on games to make sure it is not breaking other things. I anticipate it will be quite slow.

PS: I hope I made this PR correctly. Please let me know if I should change anything!

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting a contribution to PCSX2

As this is your first pull request, please be aware of the contributing guidelines.

Additionally, as per recent changes in GitHub Actions, your pull request will need to be approved by a maintainer before GitHub Actions can run against it. You can find more information about this change here.

Please be patient until this happens. In the meantime if you'd like to confirm the builds are passing, you have the option of opening a PR on your own fork, just make sure your fork's master branch is up to date!

@TJnotJT
Copy link
Author

TJnotJT commented Dec 27, 2024

Closing, as the main problem is to find how much of the texture to read from memory to make up the larger UV coords (based on #10278 and info from refraction).

@TJnotJT TJnotJT closed this Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant