bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.12k stars 3.45k forks source link

Misleading error message if wgsl import has bad path #12337

Open torsteingrindvik opened 6 months ago

torsteingrindvik commented 6 months ago

Bevy version

Relatively new: 499c978

What you did

I have a wgsl shader which at the start has:

#import bevy_ui::ui_vertex_output::UiVertexOutput
#import bevy_pbr::rand_f

What went wrong

When trying to use rand_f, an error happens:

2024-03-06T10:39:12.086331Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader:
error: required import 'bevy_pbr' not found
   ┌─ foo.wgsl:14:17
   │
14 │     let noise = rand_f(&rng);
   │                 ^
   │
   = missing import 'bevy_pbr'

Additional information

Theories

While typing out this issue I realized my mistake.

The import should be

#import bevy_pbr::utils::rand_f

not

#import bevy_pbr::rand_f

Suggested fix

Improve the error message to state that bevy_pbr::rand_f does not exist, not the current message which is misleading.

JMS55 commented 6 months ago

Needs to be filed under https://github.com/bevyengine/naga_oil