Neos-Metaverse / NeosPublic

A public issue/wiki only repository for the NeosVR project
193 stars 9 forks source link

Respect glTF sampler.wrapS/wrapT behavior #2172

Open uyjulian opened 3 years ago

uyjulian commented 3 years ago

Is your tweak request related to a problem? Please describe.

When a glTF file is imported, the texture wrap mode is always set to repeat, ignoring the sampler.wrapS/wrapT value in the glTF file.

Describe what would you like tweaked

Neos should read the sampler.wrapS/wrapT value in the glTF file so that it will set the texture wrap mode correctly.
Relevant section from the glTF specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#samplerwraps
Sample file that uses those values: https://github.com/KhronosGroup/glTF-Sample-Models/raw/0bc2ad7535aba4e16fb1afba1f85fd827bbbea6d/2.0/TextureSettingsTest/glTF-Binary/TextureSettingsTest.glb

Describe alternatives you've considered

For mirror mode to repeat mode, setting 1-v for negative values is a suitable workaround for some cases. However, in other cases, like crossing the 0 barrier, it will break the UVs.

Additional context

(Screenshot between Microsoft 3D Viewer and Neos to be placed here)

Frooxius commented 3 years ago

We are not reading/handling glTF format ourselves, that's done through the Assimp library, the support this needs to be added there: https://github.com/assimp/assimp

We're currently 371 commits behind the master: https://github.com/Neos-Metaverse/assimp

I'm not sure if the support for this was added in the meanwhile. I can update the library to latest commit and see, if you'd like to check it yourself you can. We might need to create an issue on Assimp for this if it's not supported on their end.

uyjulian commented 3 years ago

It seems like assimp already supports wrapS/wrapT: https://github.com/assimp/assimp/blob/96d0524fab2173a4198f12cd45501af65ac94261/code/AssetLib/glTF2/glTF2Importer.cpp#L201

I guess what's left is to hook up the wrapping mode.

Frooxius commented 3 years ago

I've updated to the latest commit of Assimp in 2021.5.13.384, but it doesn't seem like it actually fixed the issue. Neos is still seemingly getting "Repeat" wrap mode for all the texture slots.

Not sure what could be causing this, could be either that Assimp doesn't import it correctly or that the .NET wrapper doesn't properly convert the values.

It'll unfortunately need more investigation.