Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when loading a gltf model. #6710

Closed
AllenDang opened this issue Nov 21, 2022 · 9 comments
Closed

Crash when loading a gltf model. #6710

AllenDang opened this issue Nov 21, 2022 · 9 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash

Comments

@AllenDang
Copy link

Bevy version

0.9.0

What you did

Spawn a scene from a glb file and bevy crashed.

Error message is

❯ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.27s
     Running `target/debug/model_explorer`
2022-11-21T10:54:26.688105Z  INFO bevy_render::renderer: AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2022-11-21T10:54:29.985476Z  INFO model_explorer: loading...
2022-11-21T10:54:30.241790Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default    
thread 'Compute Task Pool (3)' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_bind_group
    texture binding 9 expects sample type = Float { filterable: true }, but given a view with format = Rgba16Uint

', /Users/allen/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.14.0/src/backend/direct.rs:2403:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'task has failed', /Users/allen/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.3.0/src/task.rs:426:43

It could be rendered normally via gltf viewer.

image

Here is the glb file leads to the crash.
PIPIXIA.glb.zip

@AllenDang AllenDang added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 21, 2022
@nicopap nicopap added A-Rendering Drawing game state to the screen A-Assets Load files from disk to use for things like images, models, and sounds and removed S-Needs-Triage This issue needs to be labelled labels Nov 21, 2022
@james7132 james7132 added the P-Crash A sudden unexpected crash label Nov 22, 2022
@AllenDang
Copy link
Author

@nicopap I know the core dev of bevy may not have time to fix it now, I'm wondering if you or anyone could give me a hint about where should I start to look at, I could start fixing this and contribute a PR.

@nicopap
Copy link
Contributor

nicopap commented Nov 29, 2022

It looks like the texture format is the culprit here, try saving the model textures in a different format

@AllenDang
Copy link
Author

@nicopap This model could be normally imported and rendered in various engines including Godot/Unreal/Unity/Raylib, so I'm thinking about to fix the compatibility of bevy.

@nicopap
Copy link
Contributor

nicopap commented Dec 1, 2022

I'm not sure what is causing this. I think you might some luck looking at the code that the following PR changed #5527

Otherwise, it would be in the GLTF loader (bevy_gltf/src/loader.rs iirc) you'd need to make sure the image data is properly handled when the GLTF is loaded.

@mockersf
Copy link
Member

mockersf commented Dec 1, 2022

One of the texture in the glb file is in a format not expected by Bevy. If I manually convert it to another format, it renders:
Screenshot 2022-12-01 at 18 51 08

Short term, you can use the converted glb file here: PIPIXIA-converted.glb.zip
(I'm not very good at image conversion, so I also compressed it. I didn't notice any worse quality)

Longer term, Bevy could convert the texture when loading the glb file to a supported format

@AllenDang
Copy link
Author

@mockersf Can you tell me which texture causes this issue?

@mockersf
Copy link
Member

mockersf commented Dec 2, 2022

I think it was the normals

@AllenDang
Copy link
Author

@mockersf Thanks, I'll see what I can do there.

github-merge-queue bot pushed a commit that referenced this issue Sep 6, 2023
# Objective

fix  #8185, #6710
replace #7005 (closed)

rgb and rgba 16 bit textures currently default to `Rgba16Uint`, the more
common use is `Rgba16Unorm`, which also matches the default type of rgb8
and rgba8 textures.

## Solution

Change default to `Rgba16Unorm`
@nicopap
Copy link
Contributor

nicopap commented Sep 9, 2023

Should be fixed by #9611

@nicopap nicopap closed this as completed Sep 9, 2023
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this issue Jan 9, 2024
…9611)

# Objective

fix  bevyengine#8185, bevyengine#6710
replace bevyengine#7005 (closed)

rgb and rgba 16 bit textures currently default to `Rgba16Uint`, the more
common use is `Rgba16Unorm`, which also matches the default type of rgb8
and rgba8 textures.

## Solution

Change default to `Rgba16Unorm`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants