godotengine / godot

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

UV Map Node Ignored in GLTF/GLB Import #93884

Open hristoiankov opened 3 months ago

hristoiankov commented 3 months ago

Tested versions

System information

Windows 10 - Godot v4.2.2.stable - Vulkan (Forward +) - dedicated GPU

Issue description

The UV Map node is ignored in materials in imported gltf/glb models. Godot instead defaults to the first UV Map for all materials.

image

From left to right (Godot, Blender, 3D Viewer): image The above image shows Blender and 3D Viewer rendering the materials using the correct UV map, while Godot is ignoring the assigned UV Map and using the default.

When the UV Map node is removed from the materials, Blender renders the model the same way as it shows up in Godot: image image

Steps to reproduce

  1. Create model with two materials.
  2. Create a second UV Map and assign it to one of the materials.
  3. Save scene as gltf/glb and import into Godot.

Minimal reproduction project (MRP)

From left to right (Godot, Windows 3D Viewer): image

The right image correctly shows the UVMap.001being used for the GreenMaterial. image

cube-2uv-materials.zip

hristoiankov commented 3 months ago

This feature is quite important since most licensed assets have materials setup in this way with a secondary UV Map. Not having this can hold Godot back from competing with the ease of importing marketplace assets in engines like Unreal and Unity.

hristoiankov commented 3 months ago

Godot supports multiple materials for a mesh, but even when those are defined, there is no way to set which UV Map the materials should use. image

There should be a per-texture UV Map selection. image

This selection only exists for the detail texture, but a similar dropdown for the main material Albedo, Metallic, Roughness, Emission, and Normal Map textures would be ideal. image

Once this option is available, the import can be extended to set the UV Map index from the gltf/glb file.

aaronfranke commented 3 weeks ago

Thanks for opening this issue! I've fixed it as much as possible in PR #96748. This doesn't support everything that can possibly be specified in glTF, since that would require changes to Godot's material system (at which point, a proposal would be needed to justify why custom UV assignment, and UV3/UV4/etc, are required in the core engine).