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

GS: Triangle/sprite edge rasterzation to find UV range for draw in SW renderer. #12192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TJnotJT
Copy link

@TJnotJT TJnotJT commented Jan 14, 2025

Description of Changes

This is an addition to the logic for calculating accurate UV ranges to determine texture ranges (currently SW renderer only). To enable accurate UV calculation, we rasterize the edge of triangles or the corners of sprites to determine the max/min UV coordinates to use. In the case of bilinear filtering, we make sure that the +/-1 UV is accurately computed. The changes are still very rough and require some more optimization and cleaning up. I also added some structs to the class GSState to develop this more quickly, which would probably be replaced by the existing structs in the final.

Rationale behind Changes

This is in response to the issue of screan tearing with Tales of Rebirth (#12100). The issues was caused by inaccurate calculation of the UVs for sprite-like triangles (i.e., triangles with axis-aligned coordinates in the form of a rectangle such that the UVs were also axis aligned). The more accurate UV calculation should allows the proper ranges of texture needed for rendering the draw to be accurated calculated and prevent screen tearing. However, the changes also might be overkill if most such problem are only for sprite-like triangles, where the calculation could be done much more quickly than in the general case for 3D triangles, as this PR addresses.

Suggested Testing Steps

This has currently been tested against several homebrews and comparing the min/max UVs against the software renderer rasterization. In all cases checked by hand so far, the only differences with the SW renderer were due to rounding errors of floats. Suggested testing steps is to test this in release against the Tales of Rebirth game and others that are known to have similar issues.

@TJnotJT TJnotJT force-pushed the uv-rounding-hack-raster-clean-4 branch 6 times, most recently from 9320200 to 1cd648d Compare January 15, 2025 01:01
@TJnotJT TJnotJT force-pushed the uv-rounding-hack-raster-clean-4 branch 2 times, most recently from a2352e1 to 0f46019 Compare January 15, 2025 19:09
@TJnotJT TJnotJT force-pushed the uv-rounding-hack-raster-clean-4 branch from 0f46019 to 6697757 Compare January 15, 2025 19:17
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.

2 participants