Skip to content
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

Introduce ShaderModel. #977

Merged
merged 7 commits into from
Sep 10, 2024
Merged

Conversation

tychedelia
Copy link
Collaborator

Introduces the nannou specific trait ShaderModel, as well as a convenient attribute macro #[shader_model] that can be used to generate the bevy boilerplate derives needed for implementing Material.

Although Material is used to drive much of the bevy ecosystem, including it in our public api and examples couples us too tightly to the bevy pbr pipeline. It's also confusing, because while we ask users to implement things from the trait like fragment and vertex shaders, there's a ton of additional features included in this trait that they would not want to touch.

As such, the nannou trait ShaderModel is a simple trait that specifies which shaders to use, as well as adding all the required bounds to make everything work. Users can implement this themselves, but can also use the macro as such:

// This struct defines the data that will be passed to your shader
#[shader_model(fragment = "draw_custom_material.wgsl")]
struct ShaderModel {
    #[uniform(0)]
    color: LinearRgba,
}

Additionally, this will help future extensions, like supporting indirect drawing in compute shaders, where we do not want to depend directly on T: Material but instead T: AsBindGroup.

Other changes:

  • Removes the nightly feature and init_fragment_shader experiment. While this is cool, we want to focus on making ShaderModel the first class way to interact with these apis.

@tychedelia tychedelia merged commit 6f2532a into nannou-org:bevy-refactor Sep 10, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant