diff --git a/common/src/terrain/block.rs b/common/src/terrain/block.rs index 3c58bd2a12..b5ae25e919 100644 --- a/common/src/terrain/block.rs +++ b/common/src/terrain/block.rs @@ -32,6 +32,7 @@ pub enum BlockKind { Velorite, VeloriteFrag, Chest, + Leaves, } impl BlockKind { diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index 7b6e8fb069..1235ea81a4 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -3,7 +3,7 @@ use crate::{ render::{self, FluidPipeline, Mesh, TerrainPipeline}, }; use common::{ - terrain::Block, + terrain::{Block, BlockKind}, vol::{ReadVol, RectRasterableVol, Vox}, volumes::vol_grid_2d::{CachedVolGrid2d, VolGrid2d}, }; @@ -13,6 +13,19 @@ use vek::*; type TerrainVertex = ::Vertex; type FluidVertex = ::Vertex; +trait Blendable { + fn is_blended(&self) -> bool; +} + +impl Blendable for BlockKind { + fn is_blended(&self) -> bool { + match self { + BlockKind::Leaves => false, + _ => true, + } + } +} + fn calc_light + ReadVol + Debug>( bounds: Aabb, vol: &VolGrid2d, @@ -317,16 +330,15 @@ impl + ReadVol + Debug> Meshable| { + let get_color = |maybe_block: Option<&Block>, neighbour: bool| { maybe_block - .filter(|vox| vox.is_opaque()) + .filter(|vox| vox.is_opaque() && (!neighbour || vox.is_blended())) .and_then(|vox| vox.get_color()) .map(|col| Rgba::from_opaque(col)) .unwrap_or(Rgba::zero()) }; let mut blocks = [[[None; 3]; 3]; 3]; - let mut colors = [[[Rgba::zero(); 3]; 3]; 3]; for i in 0..3 { for j in 0..3 { for k in 0..3 { @@ -334,7 +346,6 @@ impl + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable None, StructureBlock::TemperateLeaves => Some(Block::new( - BlockKind::Normal, + BlockKind::Leaves, Lerp::lerp( Rgb::new(0.0, 132.0, 94.0), Rgb::new(142.0, 181.0, 0.0), @@ -584,12 +584,12 @@ pub fn block_from_structure( .map(|e| e as u8), )), StructureBlock::PineLeaves => Some(Block::new( - BlockKind::Normal, + BlockKind::Leaves, Lerp::lerp(Rgb::new(0.0, 60.0, 50.0), Rgb::new(30.0, 100.0, 10.0), lerp) .map(|e| e as u8), )), StructureBlock::PalmLeaves => Some(Block::new( - BlockKind::Normal, + BlockKind::Leaves, Lerp::lerp( Rgb::new(0.0, 108.0, 113.0), Rgb::new(30.0, 156.0, 10.0),