-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Use embedded_asset to load PBR shaders #19137
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for making this happen! I'm so excited to clean out these weak handles!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for #19139 |
macro_rules! load_embedded_asset { | ||
(@get: $path: literal, $provider: expr) => {{ | ||
let path = $crate::embedded_path!($path); | ||
let path = $crate::AssetPath::from_path_buf(path).with_source("embedded"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we want to name the AssetPath
s given they have a label field for that.
@@ -1345,7 +1345,7 @@ impl From<&StandardMaterial> for StandardMaterialKey { | |||
|
|||
impl Material for StandardMaterial { | |||
fn fragment_shader() -> ShaderRef { | |||
PBR_SHADER_HANDLE.into() | |||
shader_ref(bevy_asset::embedded_path!("render/pbr.wgsl")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like possibly a not so discoverable pattern? I wonder if we should have a clearly-named macro for this particularly and likely common usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good to me. Just left a few comments. If someone wants to merge before I get back to this, I am not opposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to block on the two remaining comments I had.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my limited understanding, this also looks correct :)
@@ -140,7 +207,7 @@ impl EmbeddedAssetRegistry { | |||
#[macro_export] | |||
macro_rules! embedded_path { | |||
($path_str: expr) => {{ | |||
embedded_path!("src", $path_str) | |||
$crate::embedded_path!("src", $path_str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this meant to fix use bevy_asset::embedded_path as [something else]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im not sure why it doesn't work without this.
Objective
Solution
embedded_asset
to load shaders #12009Testing
cargo run --example pbr --features="embedded_watcher"
and edit some pbr shader code