use crate::{assets::storage::RawAssetHandle, wgpu::samplers::SamplerKind};
pub enum ParamValue {
Texture(RawAssetHandle),
Cubemap(RawAssetHandle),
Sampler(SamplerKind),
Float(f32),
Vec4([f32; 4]),
Bytes(Vec<u8>),
}
pub struct MaterialInstanceDescriptor {
pub material: RawAssetHandle,
pub params: Vec<(&'static str, ParamValue)>,
}
impl MaterialInstanceDescriptor {
pub fn new(material: RawAssetHandle) -> Self {
Self {
material,
params: Vec::new(),
}
}
pub fn with_texture(mut self, name: &'static str, handle: RawAssetHandle) -> Self {
self.params.push((name, ParamValue::Texture(handle)));
self
}
pub fn with_cubemap(mut self, name: &'static str, handle: RawAssetHandle) -> Self {
self.params.push((name, ParamValue::Cubemap(handle)));
self
}
pub fn with_sampler(mut self, name: &'static str, kind: SamplerKind) -> Self {
self.params.push((name, ParamValue::Sampler(kind)));
self
}
pub fn with_float(mut self, name: &'static str, value: f32) -> Self {
self.params.push((name, ParamValue::Float(value)));
self
}
pub fn with_vec4(mut self, name: &'static str, value: [f32; 4]) -> Self {
self.params.push((name, ParamValue::Vec4(value)));
self
}
pub fn with_bytes(mut self, name: &'static str, bytes: Vec<u8>) -> Self {
self.params.push((name, ParamValue::Bytes(bytes)));
self
}
}