vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
458 stars 72 forks source link

[BUG]Export Obj #138

Closed Omega1975 closed 2 years ago

Omega1975 commented 2 years ago

to reproduce the problem upload the attached glb file and export it in obj format. EAMES_STRIPES.zip

this is the obj exported test.zip

S.O. Windows 11 SharpGLTF from source (github cloned 19/02/2022 )

vpenades commented 2 years ago

eames_stripes.zip is an obj already

Omega1975 commented 2 years ago

Sorry. This is the right file EAMES_STRIPES.zip

Omega1975 commented 2 years ago

EAMES_SCOTTISH_YELLOW.zip I recompiled the sources, now the extension of the first texture is correct but the scales and rotation of the textures in the obj file are not. Attached is the glb file and the obj file obtained from exporting with the sharpgltf library. The differences between glb and obj are visible in the attached images.

vpenades commented 2 years ago

Reviewing your model, your source GLB uses materials that apply a transform to the texture, something like this:

"KHR_texture_transform": {
            "scale": [
              0.13846579,
              0.12745348
            ] }

As it happens, Wavefront OBJ is a very old format and it's missing lots of modern features, one of them is texture transform.

So what you're seeing is the consequence of not being able to export all the details of a glTF material into a Wavefront material.

Omega1975 commented 2 years ago

uvscale.zip Attached the same obj with uv scale equal to one tenth with respect to each other. Comparing the obj files you can see how the difference in scale translates into a scaling of the values of the vt lines. For eaxample

Original file --> new file vt -27.73200 0.00000 -> vt -2.77320 0.00000 vt 0.00000 -15.70900 -> vt 0.00000 -1.57090

Omega1975 commented 2 years ago

News? this bug has it been corrected?

vpenades commented 2 years ago

I am going to be busy at work for the rest of the month, so I doubt I'll be able to visit this issue soon.

Also, as I stated in my last response, this issue happens becase WaveFront is missing several features in its material structure... so this issue cannot be considered "a bug".

This doesn't mean it can't be fixed, but it's not trivial because I need to pre-transform the mesh UVs by the materials... but in this case, it would not be "fixing a bug" but a feature: "overcoming a wavefront format limitation"

Omega1975 commented 2 years ago

Thanks for the quick reply. I am aware that "fixing" this "bug" is no small thing. I await the change. thank you.