1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4pub enum UniformId {
5 ViewMatrix,
7 ModelMatrix,
9 MeshMatrix,
11 BoneScale,
13 BoneMatrices,
15 Material,
18 Texture(TextureId),
20 User(u8),
22 Buffer(u8),
24}
25
26impl std::str::FromStr for UniformId {
27 type Err = String;
28 fn from_str(s: &str) -> Result<Self, Self::Err> {
29 use UniformId::*;
30 let v = match s {
31 "ViewMatrix" => ViewMatrix,
32 "ModelMatrix" => ModelMatrix,
33 "MeshMatrix" => MeshMatrix,
34 "BoneScale" => BoneScale,
35 "BoneMatrices" => BoneMatrices,
36 "Material" => Material,
37 _ => Err(format!("Cannot interpret {s} as a UniformID"))?,
38 };
39 Ok(v)
40 }
41}
42
43#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
46#[repr(u8)]
47#[non_exhaustive]
48pub enum TextureId {
49 #[default]
51 None,
52 BaseColor,
54 Normal,
56 Occlusion,
58 Emission,
60 MetallicRoughness,
62 User0,
64}
65
66impl std::str::FromStr for TextureId {
67 type Err = String;
68 fn from_str(s: &str) -> Result<Self, Self::Err> {
69 use TextureId::*;
70 let v = match s {
71 "BaseColor" => BaseColor,
72 "Normal" => Normal,
73 "Occlusion" => Occlusion,
74 "Emission" => Emission,
75 "MetallicRoughness" => MetallicRoughness,
76 "User0" => User0,
77 _ => Err(format!("Cannot interpret {s} as a TextureId"))?,
78 };
79 Ok(v)
80 }
81}
82
83impl TextureId {
84 pub fn of_material_aspect(m: mod3d_base::MaterialAspect) -> Self {
85 use mod3d_base::MaterialAspect::*;
86 #[allow(unreachable_patterns)]
87 match m {
88 Color => Self::BaseColor,
89 Normal => Self::Normal,
90 MetallicRoughness => Self::MetallicRoughness,
91 Occlusion => Self::Occlusion,
92 Emission => Self::Emission,
93 _ => Self::None,
94 }
95 }
96}