Merge branch 'pfauenauge/plants_grass' into 'zesterer/instancing'

Pfauenauge/plants grass

See merge request veloren/veloren!452
This commit is contained in:
Joshua Barretto 2019-08-21 17:22:05 +00:00
commit 75107e55b5
59 changed files with 383 additions and 73 deletions

BIN
assets/voxygen/voxel/sprite/cacti/barrel_cactus.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/cacti/large_cactus.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_blue_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_blue_2.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_pink_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_pink_2.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_pink_3.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_purple_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_red_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_white_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/flower_yellow_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/sunflower_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/flowers/sunflower_2.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/fruit/apple.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/fruit/apple_half.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass-0.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass-1.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass-2.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass-3.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass-4.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass-5.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_long_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_long_2.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_long_3.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_long_4.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_long_5.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_med_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_med_2.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_med_3.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_med_4.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_med_5.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_short_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_short_2.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_short_3.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_short_4.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/grass/grass_short_5.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_10.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_2.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_3.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_4.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_5.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_6.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_7.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_8.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/velorite_small/velorite_9.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/wheat.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/tree/fruit/1.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/tree/fruit/2.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/tree/fruit/3.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/tree/fruit/4.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/tree/fruit/5.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/tree/fruit/6.vox (Stored with Git LFS)

Binary file not shown.

View File

@ -10,18 +10,38 @@ pub enum BlockKind {
Normal, Normal,
Dense, Dense,
Water, Water,
Wheat, LargeCactus,
BarrelCactus,
BlueFlower,
PinkFlower,
PurpleFlower,
RedFlower,
WhiteFlower,
YellowFlower,
Sunflower,
LongGrass, LongGrass,
Flowers, MediumGrass,
ShortGrass,
Apple,
} }
impl BlockKind { impl BlockKind {
pub fn is_air(&self) -> bool { pub fn is_air(&self) -> bool {
match self { match self {
BlockKind::Air => true, BlockKind::Air => true,
BlockKind::Wheat => true, BlockKind::LargeCactus => false,
BlockKind::BarrelCactus => true,
BlockKind::BlueFlower => true,
BlockKind::PinkFlower => true,
BlockKind::PurpleFlower => true,
BlockKind::RedFlower => true,
BlockKind::WhiteFlower => true,
BlockKind::YellowFlower => true,
BlockKind::Sunflower => true,
BlockKind::LongGrass => true, BlockKind::LongGrass => true,
BlockKind::Flowers => true, BlockKind::MediumGrass => true,
BlockKind::ShortGrass => true,
BlockKind::Apple => true,
_ => false, _ => false,
} }
} }
@ -37,9 +57,19 @@ impl BlockKind {
match self { match self {
BlockKind::Air => false, BlockKind::Air => false,
BlockKind::Water => false, BlockKind::Water => false,
BlockKind::Wheat => false, BlockKind::LargeCactus => false,
BlockKind::BarrelCactus => false,
BlockKind::BlueFlower => false,
BlockKind::PinkFlower => false,
BlockKind::PurpleFlower => false,
BlockKind::RedFlower => false,
BlockKind::WhiteFlower => false,
BlockKind::YellowFlower => false,
BlockKind::Sunflower => false,
BlockKind::LongGrass => false, BlockKind::LongGrass => false,
BlockKind::Flowers => false, BlockKind::MediumGrass => false,
BlockKind::ShortGrass => false,
BlockKind::Apple => false,
_ => true, _ => true,
} }
} }
@ -48,9 +78,19 @@ impl BlockKind {
match self { match self {
BlockKind::Air => false, BlockKind::Air => false,
BlockKind::Water => false, BlockKind::Water => false,
BlockKind::Wheat => false, BlockKind::LargeCactus => true,
BlockKind::BarrelCactus => true,
BlockKind::BlueFlower => false,
BlockKind::PinkFlower => false,
BlockKind::PurpleFlower => false,
BlockKind::RedFlower => false,
BlockKind::WhiteFlower => false,
BlockKind::YellowFlower => false,
BlockKind::Sunflower => false,
BlockKind::LongGrass => false, BlockKind::LongGrass => false,
BlockKind::Flowers => false, BlockKind::MediumGrass => false,
BlockKind::ShortGrass => false,
BlockKind::Apple => true,
_ => true, _ => true,
} }
} }

View File

