godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.31k stars 19.2k forks source link

glTF import ignores texture scale and rotation (KHR_texture_transform extension) #27375

Closed Roysten closed 3 years ago

Roysten commented 5 years ago

Godot version: 3.1 stable

OS/device including version: Windows 10

Issue description: In Blender 2.8 I created a simple material which uses a texture and a bump map. Using a Blender mapping node I scale this texture down. It seems this mapping node is ignored completely by Godot. The online gltf viewer shows it as: Screen Shot 2019-03-24 at 14 30 11

Whereas Godot shows it as: image As you can see the grass is not scaled down (I scaled it to 0.01 of the original size): image

I am just starting using Blender and Godot, so I would not be surprised if I did something wrong, but I think it is strange the online glTF viewer manages to show it correctly and Godot does not. Steps to reproduce: Just create a texture and scale it using the mapping node of Blender 2.8. I also tried rotating the texture and this also does not seem to work.

Minimal reproduction project: AWE.zip

Roysten commented 5 years ago

OK, so I managed to fix it by scaling my UV map rather than using the mapping in the shader editor shown above. Apparently using the mapping causes Blender to export the scene using the glTF extension KHR_texture_transform. My assumption is that Godot does not support this extension. Is this feature planned? If not, I think it is useful to notify the user about any extensions present in the glTF that are not supported by the import functionality.

henkz1 commented 5 years ago

edit: Didn't see your comment before commenting.. Not really a bug I guess, the blender exporter exports mapping nodes using the KHR_texture_transform extension, which godot importer doesn't support. I don't think it couldn't be fully supported since this should be per texture and you can only apply transform per uv channel (limited to two).

julienduroure commented 5 years ago

I confirm that I have the same issue here, and I confirm that this is probably link to non support of KHR_texture_transform. Here is my own minimal file: godot_texture.glb.zip

(I have the .blend file if needed). File tested on https://gltf-viewer.donmccurdy.com/ to check that the file is OK

kalbfled commented 4 years ago

I encountered this glTF issue using Blender 2.79b on Ubuntu. As the issue pertains to a common use case, I hope an enhancement makes it into Godot.

I tried working around it by exporting to OBJ and DAE (using the Better Collada Exporter), but those outputs are not importing in Godot as I expect--no texture at all. This might be user error, as I'm new to Godot.

fire commented 4 years ago

I have a fix for this, but it's risky to put in. @akien-mga What do you think about putting this for 3.2?

There's a combination of patches:

https://github.com/fire/godot/commit/14042c40f8725be34c70411d0178496b2b1ca6ec#diff-b9e261ea984d6af20869d0e1301a9378R3318-R3332

This is a bugfix for the previous.

https://github.com/fire/godot/commit/969c0dee29ce4d383cf632ae2f3074ce2fcc6630

fire commented 4 years ago

Note that this is an extension to gltf2. https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform

kitaedesigns commented 3 years ago

Did this issue ever get resolved? I am using blender with my shader set to scale according to the blender doc gltf settings and still not seeing the scaling I apply on my normal map in the exported glb. Would have to change all my UVs for just a simple scaled normal map.

scaleIssue

akien-mga commented 3 years ago

It's solved by #34193 in the master branch (Godot 4.0).

MarieGrasmeier commented 7 months ago

Still have the exact same issue with Godot 4.1.1 and Blender 4.0 Edit: scaling the UV instead of using the mapping node fixes the problem