Implement a more accurate algorithm for z interpolation #2000
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements a more accurate model for z interp which results in closely replicating the precision loss.
The amount of precision lost is directly correlated to how wide a polygon is.
This behavior seems to only apply to interpolation along x?
One theory I have is that it takes the difference between the left and right depth value and right shifts by 1. Followed by, in the case where z0 > z1, adding the remainder of the division of (z0-z1) and xdiff towards the end of the process.
Note: there are a few alternative ways to do this, while still getting an equivalent result. Such as by left shifting xdiff by 1 before division.
Some samples:
![image](https://private-user-images.githubusercontent.com/102590697/313504235-a971c520-f92f-49e5-9386-1b85fd7d3b21.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxMDQ2NTAsIm5iZiI6MTcyMDEwNDM1MCwicGF0aCI6Ii8xMDI1OTA2OTcvMzEzNTA0MjM1LWE5NzFjNTIwLWY5MmYtNDllNS05Mzg2LTFiODVmZDdkM2IyMS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzA0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwNFQxNDQ1NTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03MzM3NDAwYWQzZWRlYTdlNmE4NTM5N2RjMTE2NmJiYjhhNTEwY2EyN2ViOTY3NjJmYzhhNjBlMGRlOWU3ZWUxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.gzNI9JBWbC9MaDiKWTp32dZ0et8-38KxAb-xB_rYY64)
![image](https://private-user-images.githubusercontent.com/102590697/313504255-d28016c5-0152-467f-8501-a4aa4848b363.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxMDQ2NTAsIm5iZiI6MTcyMDEwNDM1MCwicGF0aCI6Ii8xMDI1OTA2OTcvMzEzNTA0MjU1LWQyODAxNmM1LTAxNTItNDY3Zi04NTAxLWE0YWE0ODQ4YjM2My5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzA0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwNFQxNDQ1NTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00OTNhNGVmZDA0NjZhNTc0N2NiMjFhOWE4ZDU0NDc5NmQ5YWFmMzU5NDM1MDAzYzc3OGJhOTczNjFiZmVhOGQyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.UsU4GUwn79jL6MJa_8ts3kuFrvs0vHjtNQN9aWUCzos)
before > after > console