multiple cubes now

main
Jordan Orelli 1 year ago
parent ded1b7f12f
commit fb45873c81

@ -8,8 +8,8 @@ layout(set = 1, binding = 0) uniform RepeatMaterial {
}; };
layout(set = 1, binding = 1) uniform texture2D RepeatMaterial_texture; 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() { void main() {
o_Target = Color * texture(sampler2D(RepeatMaterial_texture, RepeatMaterial_sampler), v_Uv); o_Target = Color * texture(sampler2D(RepeatMaterial_texture, RepeatMaterial_sampler), v_Uv);

@ -1,7 +1,9 @@
#version 450 #version 450
layout(location = 0) in vec3 Vertex_Position; layout(location = 0) in vec3 Vertex_Position;
layout(location = 1) in vec3 Vertex_Normal; layout(location = 1) in vec3 Vertex_Normal;
layout(location = 2) in vec2 Vertex_Uv; layout(location = 2) in vec2 Vertex_Uv;
layout(location = 0) out vec2 v_Uv; layout(location = 0) out vec2 v_Uv;

@ -43,22 +43,32 @@ fn startup(
..default() ..default()
}); });
commands.spawn(MaterialMeshBundle { let grid_tile = tiled_materials.add(RepeatMaterial {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: tiled_materials.add(RepeatMaterial{
color: Color::BLUE, color: Color::BLUE,
color_texture: Some(texture.clone()), color_texture: Some(texture.clone()),
alpha_mode: AlphaMode::Opaque, alpha_mode: AlphaMode::Blend,
}), });
commands.spawn(MaterialMeshBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: grid_tile.clone(),
transform: Transform::from_xyz(2.0, 0.5, 0.0), transform: Transform::from_xyz(2.0, 0.5, 0.0),
..default() ..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 // single light source
commands.spawn(PointLightBundle { commands.spawn(PointLightBundle {
point_light: PointLight { point_light: PointLight {
intensity: 1500.0, 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() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), transform: Transform::from_xyz(4.0, 8.0, 4.0),
@ -73,7 +83,7 @@ fn startup(
} }
#[derive(AsBindGroup, Clone, TypeUuid)] #[derive(AsBindGroup, Clone, TypeUuid)]
#[uuid = "00000000-0000-0000-0000-000000000001"] #[uuid = "d57ae039-8c67-4004-9370-5c522e256515"]
pub struct RepeatMaterial { pub struct RepeatMaterial {
#[uniform(0)] #[uniform(0)]
color: Color, color: Color,
@ -105,7 +115,10 @@ impl Material for RepeatMaterial {
_: MaterialPipelineKey<Self>, _: MaterialPipelineKey<Self>,
) -> Result<(), SpecializedMeshPipelineError> { ) -> Result<(), SpecializedMeshPipelineError> {
descriptor.vertex.entry_point = "main".into(); descriptor.vertex.entry_point = "main".into();
let mut frag = descriptor.fragment.as_mut().expect("should have a fragment entry point here"); let mut frag = descriptor
.fragment
.as_mut()
.expect("should have a fragment entry point here");
frag.entry_point = "main".into(); frag.entry_point = "main".into();
Ok(()) Ok(())
} }

Loading…
Cancel
Save