bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Gltf texture not rendering properly

Open hchockarprasad opened this issue 1 year ago • 5 comments

Bevy version

Bevy main.

AdapterInfo { name: "NVIDIA GeForce 3060", device_type: DiscreteGpu, }

What you did

Tried to use a glb scene exported from unreal.

What went wrong

I tried to use it in bevy and the textures looks odd. Have tried in scene-viewer as well. But in GLTF viewer & blender it works well.

Additional information

In bevy:

Screenshot 2024-03-15 220427

In GLTF viewer Screenshot 2024-03-15 221437

wall.glb.zip

hchockarprasad avatar Mar 15 '24 16:03 hchockarprasad

Can you upload the glb file as an attachment to this issue so we can reproduce and investigate? You may need to zip it first.

alice-i-cecile avatar Mar 15 '24 17:03 alice-i-cecile

The link to file https://github.com/hchockarprasad/trybv/blob/main/assets/wall.glb

hchockarprasad avatar Mar 15 '24 17:03 hchockarprasad

You can make better image (I mean colors) if you play with key L (which switches animation of light direction) in bevy scene viewer, because darkness of wall is light problem. Looks like issue problem relates to coordinates of texture (uv?) image And if you export this glb to gltf (by blender for example), you will see, that texture is same as in bevy scene viewer MI_brick_01_Inst_SM_wall_01_BaseColor some how blender knows that not all texture should be placed on face surface, but only quarter

bugsweeper avatar Apr 03 '24 10:04 bugsweeper

I ensured that no KHR_texture_transform extension in this file. Blender plugin doesnt see it also. gltf crate inside bevy reads TEX_COORS without modifications (it's equal to coresponding buffer data from exported bin-file after read). Looks like some postprocessing is missing. For this file exact quarter .map(|[u, v]| [u / 2.0 + 0.5, v / 2.0]) works pretty well but is too strange and ugly.

bugsweeper avatar Apr 05 '24 14:04 bugsweeper

The glTF Validator reports TEXCOORD_0 is not used. The materials in that file are using TEXCOORD_1 instead. But the gltf loader ignores that: https://github.com/bevyengine/bevy/blob/ade70b3925b27f76b669ac5fd9e2c31f824d7667/crates/bevy_gltf/src/loader.rs#L825

Because bevy_pbr always uses TEXCOORD_0 for all textures (except for lightmaps).

geckoxx avatar Apr 25 '24 06:04 geckoxx

Got such view with #13153 change image

bugsweeper avatar May 01 '24 05:05 bugsweeper