Allow custom import paths for hot-reloadable shaders
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
As far as I understand there are currently two ways to load shaders for a custom material (lets say 2d case):
1. Generate a ShaderRef from a path in your Material2d::fragment_shader() implementation
or
2. Use `Shader::from_wgsl` and add the result into Assets (using a user-defined weak handle).
In my understanding only shaders created with (1) can be hot-reloaded (as with method 2 bevy doesn't know the filename).
OTOH, only shaders loaded with method (2) can define custom import paths (such as allowing shaders to `#import` local shader files which can be quite helpful for structuring complex shaders).
## What solution would you like?
I would like a way to either
a) Set import paths for ShaderRefs
or
b) Create `Shader` instances that are hot-reloadable
## What alternative(s) have you considered?
A way of setting global naga_oil import paths in bevy would be a good alternative, but I haven't found one.
## Additional context
Contributor guide
Research direction
Start by tracing the two entry points described: Material2d::fragment_shader() producing a ShaderRef, and Shader::from_wgsl added to Assets. Compare how each path handles hot reloading and custom naga_oil import paths. Done means one supported approach provides both hot reloadability and configurable import paths, with the behavior covered by relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics, game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100