KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.48k stars 317 forks source link

T83426: Blender GLTF Exporter - Missing texture filtering #1285

Closed julienduroure closed 3 years ago

julienduroure commented 3 years ago

See https://developer.blender.org/T83426

Broken: version: 2.91.0 Worked: 2.90.1

scurest commented 3 years ago

https://github.com/KhronosGroup/glTF-Blender-IO/blob/5c0bc25d44d13eaf3e901e801c9a1642ada80423/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_sampler.py#L79

This is probably supposed to be LinearMipmapNearest (do linear filtering with the nearest mipmap), not NearestMipmapLinear (do nearest filtering with the two closest mipmaps, then average them).

f3lix-s commented 3 years ago

Changed line 79 as suggested by scurest and it's better now. But something is still missing/wrong please see attatched picture. "2.91.0_mod" is exportet from Blender with line 79 changed to "LinearMipmapNearest".

blender_compare

scurest commented 3 years ago

Try LinearMipmapLinear.

f3lix-s commented 3 years ago

"79 return TextureFilter.LinearMipmapLinear" did the job :)

scurest commented 3 years ago

To explain what happens: Linear has been (incorrectly) exported as NearestMipmapLinear since at least 2.81, but before 2.91 the sampler would be omitted for textures that are Linear/Repeat in Blender. When the sampler is omitted, the viewer picks the filtering on its own. This was changed to fix #307 (texture was Linear in Blender, but sampler was omitted, and a viewer could pick nearest filter); the sampler is now never omitted. That means the viewer is no longer picking the filter to use itself, it's using the one specified in the .gltf file.

scurest commented 3 years ago

@f3lix-s Ah, thanks.

scurest commented 3 years ago

Here is what it looks like in Blender

cube

So yeah, LinearMipmapLinear looks like it's closest, let's do that.

f3lix-s commented 3 years ago

Thank you for your solution and explanations! I am quite new in coding and new in Blender as well. Coming from Cinema 4D with the aim for three.js ...

And this was my first reported bug ever, what an exiting day ;)

scurest commented 3 years ago

@f3lix-s Nice work finding this :)

I opened #1286.