@ -24,7 +24,7 @@ struct TerrainChunk {
// GPU data // GPU data
opaque_model: Model<TerrainPipeline>, opaque_model: Model<TerrainPipeline>,
fluid_model: Model<FluidPipeline>, fluid_model: Model<FluidPipeline>,
sprite_instances: HashMap<BlockKind, Instances<SpriteInstance>>, sprite_instances: HashMap<(BlockKind, usize), Instances<SpriteInstance>>,
locals: Consts<TerrainLocals>, locals: Consts<TerrainLocals>,
visible: bool, visible: bool,
@ -43,19 +43,68 @@ struct MeshWorkerResponse {
z_bounds: (f32, f32), z_bounds: (f32, f32),
opaque_mesh: Mesh<TerrainPipeline>, opaque_mesh: Mesh<TerrainPipeline>,
fluid_mesh: Mesh<FluidPipeline>, fluid_mesh: Mesh<FluidPipeline>,
sprite_instances: HashMap<BlockKind, Vec<SpriteInstance>>, sprite_instances: HashMap<(BlockKind, usize), Vec<SpriteInstance>>,
started_tick: u64, started_tick: u64,
} }
struct SpriteConfig { struct SpriteConfig {
variations: usize,
wind_sway: f32, // 1.0 is normal wind_sway: f32, // 1.0 is normal
} }
fn sprite_config_for(kind: BlockKind) -> Option<SpriteConfig> { fn sprite_config_for(kind: BlockKind) -> Option<SpriteConfig> {
match kind { match kind {
BlockKind::Wheat => Some(SpriteConfig { wind_sway: 1.0 }), BlockKind::LargeCactus => Some(SpriteConfig {
BlockKind::LongGrass => Some(SpriteConfig { wind_sway: 1.0 }), variations: 1,
BlockKind::Flowers => Some(SpriteConfig { wind_sway: 0.3 }), wind_sway: 0.0,
}),
BlockKind::BarrelCactus => Some(SpriteConfig {
variations: 1,
wind_sway: 0.0,
}),
BlockKind::BlueFlower => Some(SpriteConfig {
variations: 2,
wind_sway: 0.3,
}),
BlockKind::PinkFlower => Some(SpriteConfig {
variations: 3,
wind_sway: 0.3,
}),
BlockKind::RedFlower => Some(SpriteConfig {
variations: 1,
wind_sway: 0.3,
}),
BlockKind::WhiteFlower => Some(SpriteConfig {
variations: 1,
wind_sway: 0.3,
}),
BlockKind::YellowFlower => Some(SpriteConfig {
variations: 1,
wind_sway: 0.3,
}),
BlockKind::Sunflower => Some(SpriteConfig {
variations: 2,
wind_sway: 0.3,
}),
BlockKind::LongGrass => Some(SpriteConfig {
variations: 5,
wind_sway: 1.0,
}),
BlockKind::MediumGrass => Some(SpriteConfig {
variations: 5,
wind_sway: 1.0,
}),
BlockKind::ShortGrass => Some(SpriteConfig {
variations: 5,
wind_sway: 1.0,
}),
BlockKind::Apple => Some(SpriteConfig {
variations: 1,
wind_sway: 0.0,
}),
_ => None, _ => None,
} }
} }
@ -88,7 +137,7 @@ fn mesh_worker(
let kind = volume.get(wpos).unwrap_or(&Block::empty()).kind(); let kind = volume.get(wpos).unwrap_or(&Block::empty()).kind();
if let Some(cfg) = sprite_config_for(kind) { if let Some(cfg) = sprite_config_for(kind) {
let seed = x * 3 + y * 7 + z * 13 + x * y; let seed = wpos.x * 3 + wpos.y * 7 + wpos.z * 13 + wpos.x * wpos.y;
let instance = SpriteInstance::new( let instance = SpriteInstance::new(
Mat4::identity() Mat4::identity()
@ -101,7 +150,7 @@ fn mesh_worker(
); );
instances instances
.entry(kind) .entry((kind, seed as usize % cfg.variations))
.or_insert_with(|| Vec::new()) .or_insert_with(|| Vec::new())
.push(instance); .push(instance);
} }
@ -125,7 +174,7 @@ pub struct Terrain {
mesh_todo: HashMap<Vec2<i32>, ChunkMeshState>, mesh_todo: HashMap<Vec2<i32>, ChunkMeshState>,
// GPU data // GPU data
sprite_models: HashMap<BlockKind, Model<SpritePipeline>>, sprite_models: HashMap<(BlockKind, usize), Model<SpritePipeline>>,
} }
impl Terrain { impl Terrain {
@ -152,14 +201,125 @@ impl Terrain {
mesh_recv: recv, mesh_recv: recv,
mesh_todo: HashMap::default(), mesh_todo: HashMap::default(),
sprite_models: vec![ sprite_models: vec![
(BlockKind::Wheat, make_model("voxygen.voxel.sprite.wheat")), // Cacti
( (
BlockKind::LongGrass, (BlockKind::LargeCactus, 0),
make_model("voxygen.voxel.sprite.grass-0"), make_model("voxygen.voxel.sprite.cacti.large_cactus"),
), ),
( (
BlockKind::Flowers, (BlockKind::BarrelCactus, 0),
make_model("voxygen.voxel.sprite.flowers"), make_model("voxygen.voxel.sprite.cacti.barrel_cactus"),
),
// Fruit
(
(BlockKind::Apple, 0),
make_model("voxygen.voxel.sprite.fruit.apple"),
),
// Flowers
(
(BlockKind::BlueFlower, 0),
make_model("voxygen.voxel.sprite.flowers.flower_blue_1"),
),
(
(BlockKind::BlueFlower, 1),
make_model("voxygen.voxel.sprite.flowers.flower_blue_2"),
),
(
(BlockKind::PinkFlower, 0),
make_model("voxygen.voxel.sprite.flowers.flower_pink_1"),
),
(
(BlockKind::PinkFlower, 1),
make_model("voxygen.voxel.sprite.flowers.flower_pink_2"),
),
(
(BlockKind::PinkFlower, 2),
make_model("voxygen.voxel.sprite.flowers.flower_pink_3"),
),
(
(BlockKind::PurpleFlower, 0),
make_model("voxygen.voxel.sprite.flowers.flower_purple_1"),
),
(
(BlockKind::RedFlower, 0),
make_model("voxygen.voxel.sprite.flowers.flower_red_1"),
),
(
(BlockKind::WhiteFlower, 0),
make_model("voxygen.voxel.sprite.flowers.flower_white_1"),
),
(
(BlockKind::YellowFlower, 0),
make_model("voxygen.voxel.sprite.flowers.flower_purple_1"),
),
(
(BlockKind::Sunflower, 0),
make_model("voxygen.voxel.sprite.flowers.sunflower_1"),
),
(
(BlockKind::Sunflower, 1),
make_model("voxygen.voxel.sprite.flowers.sunflower_2"),
),
// Grass
(
(BlockKind::LongGrass, 0),
make_model("voxygen.voxel.sprite.grass.grass_long_1"),
),
(
(BlockKind::LongGrass, 1),
make_model("voxygen.voxel.sprite.grass.grass_long_2"),
),
(
(BlockKind::LongGrass, 2),
make_model("voxygen.voxel.sprite.grass.grass_long_3"),
),
(
(BlockKind::LongGrass, 3),
make_model("voxygen.voxel.sprite.grass.grass_long_4"),
),
(
(BlockKind::LongGrass, 4),
make_model("voxygen.voxel.sprite.grass.grass_long_5"),
),
(
(BlockKind::MediumGrass, 0),
make_model("voxygen.voxel.sprite.grass.grass_med_1"),
),
(
(BlockKind::MediumGrass, 1),
make_model("voxygen.voxel.sprite.grass.grass_med_2"),
),
(
(BlockKind::MediumGrass, 2),
make_model("voxygen.voxel.sprite.grass.grass_med_3"),
),
(
(BlockKind::MediumGrass, 3),
make_model("voxygen.voxel.sprite.grass.grass_med_4"),
),
(
(BlockKind::MediumGrass, 4),
make_model("voxygen.voxel.sprite.grass.grass_med_5"),
),
(
(BlockKind::ShortGrass, 0),
make_model("voxygen.voxel.sprite.grass.grass_short_1"),
),
(
(BlockKind::ShortGrass, 1),
make_model("voxygen.voxel.sprite.grass.grass_short_2"),
),
(
(BlockKind::ShortGrass, 2),
make_model("voxygen.voxel.sprite.grass.grass_short_3"),
),
(
(BlockKind::ShortGrass, 3),
make_model("voxygen.voxel.sprite.grass.grass_short_3"),
),
(
(BlockKind::ShortGrass, 4),
make_model("voxygen.voxel.sprite.grass.grass_short_5"),
), ),
] ]
.into_iter() .into_iter()

View File

@ -149,6 +149,7 @@ impl<'a> BlockGen<'a> {
cave_xy, cave_xy,
cave_alt, cave_alt,
marble, marble,
marble_small,
rock, rock,
//cliffs, //cliffs,
cliff_hill, cliff_hill,
@ -257,16 +258,31 @@ impl<'a> BlockGen<'a> {
)) ))
} else if (wposf.z as f32) < height + 0.9 } else if (wposf.z as f32) < height + 0.9
&& (wposf.z as f32 > water_height + 3.0) && (wposf.z as f32 > water_height + 3.0)
&& (chaos * 4096.0).fract() < 0.15
&& marble > 0.6 && marble > 0.6
&& marble_small > 0.7
&& (marble * 3173.7).fract() < 0.5
{ {
let flowers = [
BlockKind::BlueFlower,
BlockKind::PinkFlower,
BlockKind::PurpleFlower,
BlockKind::RedFlower,
BlockKind::WhiteFlower,
BlockKind::YellowFlower,
BlockKind::Sunflower,
];
let grasses = [
BlockKind::LongGrass,
BlockKind::MediumGrass,
BlockKind::ShortGrass,
];
Some(Block::new( Some(Block::new(
if (height * 121.0).fract() < 0.15 { if (height * 1271.0).fract() < 0.3 {
BlockKind::Wheat flowers[(height * 7319.0) as usize % flowers.len()]
} else if (height * 121.0).fract() < 0.2 {
BlockKind::Flowers
} else { } else {
BlockKind::LongGrass grasses[(height * 7319.0) as usize % grasses.len()]
}, },
Rgb::broadcast(0), Rgb::broadcast(0),
)) ))
@ -520,11 +536,7 @@ fn block_from_structure(
) )
.map(|e| e as u8), .map(|e| e as u8),
)), )),
StructureBlock::Fruit => Some(Block::new( StructureBlock::Fruit => Some(Block::new(BlockKind::Apple, Rgb::new(194, 30, 37))),
BlockKind::Normal,
Lerp::lerp(Rgb::new(237.0, 0.0, 0.0), Rgb::new(200.0, 237.0, 0.0), lerp)
.map(|e| e as u8),
)),
StructureBlock::Hollow => Some(Block::empty()), StructureBlock::Hollow => Some(Block::empty()),
StructureBlock::Normal(color) => { StructureBlock::Normal(color) => {
Some(Block::new(default_kind, color)).filter(|block| !block.is_empty()) Some(Block::new(default_kind, color)).filter(|block| !block.is_empty())

View File

@ -366,11 +366,11 @@ lazy_static! {
pub static ref FRUIT_TREES: Vec<Arc<Structure>> = vec![ pub static ref FRUIT_TREES: Vec<Arc<Structure>> = vec![
// fruit trees // fruit trees
st_asset("world.tree.fruit.1", (5, 5, 7)), st_asset("world.tree.fruit.1", (5, 5, 7)),
st_asset("world.tree.fruit.2", (5, 5, 7)), st_asset("world.tree.fruit.2", (6, 6, 7)),
st_asset("world.tree.fruit.3", (5, 5, 7)), st_asset("world.tree.fruit.3", (6, 7, 7)),
st_asset("world.tree.fruit.4", (5, 5, 7)), st_asset("world.tree.fruit.4", (3, 3, 7)),
st_asset("world.tree.fruit.5", (5, 5, 7)), st_asset("world.tree.fruit.5", (6, 8, 7)),
st_asset("world.tree.fruit.6", (5, 5, 7)), st_asset("world.tree.fruit.6", (7, 7, 7)),
]; ];
/* /*

View File

@ -360,6 +360,7 @@ impl<'a> Sampler for ColumnGen<'a> {
cave_xy, cave_xy,
cave_alt, cave_alt,
marble, marble,
marble_small,
rock, rock,
is_cliffs, is_cliffs,
near_cliffs, near_cliffs,
@ -386,6 +387,7 @@ pub struct ColumnSample<'a> {
pub cave_xy: f32, pub cave_xy: f32,
pub cave_alt: f32, pub cave_alt: f32,
pub marble: f32, pub marble: f32,
pub marble_small: f32,
pub rock: f32, pub rock: f32,
pub is_cliffs: bool, pub is_cliffs: bool,
pub near_cliffs: bool, pub near_cliffs: bool,