mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
shader_def: use to_upper instead of to_screaming_snake
This commit is contained in:
parent
4d17763c85
commit
e523dc92d8
4 changed files with 10 additions and 10 deletions
|
@ -151,10 +151,10 @@ pub fn derive_uniforms(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
let struct_name = &ast.ident;
|
let struct_name = &ast.ident;
|
||||||
let struct_name_string = struct_name.to_string();
|
let struct_name_string = struct_name.to_string();
|
||||||
let struct_name_screaming_snake = struct_name.to_string().to_screaming_snake_case();
|
let struct_name_uppercase = struct_name.to_string().to_uppercase();
|
||||||
let field_infos_ident = format_ident!("{}_FIELD_INFO", struct_name_screaming_snake);
|
let field_infos_ident = format_ident!("{}_FIELD_INFO", struct_name_uppercase);
|
||||||
let vertex_buffer_descriptor_ident =
|
let vertex_buffer_descriptor_ident =
|
||||||
format_ident!("{}_VERTEX_BUFFER_DESCRIPTOR", struct_name_screaming_snake);
|
format_ident!("{}_VERTEX_BUFFER_DESCRIPTOR", struct_name_uppercase);
|
||||||
|
|
||||||
let active_uniform_field_names = active_uniform_fields
|
let active_uniform_field_names = active_uniform_fields
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -342,7 +342,7 @@ pub fn derive_uniforms(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
Some(potential_shader_defs.drain(..)
|
Some(potential_shader_defs.drain(..)
|
||||||
.filter(|(f, shader_def)| shader_def.is_some())
|
.filter(|(f, shader_def)| shader_def.is_some())
|
||||||
.map(|(f, shader_def)| format!("{}_{}{}", #struct_name_screaming_snake, f, shader_def.unwrap()))
|
.map(|(f, shader_def)| format!("{}_{}{}", #struct_name_uppercase, f, shader_def.unwrap()))
|
||||||
.collect::<Vec<String>>())
|
.collect::<Vec<String>>())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ fn main() {
|
||||||
.add_defaults()
|
.add_defaults()
|
||||||
.setup_render_graph(|render_graph_builder| {
|
.setup_render_graph(|render_graph_builder| {
|
||||||
render_graph_builder
|
render_graph_builder
|
||||||
.add_resource_provider(UniformResourceProvider::<MyMaterial>::new())
|
.add_resource_provider(UniformResourceProvider::<MyMaterial>::new(true))
|
||||||
.add_pipeline_to_pass(resource_name::pass::MAIN, "MyMaterial", |builder| {
|
.add_pipeline_to_pass(resource_name::pass::MAIN, "MyMaterial", |builder| {
|
||||||
builder
|
builder
|
||||||
.with_vertex_shader(Shader::from_glsl(
|
.with_vertex_shader(Shader::from_glsl(
|
||||||
|
@ -45,13 +45,13 @@ fn main() {
|
||||||
void main() {
|
void main() {
|
||||||
o_Target = color;
|
o_Target = color;
|
||||||
|
|
||||||
# ifdef MY_MATERIAL_ALWAYS_RED
|
# ifdef MYMATERIAL_ALWAYS_RED
|
||||||
o_Target = vec4(0.8, 0.0, 0.0, 1.0);
|
o_Target = vec4(0.8, 0.0, 0.0, 1.0);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
))
|
))
|
||||||
.with_standard_config();
|
.with_default_config();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.setup_world(setup)
|
.setup_world(setup)
|
||||||
|
|
|
@ -236,7 +236,7 @@ impl<'a> PipelineBuilder<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_standard_config(&mut self) -> &mut Self {
|
pub fn with_default_config(&mut self) -> &mut Self {
|
||||||
self.with_depth_stencil_state(DepthStencilStateDescriptor {
|
self.with_depth_stencil_state(DepthStencilStateDescriptor {
|
||||||
format: TextureFormat::Depth32Float,
|
format: TextureFormat::Depth32Float,
|
||||||
depth_write_enabled: true,
|
depth_write_enabled: true,
|
||||||
|
|
|
@ -27,14 +27,14 @@ layout(set = 2, binding = 1) uniform StandardMaterial_albedo {
|
||||||
vec4 Albedo;
|
vec4 Albedo;
|
||||||
};
|
};
|
||||||
|
|
||||||
# ifdef STANDARD_MATERIAL_ALBEDO_TEXTURE
|
# ifdef STANDARDMATERIAL_ALBEDO_TEXTURE
|
||||||
layout(set = 3, binding = 1) uniform texture2D StandardMaterial_albedo_texture;
|
layout(set = 3, binding = 1) uniform texture2D StandardMaterial_albedo_texture;
|
||||||
layout(set = 3, binding = 2) uniform sampler StandardMaterial_albedo_texture_sampler;
|
layout(set = 3, binding = 2) uniform sampler StandardMaterial_albedo_texture_sampler;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 albedo = Albedo;
|
vec4 albedo = Albedo;
|
||||||
# ifdef STANDARD_MATERIAL_ALBEDO_TEXTURE
|
# ifdef STANDARDMATERIAL_ALBEDO_TEXTURE
|
||||||
albedo *= texture(
|
albedo *= texture(
|
||||||
sampler2D(StandardMaterial_albedo_texture, StandardMaterial_albedo_texture_sampler),
|
sampler2D(StandardMaterial_albedo_texture, StandardMaterial_albedo_texture_sampler),
|
||||||
v_Uv);
|
v_Uv);
|
||||||
|
|
Loading…
Reference in a new issue