bevyengine / bevyengine/bevy

Shader imports fail silently when loaded using Shader::from_wgsl

Open
#3,749 5 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

Main f3de12bc

## Operating system & version

Windows 11

## What you did

1. Edited the mesh2d_manual example and added `#import "./doesnotexist.wgsl"` into the shader string.

```diff
diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs
index 37164583..47677919 100644
--- a/examples/2d/mesh2d_manual.rs
+++ b/examples/2d/mesh2d_manual.rs
@@ -215,8 +215,9 @@ type DrawColoredMesh2d = (

// The custom shader can be inline like here, included from another file at build time
// using `include_str!()`, or loaded like any other asset with `asset_server.load()`.
-const COLORED_MESH2D_SHADER: &str = r"
+const COLORED_MESH2D_SHADER: &str = r#"
// Import the standard 2d mesh uniforms and set their bind groups
+#import "./doesnotexist.wgsl"
#import bevy_sprite::mesh2d_view_bind_group
[[group(0), binding(0)]]
var view: View;
@@ -258,7 +259,7 @@ struct FragmentInput {
fn fragment(in: FragmentInput) -> [[location(0)]] vec4 {
return in.color;
}
-";
+"#;

/// Plugin that renders [`ColoredMesh2d`]s
pub struct ColoredMesh2dPlugin;
```

Without quotes, I also get the proper error message

2. `cargo run --example mesh2d_manual`

## What you expected to happen

I suspect that path includes probably aren't supported when loading using Shader::from_wgsl, but I'd expect some kind of error message.

## What actually happened

No error is printed, the window opens, but the star in the mesh2d_manual example is not visible.

## Additional information

If I load using AssetServer::load, an error is printed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.