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

View File

@ -24,7 +24,7 @@ struct TerrainChunk {
// GPU data
opaque_model: Model<TerrainPipeline>,
fluid_model: Model<FluidPipeline>,
sprite_instances: HashMap<BlockKind, Instances<SpriteInstance>>,
sprite_instances: HashMap<(BlockKind, usize), Instances<SpriteInstance>>,
locals: Consts<TerrainLocals>,
visible: bool,
@ -43,19 +43,68 @@ struct MeshWorkerResponse {
z_bounds: (f32, f32),
opaque_mesh: Mesh<TerrainPipeline>,
fluid_mesh: Mesh<FluidPipeline>,
sprite_instances: HashMap<BlockKind, Vec<SpriteInstance>>,
sprite_instances: HashMap<(BlockKind, usize), Vec<SpriteInstance>>,
started_tick: u64,
}
struct SpriteConfig {
variations: usize,
wind_sway: f32, // 1.0 is normal
}
fn sprite_config_for(kind: BlockKind) -> Option<SpriteConfig> {
match kind {
BlockKind::Wheat => Some(SpriteConfig { wind_sway: 1.0 }),
BlockKind::LongGrass => Some(SpriteConfig { wind_sway: 1.0 }),
BlockKind::Flowers => Some(SpriteConfig { wind_sway: 0.3 }),
BlockKind::LargeCactus => Some(SpriteConfig {
variations: 1,
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,
}
}
@ -88,7 +137,7 @@ fn mesh_worker(
let kind = volume.get(wpos).unwrap_or(&Block::empty()).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(
Mat4::identity()
@ -101,7 +150,7 @@ fn mesh_worker(
);
instances
.entry(kind)
.entry((kind, seed as usize % cfg.variations))
.or_insert_with(|| Vec::new())
.push(instance);
}
@ -125,7 +174,7 @@ pub struct Terrain {
mesh_todo: HashMap<Vec2<i32>, ChunkMeshState>,
// GPU data
sprite_models: HashMap<BlockKind, Model<SpritePipeline>>,
sprite_models: HashMap<(BlockKind, usize), Model<SpritePipeline>>,
}
impl Terrain {
@ -152,14 +201,125 @@ impl Terrain {
mesh_recv: recv,
mesh_todo: HashMap::default(),
sprite_models: vec![
(BlockKind::Wheat, make_model("voxygen.voxel.sprite.wheat")),
// Cacti
(
BlockKind::LongGrass,
make_model("voxygen.voxel.sprite.grass-0"),
(BlockKind::LargeCactus, 0),
make_model("voxygen.voxel.sprite.cacti.large_cactus"),
),
(
BlockKind::Flowers,
make_model("voxygen.voxel.sprite.flowers"),
(BlockKind::BarrelCactus, 0),
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()

View File

@ -149,6 +149,7 @@ impl<'a> BlockGen<'a> {
cave_xy,
cave_alt,
marble,
marble_small,
rock,
//cliffs,
cliff_hill,
@ -257,16 +258,31 @@ impl<'a> BlockGen<'a> {
))
} else if (wposf.z as f32) < height + 0.9
&& (wposf.z as f32 > water_height + 3.0)
&& (chaos * 4096.0).fract() < 0.15
&& 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(
if (height * 121.0).fract() < 0.15 {
BlockKind::Wheat
} else if (height * 121.0).fract() < 0.2 {
BlockKind::Flowers
if (height * 1271.0).fract() < 0.3 {
flowers[(height * 7319.0) as usize % flowers.len()]
} else {
BlockKind::LongGrass
grasses[(height * 7319.0) as usize % grasses.len()]
},
Rgb::broadcast(0),
))
@ -520,11 +536,7 @@ fn block_from_structure(
)
.map(|e| e as u8),
)),
StructureBlock::Fruit => Some(Block::new(
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::Fruit => Some(Block::new(BlockKind::Apple, Rgb::new(194, 30, 37))),
StructureBlock::Hollow => Some(Block::empty()),
StructureBlock::Normal(color) => {
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![
// fruit trees
st_asset("world.tree.fruit.1", (5, 5, 7)),
st_asset("world.tree.fruit.2", (5, 5, 7)),
st_asset("world.tree.fruit.3", (5, 5, 7)),
st_asset("world.tree.fruit.4", (5, 5, 7)),
st_asset("world.tree.fruit.5", (5, 5, 7)),
st_asset("world.tree.fruit.6", (5, 5, 7)),
st_asset("world.tree.fruit.2", (6, 6, 7)),
st_asset("world.tree.fruit.3", (6, 7, 7)),
st_asset("world.tree.fruit.4", (3, 3, 7)),
st_asset("world.tree.fruit.5", (6, 8, 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_alt,
marble,
marble_small,
rock,
is_cliffs,
near_cliffs,
@ -386,6 +387,7 @@ pub struct ColumnSample<'a> {
pub cave_xy: f32,
pub cave_alt: f32,
pub marble: f32,
pub marble_small: f32,
pub rock: f32,
pub is_cliffs: bool,
pub near_cliffs: bool,