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

floor rendering fix #48

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

floor rendering fix #48

wants to merge 1 commit into from

Conversation

zZeck
Copy link

@zZeck zZeck commented Apr 11, 2021

The original code has insufficient precision in the xstep and ystep used for floor/ceiling. This lack of precision results in very visible error accumulating as DrawRow renders left to right. Look at the distortion on the right side in the original.
Original
floorDistorted
Improved
floorFixed

Credit to a 2019 Kaiser tweet for pointing out the problem.

It would be nice if #42 went in ahead of this. I did a hackier work around the same mingw-w64 problem for w_wad.c.


while (count--) {
/* extract the x/y coordinates */
coord = ((frac >> (32-7)) | ((frac >> (32-23)) << 7)) & 16383;
coord = ((yfrac >> 24) & 0b00000001111111) | (( xfrac >> 17) & 0b11111110000000);
Copy link
Author

Choose a reason for hiding this comment

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

Binary constants are not standard C, but it makes the code easier to understand. I can change this if needed.

@Calinou
Copy link

Calinou commented Nov 2, 2021

I can confirm this PR works as expected:

image

@zZeck
Copy link
Author

zZeck commented Nov 2, 2021

In hindsight, I should have made the comparison images on a level with straight lines in the floor texture. Thanks for vouching for the PR. Planning on doing anything else in ROTT?

@Calinou
Copy link

Calinou commented Nov 2, 2021

Planning on doing anything else in ROTT?

I don't have much in mind right now, but maybe I'll contribute QOL improvements in the future 🙂

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.

2 participants