add shader_def to albedo ColorSource and auto import trait in macro

This commit is contained in:
Carter Anderson 2020-02-18 19:08:17 -08:00
parent b809b22589
commit a1b9e3a7a5
2 changed files with 2 additions and 0 deletions

View file

@ -159,6 +159,7 @@ pub fn derive_uniforms(input: TokenStream) -> TokenStream {
// TODO: this will be very allocation heavy. find a way to either make this allocation free
// or alternatively only run it when the shader_defs have changed
fn get_shader_defs(&self) -> Option<Vec<String>> {
use bevy::render::render_graph::ShaderDefSuffixProvider;
let mut potential_shader_defs: Vec<(&'static str, Option<&'static str>)> = vec![
#((#shader_def_field_name_strs, self.#shader_def_field_names.get_shader_def()),)*
];

View file

@ -5,6 +5,7 @@ use bevy_derive::Uniforms;
#[derive(Uniforms)]
pub struct StandardMaterial {
#[uniform(shader_def)]
pub albedo: ColorSource,
}