warenhuis / Crash-Bandicoot-2-Modelexport

13 stars 1 forks source link

UV positions slightly off after import, causing Z-fighting on some faces #5

Closed ghost closed 8 years ago

ghost commented 8 years ago

This issue is happening due to two reasons:

The loss of accuracy can be solved by "padding" the outermost pixels, by stretching them at least 1 pixel more in all directions.

Said method also requires adjustments the UV coordinate calculator, to shift the UV coordinates of adjacent parts by at least 1 pixel to accommodate for the padding.

Example: http://i.imgur.com/HOeoeUq.png

ghost commented 8 years ago

If you would prefer the texture's parts to look accurate when viewed as an image, an alternative solution would be to double the size of all texture parts.

But this would require texture part packing optimisation, because a 4096x4096-sized texture would be absurd.

warenhuis commented 8 years ago

Thank you for submitting this issue. The problem was not so much an issue of padding or Blender itself, but how to handle UV triangles where 2 out of 3 coordinates were identical. This causes an UV triangle to be an 1-dimensional line, which is causing the z-fighting in the model view.

As a measure, I have implemented an upscaling mechanism, so that instead of a flat 1D-line, the triangle becomes 1 pixel thick. And indeed, you access extra parts of the texture for that (the sample you showed here is not 34 x 66, but 33 x 65). Here's a before-after example of what has changed: image You should get these results after redownloading the tool. I'm not sure if this is a 100% failsafe measure, so let me know if you stumble upon anymore z-fighting.

ghost commented 8 years ago

Ah! Right, thanks for clearing that up. I had the entirely wrong idea on the issue. I'll try it out soon!

ghost commented 8 years ago

Now there seems to be another UV issue, but I'm unsure if the issue is due to my mishandling of Blender or not so I'll just upload the scene and render as an archive: https://mega.nz/#!hwJkAAgC!xV_kFTUpvjP_DVWPqZOaZ_Imq_bYxkIql6OChy2yHds Notice the black spot near the end of the front wheel fender and the sides of the fork.

ghost commented 8 years ago

Never mind, the issue seems to be Blender's rendering. The UVs are accurate enough to have the model's materials baked into a texture as I hoped.