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

softgpu: Round tex coords properly for nearest #8282

Merged
merged 1 commit into from
Dec 21, 2015

Conversation

unknownbrackets
Copy link
Collaborator

Fixes #4853 - off-by-one errors in rendering certain textures.

This rounds up at 0.625, which I think is the correct behavior, from my tests of the PSP's GPU in general. It fixes the examples I had collected of this issue, anyway.

Before, it was always rounding down.

-[Unknown]

Fixes off-by-one errors in rendering certain textures.
hrydgard added a commit that referenced this pull request Dec 21, 2015
softgpu: Round tex coords properly for nearest
@hrydgard hrydgard merged commit 949fc8f into hrydgard:master Dec 21, 2015
@unknownbrackets unknownbrackets deleted the softgpu branch December 22, 2015 02:23
int u = (int)(s * width);
int v = (int)(t * height);
int u = (int)(s * width + 0.375f);
int v = (int)(t * height + 0.375f);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turns out this is wrong. In fact, I think we are half a pixel off for bilinear (i.e. a 0,0 -> 1,1 box will apply 50% of texel 1,1 in the center, which is of course wrong.)

-[Unknown]

Copy link
Owner

Choose a reason for hiding this comment

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

That's interesting - I hadn't considered the possibility that the offset might need to be different in each of the filtering modes - who knows how they are implemented.

Copy link
Collaborator Author

@unknownbrackets unknownbrackets May 7, 2017

Choose a reason for hiding this comment

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

Well, AFAICT it's just 0 for nearest (seems to round right at 0.5) and -0.5 for linear (to sample at the centers.) Need to check some throughmode handling still when I have time.

I did try applying a 0.375f / 256.0f offset to correct for rounding issues, which seemed to largely help most everywhere (including Crisis Core.) And with that the Hexyz issue doesn't happen either (probably the same rounding issue.) However, it introduces other issues...

Also tex wrap with negative float uvs was wrong.

-[Unknown]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Software renderer off-by-one errors
2 participants