bevy/crates/bevy_pbr/src/material.rs

44 lines
1.1 KiB
Rust
Raw Normal View History

2020-04-25 01:55:15 +00:00
use bevy_asset::{self, Handle};
use bevy_render::{color::Color, renderer::RenderResources, shader::ShaderDefs, texture::Texture};
use bevy_type_registry::TypeUuid;
2020-04-06 03:19:02 +00:00
/// A material with "standard" properties used in PBR lighting
#[derive(Debug, RenderResources, ShaderDefs, TypeUuid)]
#[uuid = "dace545e-4bc6-4595-a79d-c224fc694975"]
2020-02-10 02:09:54 +00:00
pub struct StandardMaterial {
pub albedo: Color,
#[shader_def]
pub albedo_texture: Option<Handle<Texture>>,
#[render_resources(ignore)]
#[shader_def]
pub shaded: bool,
2020-02-11 17:31:49 +00:00
}
impl Default for StandardMaterial {
fn default() -> Self {
StandardMaterial {
albedo: Color::rgb(1.0, 1.0, 1.0),
albedo_texture: None,
shaded: true,
2020-02-11 17:31:49 +00:00
}
}
}
2020-08-01 00:10:29 +00:00
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()
}
}
}