Open linkpy opened 2 years ago
I wonder if this should maybe use Rgba16Unorm
.
The PNG image loader only knows that the components are 16-bit unsigned integer, it doesn't know how you want to use it. The PBR material shader binding is configured to always expect a floating point value, whether that is how it is stored, or how it is converted automatically when being sampled.
So, you should be able to load the texture, and when it is loaded, reconfigure it:
if let Some(image) = images.get_mut(image_handle) {
image.texture_descriptor.format = TextureFormat::Rgba16Unorm;
}
If this is part of a model, you may have to delay spawning the model into the world until this change is made.
In future, these friction points would be addressed by a few things:
@cart I think this is an interesting case to consider for asset stuff so just giving you a nudge to inject it into your brain. :)
It's worth noting that this started being an issue for me when upgrading to 0.7, before that point bevy had no issues with my texture files. If this is an intentional breaking change, i haven't seen it noted anywhere
Changes were made to texture stuff between 0.6 and 0.7. I don't think anything should have been changed with respect to PNG textures but perhaps it was. I guess I/someone will have to go digging to find out what changed and why.
Some more information would likely be useful - exactly how are you loading the texture? Is it part of a glTF model or some other kind of model?
Changes were made to texture stuff between 0.6 and 0.7. I don't think anything should have been changed with respect to PNG textures but perhaps it was. I guess I/someone will have to go digging to find out what changed and why.
Some more information would likely be useful - exactly how are you loading the texture? Is it part of a glTF model or some other kind of model?
For my case it's a texture that's part of a .gltf file I load as a scene. Some meshes are fully textured with UV maps etc., and exported from Blender. In 0.6.1 I didn't get any panics loading this scene (although it did look strange, something I suspect is an unrelated lighting issue)
Changes were made to texture stuff between 0.6 and 0.7. I don't think anything should have been changed with respect to PNG textures but perhaps it was. I guess I/someone will have to go digging to find out what changed and why. Some more information would likely be useful - exactly how are you loading the texture? Is it part of a glTF model or some other kind of model?
For my case it's a texture that's part of a .gltf file I load as a scene. Some meshes are fully textured with UV maps etc., and exported from Blender. In 0.6.1 I didn't get any panics loading this scene (although it did look strange, something I suspect is an unrelated lighting issue)
Normals are essential for lighting and have a direct impact. It could be related. Could you share the complete model so I can debug it?
Normals are essential for lighting and have a direct impact. It could be related. Could you share the complete model so I can debug it?
Yeah it's this model here https://github.com/Sheepyhead/diablo_3/blob/main/assets/GameScene.gltf Do note that since it's gltf i think you'll have to pull the whole asset folder to get texturing and such? Not entirely sure there
Edit: i realized the repo is private, I'll open it when I can get to my computer
i realized the repo is private, I'll open it when I can get to my computer
It should now be public
Hello,
I got a similar error with 16 bit RGBA PNGs on Bevy 0.7.0 in my code. So I use the pngtest16rgba.png in examples/2d/sprite.rs
to exclude my code and PNG and got:
2022-06-30T11:24:00.227870Z INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1
2022-06-30T11:24:00.437052Z INFO bevy_render::renderer: AdapterInfo { name: "Quadro GP100", vendor: 4318, device: 5616, device_type: DiscreteGpu, backend: Vulkan }
2022-06-30T11:24:00.704090Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error
Caused by:
In Device::create_bind_group
note: label = `sprite_material_bind_group`
texture binding 0 expects sample type = Float { filterable: true }, but given a view with format = Rgba16Uint
', /home/dev/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:2273:5
same issue in 0.8.0
$ cargo run --release --example sprite
Finished release [optimized] target(s) in 0.48s
Running `target\release\examples\sprite.exe`
2022-08-22T12:05:50.774818Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 760", vendor: 4318, device: 4487, device_type: DiscreteGpu, backend: Vulkan }
2022-08-22T12:05:50.929792Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (1)' panicked at 'wgpu error: Validation Error
Caused by:
In Device::create_bind_group
note: label = `sprite_material_bind_group`
texture binding 0 expects sample type = Float { filterable: true }, but given a view with format = Rgba16Uint
', C:\Users\zhuli\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.13.1\src\backend\direct.rs:2391:5
stack backtrace:
0: 0x7ff79648cc80 - std::backtrace_rs::backtrace::dbghelp::trace::h2ea0ad9cce2df0d1
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\..\..\backtrace\src\backtrace/dbghelp.rs:98:5
1: 0x7ff79648cc80 - std::backtrace_rs::backtrace::trace_unsynchronized::hfefebac16597eb75
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\..\..\backtrace\src\backtrace/mod.rs:66:5
2: 0x7ff79648cc80 - std::sys_common::backtrace::_print_fmt::hc267b8b2be4d51eb
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:66:5
3: 0x7ff79648cc80 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h97dfe3734bd78ac0
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:45:22
4: 0x7ff7964e769a - core::fmt::write::hd8af89fcc4b84ea9
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src\fmt/mod.rs:1196:17
5: 0x7ff79647e873 - std::io::Write::write_fmt::h5a258d575ea478a1
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\io/mod.rs:1654:15
6: 0x7ff7964900a9 - std::sys_common::backtrace::_print::h9f18c5f285430ca3
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:48:5
7: 0x7ff7964900a9 - std::sys_common::backtrace::print::h13e37189638a0ea9
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:35:9
8: 0x7ff7964900a9 - std::panicking::default_hook::{{closure}}::h4ec8f418aad06b88
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:295:22
9: 0x7ff79648fd2d - std::panicking::default_hook::hb983e59d5107ec09
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:314:9
10: 0x7ff7964907c7 - std::panicking::rust_panic_with_hook::ha8688f5446122c27
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:698:17
11: 0x7ff7964906c5 - std::panicking::begin_panic_handler::{{closure}}::h6d391b6ab162e2a1
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:588:13
12: 0x7ff79648d887 - std::sys_common::backtrace::__rust_end_short_backtrace::h084edb22d7398da7
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:138:18
13: 0x7ff7964903f9 - rust_begin_unwind
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:584:5
14: 0x7ff7964e3f45 - core::panicking::panic_fmt::h0d6ac562bda3a0b3
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src/panicking.rs:142:14
15: 0x7ff795bc0d8b - core::ops::function::Fn::call::h9faeb51434f72328
16: 0x7ff795bde8e2 - <wgpu::backend::direct::Context as wgpu::Context>::device_create_bind_group::he5d775ee10d19483
17: 0x7ff795b3d0aa - wgpu::Device::create_bind_group::hfe365393a61ef0db
18: 0x7ff7951f87e0 - bevy_sprite::render::queue_sprites::hcf04d4f590a595e9
19: 0x7ff7951e24e5 - <bevy_ecs::system::function_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe::h38f8f84ec6986ed9
20: 0x7ff79634e1ae - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hfa3128cc6cb09dc3
21: 0x7ff79634dd58 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::ha15c9aa0f49bf44c
22: 0x7ff79635c803 - async_task::raw::RawTask<F,T,S>::run::haf8a27308196db22
23: 0x7ff79636451f - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h4c98051796cb4684
24: 0x7ff7963646df - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hec727a863b834ac2
25: 0x7ff796366dab - std::thread::local::LocalKey<T>::with::hd703f80ddcd0fae6
26: 0x7ff796362d9f - std::sys_common::backtrace::__rust_begin_short_backtrace::ha0d7cfb8177c38fe
27: 0x7ff796369546 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0ac3fa869e785a37
28: 0x7ff7964a0a27 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3130f85cdced461d
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\alloc\src/boxed.rs:1872:9
29: 0x7ff7964a0a27 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h936c849a15702a5f
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\alloc\src/boxed.rs:1872:9
30: 0x7ff7964a0a27 - std::sys::windows::thread::Thread::new::thread_start::h9c9acb7062a70b63
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys\windows/thread.rs:56:17
31: 0x7ffd29bb7034 - <unknown>
32: 0x7ffd2ab62651 - <unknown>
thread 'main' panicked at 'task has failed', C:\Users\zhuli\.cargo\registry\src\github.com-1ecc6299db9ec823\async-task-4.2.0\src\task.rs:425:45
stack backtrace:
0: 0x7ff79648cc80 - std::backtrace_rs::backtrace::dbghelp::trace::h2ea0ad9cce2df0d1
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\..\..\backtrace\src\backtrace/dbghelp.rs:98:5
1: 0x7ff79648cc80 - std::backtrace_rs::backtrace::trace_unsynchronized::hfefebac16597eb75
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\..\..\backtrace\src\backtrace/mod.rs:66:5
2: 0x7ff79648cc80 - std::sys_common::backtrace::_print_fmt::hc267b8b2be4d51eb
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:66:5
3: 0x7ff79648cc80 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h97dfe3734bd78ac0
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:45:22
4: 0x7ff7964e769a - core::fmt::write::hd8af89fcc4b84ea9
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src\fmt/mod.rs:1196:17
5: 0x7ff79647e873 - std::io::Write::write_fmt::h5a258d575ea478a1
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\io/mod.rs:1654:15
6: 0x7ff7964900a9 - std::sys_common::backtrace::_print::h9f18c5f285430ca3
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:48:5
7: 0x7ff7964900a9 - std::sys_common::backtrace::print::h13e37189638a0ea9
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:35:9
8: 0x7ff7964900a9 - std::panicking::default_hook::{{closure}}::h4ec8f418aad06b88
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:295:22
9: 0x7ff79648fd2d - std::panicking::default_hook::hb983e59d5107ec09
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:314:9
10: 0x7ff7964907c7 - std::panicking::rust_panic_with_hook::ha8688f5446122c27
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:698:17
11: 0x7ff7964906c5 - std::panicking::begin_panic_handler::{{closure}}::h6d391b6ab162e2a1
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:588:13
12: 0x7ff79648d887 - std::sys_common::backtrace::__rust_end_short_backtrace::h084edb22d7398da7
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys_common/backtrace.rs:138:18
13: 0x7ff7964903f9 - rust_begin_unwind
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:584:5
14: 0x7ff7964e3f45 - core::panicking::panic_fmt::h0d6ac562bda3a0b3
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src/panicking.rs:142:14
15: 0x7ff7964e3e00 - core::panicking::panic_display::hdf3307d547c52518
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src/panicking.rs:72:5
16: 0x7ff7964e3dab - core::panicking::panic_str::h0a2d1839bb280201
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src/panicking.rs:56:5
17: 0x7ff7964e3ad9 - core::option::expect_failed::h8352bfe516863262
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src/option.rs:1854:5
18: 0x7ff796345223 - <async_task::task::Task<T> as core::future::future::Future>::poll::h244f369aaa90a4ca
19: 0x7ff79634e068 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hee3186c2560ad0f6
20: 0x7ff79634de7c - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hcead4209c8f04c61
21: 0x7ff79635cd98 - async_task::raw::RawTask<F,T,S>::run::hc62fda5c65c8b718
22: 0x7ff79636deac - async_executor::Executor::try_tick::h970fe4406782cd75
23: 0x7ff7963538fa - std::thread::local::LocalKey<T>::with::h31c4999ff9279d4d
24: 0x7ff79632a067 - <bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems::he3428ee2b0df9b71
25: 0x7ff796341443 - <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::hd26e5c1f4566089c
26: 0x7ff795910b44 - <bevy_render::RenderPlugin as bevy_app::plugin::Plugin>::build::{{closure}}::hab93059d97aa0716
27: 0x7ff7963048f1 - bevy_app::app::App::update::hb0c744a0bbf9290e
28: 0x7ff794ec5701 - winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::{{closure}}::h408241fb8e45645b
29: 0x7ff794efe139 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h413b8e3a9e9c28f3
30: 0x7ff794f03323 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::call_event_handler::h1052dbc8fea7b0ae
31: 0x7ff794f03858 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::move_state_to::h267a96a84e0b80ec
32: 0x7ff794efd797 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h1bab47c29b8afbb8
33: 0x7ff794f029b1 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::h35479836470c20de
34: 0x7ff794f08ee0 - winit::platform_impl::platform::event_loop::thread_event_target_callback::h8fc4c62dafeb3c05
35: 0x7ffd28bfe858 - <unknown>
36: 0x7ffd28bfe3dc - <unknown>
37: 0x7ffd28c10bc3 - <unknown>
38: 0x7ffd2abb0d74 - <unknown>
39: 0x7ffd28331704 - <unknown>
40: 0x7ffd28bfe2ea - <unknown>
41: 0x7ff794ec4ae4 - winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::hfb874d08f9e269b0
42: 0x7ff794ec753a - winit::platform_impl::platform::event_loop::EventLoop<T>::run::hf0529f35b9a4e465
43: 0x7ff794ebb4b2 - winit::event_loop::EventLoop<T>::run::hce877604be50e2de
44: 0x7ff794ebc1b2 - bevy_winit::run::h5638b563e86916cd
45: 0x7ff794ebceb7 - bevy_winit::winit_runner_with::h2b91be3cb891a6cc
46: 0x7ff794ee68c3 - core::ops::function::Fn::call::h434b54ef06ca329c
47: 0x7ff796304a0f - bevy_app::app::App::run::h3e7d59e01e9ea04c
48: 0x7ff794ea7806 - sprite::main::h03f2be1e1e8be8ca
49: 0x7ff794ea7896 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5b141749601e847b
50: 0x7ff794ea7eac - std::rt::lang_start::{{closure}}::hc27c162647fdec86
51: 0x7ff79646ecfa - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hc8aba40eff0a2dd0
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\core\src\ops/function.rs:280:13
52: 0x7ff79646ecfa - std::panicking::try::do_call::h6a859b1660e9999f
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:492:40
53: 0x7ff79646ecfa - std::panicking::try::h44b35daefd98b33c
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:456:19
54: 0x7ff79646ecfa - std::panic::catch_unwind::h380d1870ab3409fd
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panic.rs:137:14
55: 0x7ff79646ecfa - std::rt::lang_start_internal::{{closure}}::had3d144ba438b155
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/rt.rs:128:48
56: 0x7ff79646ecfa - std::panicking::try::do_call::h14ca5684185d59a5
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:492:40
57: 0x7ff79646ecfa - std::panicking::try::ha7138efc782d49a1
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panicking.rs:456:19
58: 0x7ff79646ecfa - std::panic::catch_unwind::hc3bf127da9ef51b1
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/panic.rs:137:14
59: 0x7ff79646ecfa - std::rt::lang_start_internal::hcee5d2524f416652
at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src/rt.rs:128:20
60: 0x7ff794ea7878 - main
61: 0x7ff794ea13ae - __tmainCRTStartup
at C:\M\mingw-w64-crt-git\src\crt-x86_64-w64-mingw32\C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt\crtexe.c:329:15
62: 0x7ff794ea14e6 - mainCRTStartup
at C:\M\mingw-w64-crt-git\src\crt-x86_64-w64-mingw32\C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt\crtexe.c:206:9
63: 0x7ffd29bb7034 - <unknown>
64: 0x7ffd2ab62651 - <unknown>
error: process didn't exit successfully: `target\release\examples\sprite.exe` (exit code: 101)
PNG file exported by krita
Update: PNG file exported by Inkscape works fine.
Related: #554 and #1824
In 0.11.2 there is the same issue as well. I tried to change color depth for all 16bit/color materials to 8bit/color via imagemagick (magick <input image> -depth 8 <output image>
) and the model was then partially rendered (parts with affected textures were missing). Don't know why :shrug:
In main branch on commit bdb063497d802b9180d1b608bf54339e5a726b70 it seems the behavior is: meshes with textures with 16bit/color are not rendered (like in my attempt to fix it above). However it doesn't panic.
I think 6c1f4668c7afe20a6ba0657794a4cf51c803c0b8 fixed this.
Bevy version
0.7.0
Operating system & version
Pop_OS! 21.10
What you did
I tried to use a normal texture which has a precision of "16-bit gamma integer".
What you expected to happen
I've expected to have the texture loaded normally and used with a
PbrBundle
.What actually happened
Crash at runtime.
Additional information
I've compared my texture with other textures which work correctly :
Left is the image used by https://github.com/bevyengine/bevy/blob/main/examples/3d/texture.rs and right is the normal texture generating the wgpu validation error. The only difference I found was the precision.
After re-exporting the image to use 8-bit precision, the error is gone.