use crate::color::Color;
use crate::texture::Texture;
pub struct Material {
pub base_color_texture: Texture,
pub base_color_factor: Color,
pub bind_group: wgpu::BindGroup,
}
impl Material {
pub fn new(
device: &wgpu::Device,
layout: &wgpu::BindGroupLayout,
texture: Texture,
base_color_factor: Color,
) -> Self {
let bind_group = texture.bind_group(device, layout);
Self {
base_color_texture: texture,
base_color_factor,
bind_group,
}
}
pub fn default_material(
device: &wgpu::Device,
queue: &wgpu::Queue,
layout: &wgpu::BindGroupLayout,
) -> crate::error::Result<Self> {
let texture = Texture::white_pixel(device, queue)?;
Ok(Self::new(device, layout, texture, Color::WHITE))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn material_types_exist() {
let _size = std::mem::size_of::<Material>();
}
}