bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Loading a glTF scene doesn't use the correct UV map for ambient occlusion

Open jf908 opened this issue 10 months ago • 4 comments

Bevy version

0.13.2 and latest main (9592a40e1eb387f926b787cbb3a65d9db1dfb1a3)

Relevant system information

AdapterInfo { name: "NVIDIA GeForce RTX 3070 Ti Laptop GPU", vendor: 4318, device: 9440, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "546.33", backend: Vulkan }

What you did

Load a gltf model with a ambient occlusion lightmap

What went wrong

Expected Actual
https://gltf-viewer.donmccurdy.com/ Bevy Scene Viewer Example
image image

In the example there is a cube mesh and a plane mesh, each with 2 UV maps. One UV map is used for the base colour and one is used for ambient occlusion. The gltf-viewer and three.js read and render the model correctly but not in bevy. The base texture can be seen properly rendered through the broken ambient occlusion texture so I suspect that the ambient occlusion is working but the 2nd UV map is not being used or being read incorrectly.

Additional information

Model used to test: gltf_model.zip

jf908 avatar Apr 24 '24 17:04 jf908

This also has problems with UV-map, but may be different kind

bugsweeper avatar Apr 25 '24 00:04 bugsweeper

It is a similar issue. The material in the file is using a specific texCoord for its occlusionTexture but this is ignored by the gltf loader: https://github.com/bevyengine/bevy/blob/ade70b3925b27f76b669ac5fd9e2c31f824d7667/crates/bevy_gltf/src/loader.rs#L856

But the main issue is that bevy_pbr uses only one texcoord attribute for all textures. So it does not support multiple UV maps at the moment.

geckoxx avatar Apr 25 '24 07:04 geckoxx

I thought with the lightmap update in 0.13, bevy pbr supported 2 UV maps? three.js is hardcoded to use the 2nd UV map for ambient occlusion and lightmap textures and the 1st UV map for everything else. Perhaps bevy could follow the same convention until multiple UV maps become more flexible?

jf908 avatar Apr 25 '24 10:04 jf908

It is a similar issue. The material in the file is using a specific texCoord for its occlusionTexture but this is ignored by the gltf loader

Problem is that baseColorTexture uses TEXCOORD_0, but (!!!) occlusionTexture uses TEXCOORD_1, bevy_pbr does use same ATTRIBUTE_UV_0 for both of them, that's why loader can't load this glb in mesh+StandardMaterial with correct bevy_pbr interpretation

bugsweeper avatar Apr 30 '24 19:04 bugsweeper