Skip to content

floor rendering fix - #48

Open
zZeck wants to merge 1 commit into
LTCHIPS:masterfrom
zZeck:floor-fix
Open

floor rendering fix#48
zZeck wants to merge 1 commit into
LTCHIPS:masterfrom
zZeck:floor-fix

Conversation

@zZeck

@zZeck zZeck commented Apr 11, 2021

Copy link
Copy Markdown

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.

Comment thread src/rt_floor.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
Copy Markdown
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

Calinou commented Nov 2, 2021

Copy link
Copy Markdown

I can confirm this PR works as expected:

image

@zZeck

zZeck commented Nov 2, 2021

Copy link
Copy Markdown
Author

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

Calinou commented Nov 2, 2021

Copy link
Copy Markdown

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