Skip to content

Commit

Permalink
update shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
mrk-its committed Nov 5, 2020
1 parent e76f56b commit bf4b6fa
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 40 deletions.
13 changes: 6 additions & 7 deletions crates/bevy_render/src/shader/shader_reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,15 @@ mod tests {
let vertex_shader = Shader::from_glsl(
ShaderStage::Vertex,
r#"
#version 450
layout(location = 0) in vec4 Vertex_Position;
layout(location = 1) in uvec4 Vertex_Normal;
layout(location = 2) in uvec4 I_TestInstancing_Property;
LAYOUT(location = 0) in vec4 Vertex_Position;
LAYOUT(location = 1) in uvec4 Vertex_Normal;
LAYOUT(location = 2) in uvec4 I_TestInstancing_Property;
layout(location = 0) out vec4 v_Position;
layout(set = 0, binding = 0) uniform Camera {
LAYOUT(location = 0) out vec4 v_Position;
BLOCK_LAYOUT(set = 0, binding = 0) uniform Camera {
mat4 ViewProj;
};
layout(set = 1, binding = 0) uniform texture2D Texture;
UNIFORM_TEXTURE(set = 1, binding = 0, Texture)
void main() {
v_Position = Vertex_Position;
Expand Down
4 changes: 1 addition & 3 deletions crates/bevy_ui/src/render/ui.frag
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#version 450

layout(location = 0) in vec2 v_Uv;

layout(location = 0) out vec4 o_Target;
Expand All @@ -8,7 +6,7 @@ layout(set = 2, binding = 0) uniform ColorMaterial_color {
vec4 Color;
};

# ifdef COLORMATERIAL_TEXTURE
# ifdef COLORMATERIAL_TEXTURE
layout(set = 2, binding = 1) uniform texture2D ColorMaterial_texture;
layout(set = 2, binding = 2) uniform sampler ColorMaterial_texture_sampler;
# endif
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_ui/src/render/ui.vert
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#version 450

layout(location = 0) in vec3 Vertex_Position;
layout(location = 1) in vec3 Vertex_Normal;
layout(location = 2) in vec2 Vertex_Uv;
Expand Down
20 changes: 9 additions & 11 deletions examples/shader/mesh_custom_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bevy::{
prelude::*,
render::{
mesh::{shape, VertexAttributeValues},
pipeline::{PipelineDescriptor, PipelineSpecialization, RenderPipeline},
pipeline::{PipelineDescriptor, RenderPipeline},
render_graph::{base, AssetRenderResourcesNode, RenderGraph},
renderer::RenderResources,
shader::{ShaderStage, ShaderStages},
Expand All @@ -24,15 +24,14 @@ fn main() {
struct MyMaterialWithVertexColorSupport {}

const VERTEX_SHADER: &str = r#"
#version 450
layout(location = 0) in vec3 Vertex_Position;
layout(location = 1) in vec3 Vertex_Color;
layout(location = 0) out vec3 v_color;
LAYOUT(location = 0) in vec3 Vertex_Position;
LAYOUT(location = 1) in vec3 Vertex_Color;
LAYOUT(location = 0) out vec3 v_color;
layout(set = 0, binding = 0) uniform Camera {
BLOCK_LAYOUT(set = 0, binding = 0) uniform Camera {
mat4 ViewProj;
};
layout(set = 1, binding = 0) uniform Transform {
BLOCK_LAYOUT(set = 1, binding = 0) uniform Transform {
mat4 Model;
};
void main() {
Expand All @@ -42,12 +41,11 @@ void main() {
"#;

const FRAGMENT_SHADER: &str = r#"
#version 450
layout(location = 0) out vec4 o_Target;
layout(location = 0) in vec3 v_color;
LAYOUT(location = 0) out vec4 o_Target;
LAYOUT(location = 0) in vec3 v_color;
void main() {
o_Target = vec4(v_color, 1.0);
o_Target = encodeColor(vec4(v_color, 1.0));
}
"#;

Expand Down
14 changes: 6 additions & 8 deletions examples/shader/shader_custom_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ struct MyMaterial {
}

const VERTEX_SHADER: &str = r#"
#version 450
layout(location = 0) in vec3 Vertex_Position;
layout(set = 0, binding = 0) uniform Camera {
LAYOUT(location = 0) in vec3 Vertex_Position;
BLOCK_LAYOUT(set = 0, binding = 0) uniform Camera {
mat4 ViewProj;
};
layout(set = 1, binding = 0) uniform Transform {
BLOCK_LAYOUT(set = 1, binding = 0) uniform Transform {
mat4 Model;
};
void main() {
Expand All @@ -40,13 +39,12 @@ void main() {
"#;

const FRAGMENT_SHADER: &str = r#"
#version 450
layout(location = 0) out vec4 o_Target;
layout(set = 1, binding = 1) uniform MyMaterial_color {
LAYOUT(location = 0) out vec4 o_Target;
BLOCK_LAYOUT(set = 1, binding = 1) uniform MyMaterial_color {
vec4 color;
};
void main() {
o_Target = color;
o_Target = encodeColor(color);
}
"#;

Expand Down
16 changes: 7 additions & 9 deletions examples/shader/shader_defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ struct MyMaterial {
}

const VERTEX_SHADER: &str = r#"
#version 450
layout(location = 0) in vec3 Vertex_Position;
layout(set = 0, binding = 0) uniform Camera {
LAYOUT(location = 0) in vec3 Vertex_Position;
BLOCK_LAYOUT(set = 0, binding = 0) uniform Camera {
mat4 ViewProj;
};
layout(set = 1, binding = 0) uniform Transform {
BLOCK_LAYOUT(set = 1, binding = 0) uniform Transform {
mat4 Model;
};
void main() {
Expand All @@ -48,16 +47,15 @@ void main() {
"#;

const FRAGMENT_SHADER: &str = r#"
#version 450
layout(location = 0) out vec4 o_Target;
layout(set = 1, binding = 1) uniform MyMaterial_color {
LAYOUT(location = 0) out vec4 o_Target;
BLOCK_LAYOUT(set = 1, binding = 1) uniform MyMaterial_color {
vec4 color;
};
void main() {
o_Target = color;
o_Target = encodeColor(color);
# ifdef MYMATERIAL_ALWAYS_BLUE
o_Target = vec4(0.0, 0.0, 0.8, 1.0);
o_Target = encodeColor(vec4(0.0, 0.0, 0.8, 1.0));
# endif
}
"#;
Expand Down

0 comments on commit bf4b6fa

Please sign in to comment.