mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
good hat rendering
This commit is contained in:
parent
4fd276890e
commit
124cb5d305
@ -5,27 +5,30 @@ use vek::*;
|
||||
|
||||
const GLOWY: u8 = 1 << 1;
|
||||
const SHINY: u8 = 1 << 2;
|
||||
const HOLLOW: u8 = 1 << 3;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CellData {
|
||||
pub col: Rgb<u8>,
|
||||
pub attr: NonZeroU8, // 1 = glowy, 2 = shiny
|
||||
pub attr: NonZeroU8, // 1 = glowy, 2 = shiny, 3 = hollow
|
||||
}
|
||||
|
||||
impl CellData {
|
||||
pub(super) fn new(col: Rgb<u8>, glowy: bool, shiny: bool) -> Self {
|
||||
pub(super) fn new(col: Rgb<u8>, glowy: bool, shiny: bool, hollow: bool) -> Self {
|
||||
CellData {
|
||||
col,
|
||||
attr: NonZeroU8::new(
|
||||
1 + glowy as u8 * GLOWY + shiny as u8 * SHINY,
|
||||
1 + glowy as u8 * GLOWY + shiny as u8 * SHINY + hollow as u8 * HOLLOW,
|
||||
)
|
||||
.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_hollow(&self) -> bool { self.attr.get() & HOLLOW != 0 }
|
||||
}
|
||||
|
||||
impl Default for CellData {
|
||||
fn default() -> Self { Self::new(Rgb::broadcast(255), false, false) }
|
||||
fn default() -> Self { Self::new(Rgb::broadcast(255), false, false, false) }
|
||||
}
|
||||
|
||||
/// A type representing a single voxel in a figure.
|
||||
@ -36,8 +39,8 @@ pub enum Cell {
|
||||
}
|
||||
|
||||
impl Cell {
|
||||
pub fn new(col: Rgb<u8>, glowy: bool, shiny: bool) -> Self {
|
||||
Cell::Filled(CellData::new(col, glowy, shiny))
|
||||
pub fn new(col: Rgb<u8>, glowy: bool, shiny: bool, hollow: bool) -> Self {
|
||||
Cell::Filled(CellData::new(col, glowy, shiny, hollow))
|
||||
}
|
||||
|
||||
pub fn get_color(&self) -> Option<Rgb<u8>> {
|
||||
@ -60,6 +63,13 @@ impl Cell {
|
||||
Cell::Empty => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_hollow(&self) -> bool {
|
||||
match self {
|
||||
Cell::Filled(data) => data.is_hollow(),
|
||||
Cell::Empty => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Vox for Cell {
|
||||
|
@ -20,7 +20,6 @@ pub enum MatCell {
|
||||
None,
|
||||
Mat(Material),
|
||||
Normal(CellData),
|
||||
Hollow,
|
||||
}
|
||||
|
||||
impl Vox for MatCell {
|
||||
|
@ -67,6 +67,7 @@ impl Segment {
|
||||
color,
|
||||
(13..16).contains(&voxel.i), // Glowy
|
||||
(8..13).contains(&voxel.i), // Shiny
|
||||
voxel.i == 16, //Hollow
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
@ -98,6 +99,7 @@ impl Segment {
|
||||
transform(rgb),
|
||||
cell.is_glowy(),
|
||||
cell.is_shiny(),
|
||||
cell.is_hollow(),
|
||||
)
|
||||
})
|
||||
})
|
||||
@ -164,9 +166,8 @@ impl MatSegment {
|
||||
for (pos, vox) in self.full_vol_iter() {
|
||||
let data = match vox {
|
||||
MatCell::None => continue,
|
||||
MatCell::Mat(mat) => CellData::new(map(*mat), false, false),
|
||||
MatCell::Mat(mat) => CellData::new(map(*mat), false, false, false),
|
||||
MatCell::Normal(data) => *data,
|
||||
MatCell::Hollow => continue,
|
||||
};
|
||||
vol.set(pos, Cell::Filled(data)).unwrap();
|
||||
}
|
||||
@ -219,7 +220,6 @@ impl MatSegment {
|
||||
4 => MatCell::Mat(Material::SkinDark),
|
||||
5 => MatCell::Mat(Material::SkinLight),
|
||||
7 => MatCell::Mat(Material::EyeWhite),
|
||||
16 => MatCell::Hollow,
|
||||
//6 => MatCell::Mat(Material::Clothing),
|
||||
index => {
|
||||
let color = palette
|
||||
@ -230,6 +230,7 @@ impl MatSegment {
|
||||
color,
|
||||
(13..16).contains(&index),
|
||||
(8..13).contains(&index),
|
||||
index == 16, // Hollow
|
||||
))
|
||||
},
|
||||
};
|
||||
|
38
frame-trace_1635217738690.json
Normal file
38
frame-trace_1635217738690.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"traceEvents": [
|
||||
{ "pid":1, "tid":1, "ts":1635217738642844.8, "dur":4531.383514404297, "ph":"X", "name":"frame" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738642866, "dur":304.4605255126953, "ph":"X", "name":"shadow_pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738642866, "dur":297.0695495605469, "ph":"X", "name":"direcred_terrain_shadows" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643163, "dur":5.9604644775390625, "ph":"X", "name":"direcred_figure_shadows" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643172.8, "dur":211.95411682128906, "ph":"X", "name":"point shadows" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643182.3, "dur":21.696090698242188, "ph":"X", "name":"point shadow face-0 pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643212, "dur":28.848648071289063, "ph":"X", "name":"point shadow face-1 pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643248.3, "dur":28.133392333984375, "ph":"X", "name":"point shadow face-2 pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643283.3, "dur":33.14018249511719, "ph":"X", "name":"point shadow face-3 pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643322.8, "dur":26.464462280273438, "ph":"X", "name":"point shadow face-4 pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643357, "dur":25.033950805664063, "ph":"X", "name":"point shadow face-5 pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643402.3, "dur":1906.8717956542969, "ph":"X", "name":"first_pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643402.5, "dur":21.696090698242188, "ph":"X", "name":"figures" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738643424.8, "dur":672.1019744873047, "ph":"X", "name":"terrain" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738644098.3, "dur":18.596649169921875, "ph":"X", "name":"figures" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738644117.5, "dur":808.4774017333984, "ph":"X", "name":"lod_terrain" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738644926.3, "dur":18.358230590820313, "ph":"X", "name":"skybox" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738644944.5, "dur":349.99847412109375, "ph":"X", "name":"sprites" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738645295, "dur":0, "ph":"X", "name":"fluid" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738645296.3, "dur":10.967254638671875, "ph":"X", "name":"particles" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738645308.3, "dur":0.476837158203125, "ph":"X", "name":"debug" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738645319.5, "dur":1293.8976287841797, "ph":"X", "name":"second_pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646615.5, "dur":278.9497375488281, "ph":"X", "name":"bloom" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646620, "dur":40.76957702636719, "ph":"X", "name":"downsample filtered 1" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646666, "dur":12.159347534179688, "ph":"X", "name":"downsample 2" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646683.3, "dur":4.0531158447265625, "ph":"X", "name":"downsample 3" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646691.8, "dur":3.814697265625, "ph":"X", "name":"downsample 4" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646699.5, "dur":4.5299530029296875, "ph":"X", "name":"upsample 1" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646708, "dur":9.775161743164063, "ph":"X", "name":"upsample 2" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646722, "dur":30.994415283203125, "ph":"X", "name":"upsample 3" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646762.8, "dur":129.46128845214844, "ph":"X", "name":"upsample 4" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646902, "dur":470.87669372558594, "ph":"X", "name":"third_pass" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738646902.5, "dur":468.4925079345703, "ph":"X", "name":"postprocess" },
|
||||
{ "pid":1, "tid":1, "ts":1635217738647371.5, "dur":0.95367431640625, "ph":"X", "name":"ui" }
|
||||
]
|
||||
}
|
@ -211,9 +211,8 @@ fn graceful_load_segment_no_skin(specifier: &str) -> Arc<Segment> {
|
||||
let seg = mat_seg
|
||||
.map(|mat_cell| match mat_cell {
|
||||
MatCell::None => None,
|
||||
MatCell::Hollow => None,
|
||||
MatCell::Mat(_) => Some(MatCell::None),
|
||||
MatCell::Normal(_) => None,
|
||||
MatCell::Normal(data) => data.is_hollow().then(|| MatCell::None),
|
||||
})
|
||||
.to_segment(|_| Default::default());
|
||||
Arc::new(seg)
|
||||
|
@ -318,7 +318,7 @@ impl HumHeadSpec {
|
||||
.maybe_add(beard)
|
||||
.maybe_add(accessory)
|
||||
.maybe_add(helmet)
|
||||
.unify();
|
||||
.unify_with(|v| if v.is_hollow() { Cell::empty() } else { v });
|
||||
(
|
||||
head,
|
||||
Vec3::from(spec.offset) + origin_offset.map(|e| e as f32 * -1.0),
|
||||
|
Loading…
Reference in New Issue
Block a user