Robert-N7 / abmatt

ANoob's Brres Material Tool for Mario Kart Wii
GNU General Public License v3.0
14 stars 3 forks source link

Broken textures #72

Closed Heath123 closed 3 years ago

Heath123 commented 3 years ago

model.zip Blender: image In game: image

Heath123 commented 3 years ago

If you get very close using Free Look you can see this image

Heath123 commented 3 years ago

Converting it back to DAE and importing it, the UV map is way too big (as expected): https://user-images.githubusercontent.com/13787163/129484517-49ad95f7-8ea9-404a-80c1-3372526d1b3d.mp4

Heath123 commented 3 years ago

Scaling it by 0.00001525 gets it back to about the right position, and 1 / 0.00001525 = 65573.7704918 which is very close to 2 ^ 16 or 65536

Heath123 commented 3 years ago

So it's 65536 times too big

Heath123 commented 3 years ago

Oh: ERROR: Geometry Cylinder#0 divisor 16 out of range image That definitely seems like the problem

Heath123 commented 3 years ago
if self.divisor >= 16:
    AutoFix.error('Geometry {} divisor {} out of range'.format(self.name, self.divisor))
    self.divisor = 0
    result = True

So you set divisor to 0, which would make everything 65536 times bigger than it would be Removing the check fixes it for me, why does it need to be there? (also the warning says geometry but point.py is also used for texture ccordinates)

Robert-N7 commented 3 years ago

I believe this was an issue that I fixed in my development branch, still working to get it passing all checks though... There was an off by one bug detecting the precision needed for texture coordinates, which resulted in using the 16-bit format with a divisor of 16… as you see that fires the check that resets it to 0. You may think it's not necessary but in ctools models it's very common to have invalid divisor values. I'm not sure how it fixed it in your case, as shifting a 16 bit integer 16 times results in... Well nothing

Heath123 commented 3 years ago

I believe this was an issue that I fixed in my development branch, still working to get it passing all checks though... There was an off by one bug detecting the precision needed for texture coordinates, which resulted in using the 16-bit format with a divisor of 16… as you see that fires the check that resets it to 0. You may think it's not necessary but in ctools models it's very common to have invalid divisor values. I'm not sure how it fixed it in your case, as shifting a 16 bit integer 16 times results in... Well nothing

If you want to work out why I attached a model that should reproduce it in the issue

Heath123 commented 3 years ago

You may think it's not necessary

I know it's there for a reason, I just meant I'd need to know what it does to fix it properly