|
|
@ -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(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|