diff --git a/assets/shaders/repeat.frag b/assets/shaders/repeat.frag index c140639..8d7cc2a 100644 --- a/assets/shaders/repeat.frag +++ b/assets/shaders/repeat.frag @@ -8,11 +8,11 @@ layout(set = 1, binding = 0) uniform RepeatMaterial { }; layout(set = 1, binding = 1) uniform texture2D RepeatMaterial_texture; -layout(set = 1, binding = 2) uniform sampler RepeatMaterial_sampler; +layout(set = 1, binding = 2) uniform sampler RepeatMaterial_sampler; void main() { - o_Target = Color * texture(sampler2D(RepeatMaterial_texture,RepeatMaterial_sampler), v_Uv); + o_Target = Color * texture(sampler2D(RepeatMaterial_texture, RepeatMaterial_sampler), v_Uv); } // vim: set ft=glsl: diff --git a/assets/shaders/repeat.vert b/assets/shaders/repeat.vert index f409059..434f65d 100644 --- a/assets/shaders/repeat.vert +++ b/assets/shaders/repeat.vert @@ -1,7 +1,9 @@ #version 450 layout(location = 0) in vec3 Vertex_Position; + layout(location = 1) in vec3 Vertex_Normal; + layout(location = 2) in vec2 Vertex_Uv; layout(location = 0) out vec2 v_Uv; diff --git a/src/main.rs b/src/main.rs index 3a68aa6..db0fd40 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,22 +43,32 @@ fn startup( ..default() }); + let grid_tile = tiled_materials.add(RepeatMaterial { + color: Color::BLUE, + color_texture: Some(texture.clone()), + alpha_mode: AlphaMode::Blend, + }); + commands.spawn(MaterialMeshBundle { mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), - material: tiled_materials.add(RepeatMaterial{ - color: Color::BLUE, - color_texture: Some(texture.clone()), - alpha_mode: AlphaMode::Opaque, - }), + material: grid_tile.clone(), transform: Transform::from_xyz(2.0, 0.5, 0.0), ..default() }); + commands.spawn(MaterialMeshBundle { + mesh: meshes.add(Mesh::from(shape::Cube { size: 2.0 })), + material: grid_tile.clone(), + transform: Transform::from_xyz(-2.0, 1.0, 0.0), + ..default() + }); + // single light source commands.spawn(PointLightBundle { point_light: PointLight { intensity: 1500.0, - shadows_enabled: true, + // I don't know why but the glsl shader explodes if we turn on the shadows + shadows_enabled: false, ..default() }, transform: Transform::from_xyz(4.0, 8.0, 4.0), @@ -73,7 +83,7 @@ fn startup( } #[derive(AsBindGroup, Clone, TypeUuid)] -#[uuid = "00000000-0000-0000-0000-000000000001"] +#[uuid = "d57ae039-8c67-4004-9370-5c522e256515"] pub struct RepeatMaterial { #[uniform(0)] color: Color, @@ -105,8 +115,11 @@ impl Material for RepeatMaterial { _: MaterialPipelineKey, ) -> Result<(), SpecializedMeshPipelineError> { descriptor.vertex.entry_point = "main".into(); - let mut frag = descriptor.fragment.as_mut().expect("should have a fragment entry point here"); - frag.entry_point = "main".into(); + let mut frag = descriptor + .fragment + .as_mut() + .expect("should have a fragment entry point here"); + frag.entry_point = "main".into(); Ok(()) } } @@ -114,7 +127,7 @@ impl Material for RepeatMaterial { fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugin(MaterialPlugin::::default()) .add_startup_system(startup) .run(); }