diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index d227510663..b3f866e6d0 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -61,6 +61,7 @@ pub const ALL_RACES: [Race; 6] = [ Race::Orc, Race::Undead, ]; + // Hair Colors pub const DANARI_HAIR_COLORS: [(u8, u8, u8); 4] = [ (198, 169, 113), @@ -73,6 +74,7 @@ pub const ELF_HAIR_COLORS: [(u8, u8, u8); 3] = [(66, 83, 113), (13, 76, 41), (66 pub const HUMAN_HAIR_COLORS: [(u8, u8, u8); 3] = [(73, 42, 36), (73, 42, 36), (73, 42, 36)]; pub const ORC_HAIR_COLORS: [(u8, u8, u8); 3] = [(11, 11, 11), (54, 30, 26), (54, 30, 26)]; pub const UNDEAD_HAIR_COLORS: [(u8, u8, u8); 3] = [(0, 131, 122), (24, 19, 17), (0, 131, 122)]; + // Skin colors pub const DANARI_SKIN_COLORS: [(u8, u8, u8); 4] = [ (57, 120, 148), @@ -87,6 +89,63 @@ pub const HUMAN_SKIN_COLORS: [(u8, u8, u8); 3] = pub const ORC_SKIN_COLORS: [(u8, u8, u8); 3] = [(68, 129, 44), (77, 150, 51), (45, 95, 32)]; pub const UNDEAD_SKIN_COLORS: [(u8, u8, u8); 3] = [(255, 255, 255), (203, 255, 215), (213, 220, 180)]; + +// Eye colors +pub const DANARI_EYE_COLORS: [EyeColor; 7] = [ + EyeColor::Black, + EyeColor::Blue, + EyeColor::Green, + EyeColor::Brown, + EyeColor::Red, + EyeColor::White, + EyeColor::Orange, +]; +pub const DWARF_EYE_COLORS: [EyeColor; 7] = [ + EyeColor::Black, + EyeColor::Blue, + EyeColor::Green, + EyeColor::Brown, + EyeColor::Red, + EyeColor::White, + EyeColor::Orange, +]; +pub const ELF_EYE_COLORS: [EyeColor; 7] = [ + EyeColor::Black, + EyeColor::Blue, + EyeColor::Green, + EyeColor::Brown, + EyeColor::Red, + EyeColor::White, + EyeColor::Orange, +]; +pub const HUMAN_EYE_COLORS: [EyeColor; 7] = [ + EyeColor::Black, + EyeColor::Blue, + EyeColor::Green, + EyeColor::Brown, + EyeColor::Red, + EyeColor::White, + EyeColor::Orange, +]; +pub const ORC_EYE_COLORS: [EyeColor; 7] = [ + EyeColor::Black, + EyeColor::Blue, + EyeColor::Green, + EyeColor::Brown, + EyeColor::Red, + EyeColor::White, + EyeColor::Orange, +]; +pub const UNDEAD_EYE_COLORS: [EyeColor; 7] = [ + EyeColor::Black, + EyeColor::Blue, + EyeColor::Green, + EyeColor::Brown, + EyeColor::Red, + EyeColor::White, + EyeColor::Orange, +]; + impl Race { fn hair_colors(self) -> &'static [(u8, u8, u8)] { match self { @@ -110,7 +169,12 @@ impl Race { } fn eye_colors(self) -> &'static [EyeColor] { match self { - _ => &ALL_EYE_COLORS, + Race::Danari => &DANARI_EYE_COLORS, + Race::Dwarf => &DWARF_EYE_COLORS, + Race::Elf => &ELF_EYE_COLORS, + Race::Human => &HUMAN_EYE_COLORS, + Race::Orc => &ORC_EYE_COLORS, + Race::Undead => &UNDEAD_EYE_COLORS, } } pub fn hair_color(self, val: u8) -> Rgb { diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index e7db3c6c43..b0ed77bbfe 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -63,6 +63,22 @@ fn color_segment( }) } +fn recolor_greys(segment: Segment, color: Rgb) -> Segment { + use common::util::{linear_to_srgb, srgb_to_linear}; + + segment.map_rgb(|rgb| { + const BASE_GREY: f32 = 178.0; + if rgb.r == rgb.g && rgb.g == rgb.b { + let c1 = srgb_to_linear(rgb.map(|e| e as f32 / BASE_GREY)); + let c2 = srgb_to_linear(color.map(|e| e as f32 / 255.0)); + + linear_to_srgb(c1 * c2).map(|e| (e.min(1.0).max(0.0) * 255.0) as u8) + } else { + rgb + } + }) +} + #[derive(Serialize, Deserialize)] struct VoxSpec(String, [i32; 3]); // All offsets should be relative to an initial origin that doesn't change when combining segments // All reliant on humanoid::Race and humanoid::BodyType @@ -116,22 +132,6 @@ impl HumHeadSpec { let skin_rgb = race.skin_color(skin); let eye_color = race.eye_color(eye_color); - fn recolor_greys(segment: Segment, color: Rgb) -> Segment { - use common::util::{linear_to_srgb, srgb_to_linear}; - - segment.map_rgb(|rgb| { - const BASE_GREY: f32 = 178.0; - if rgb.r == rgb.g && rgb.g == rgb.b { - let c1 = srgb_to_linear(rgb.map(|e| e as f32 / BASE_GREY)); - let c2 = srgb_to_linear(color.map(|e| e as f32 / 255.0)); - - linear_to_srgb(c1 * c2).map(|e| (e.min(1.0).max(0.0) * 255.0) as u8) - } else { - rgb - } - }) - } - // Load segment pieces let bare_head = graceful_load_mat_segment(&spec.head.0); let eyes = graceful_load_mat_segment(&spec.eyes.0); @@ -234,14 +234,6 @@ impl HumHeadSpec { //load_mesh(name, offset) } } -// loads models with different offsets -// pub fn mesh_beard(beard: Beard) -> Mesh { -// let (name, offset) = match beard { -// Beard::None => ("figure/body/empty", Vec3::new(0.0, 0.0, 0.0)), -// Beard::Human1 => ("figure/empty", Vec3::new(0.0, 0.0, 0.0)), -// }; -// load_mesh(name, offset) -// } pub fn mesh_chest(chest: Chest) -> Mesh { let color = match chest {