Skip to content
Discussion options

You must be logged in to vote

Internally, Bevy and other plugins do something like this.

const SHADER_HANDLE: HandleUntyped =
	HandleUntyped::weak_from_u64(Shader::TYPE_UUID, /* insert a large random number here */);

// You can use this helper macro as suggested by komadori below :)
load_internal_asset!(
    app,
    SHADER_HANDLE,
    "shader/path.wgsl",
    Shader::from_wgsl
);

// Which expands to the following code.
let mut shaders = app.world.resource_mut::<Assets<Shader>>();
shaders.set_untracked(SHADER_HANDLE, Shader::from_wgsl(include_str!("shader/path.wgsl")));

And then return this handle from fragment_shader().

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@komadori
Comment options

@tesfabpel
Comment options

@tesfabpel
Comment options

Answer selected by tesfabpel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants