1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use bevy_asset::{self, Handle};
use bevy_render::{color::Color, renderer::RenderResources, shader::ShaderDefs, texture::Texture};
#[derive(RenderResources, ShaderDefs)]
#[allow(clippy::manual_non_exhaustive)]
pub struct StandardMaterial {
pub albedo: Color,
#[shader_def]
pub albedo_texture: Option<Handle<Texture>>,
#[render_resources(ignore)]
#[shader_def]
pub shaded: bool,
#[render_resources(ignore)]
#[doc(hidden)]
pub __non_exhaustive: (),
}
impl Default for StandardMaterial {
fn default() -> Self {
StandardMaterial {
albedo: Color::rgb(1.0, 1.0, 1.0),
albedo_texture: None,
shaded: true,
__non_exhaustive: (),
}
}
}
impl From<Color> for StandardMaterial {
fn from(color: Color) -> Self {
StandardMaterial {
albedo: color,
..Default::default()
}
}
}
impl From<Handle<Texture>> for StandardMaterial {
fn from(texture: Handle<Texture>) -> Self {
StandardMaterial {
albedo_texture: Some(texture),
..Default::default()
}
}
}