added grass sprites

This commit is contained in:
Monty Marz 2020-08-10 09:57:01 +02:00 committed by Joshua Barretto
parent 6633298722
commit c1b07465cf
13 changed files with 253 additions and 83 deletions

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

View File

@ -90,6 +90,7 @@ pub enum BlockKind {
ShinyGem, ShinyGem,
DropGate, DropGate,
DropGateBottom, DropGateBottom,
GrassSnow,
} }
impl fmt::Display for BlockKind { impl fmt::Display for BlockKind {
@ -195,6 +196,7 @@ impl BlockKind {
BlockKind::ShinyGem => true, BlockKind::ShinyGem => true,
BlockKind::DropGate => false, BlockKind::DropGate => false,
BlockKind::DropGateBottom => false, BlockKind::DropGateBottom => false,
BlockKind::GrassSnow => true,
_ => false, _ => false,
} }
} }
@ -294,6 +296,7 @@ impl BlockKind {
BlockKind::ShinyGem => false, BlockKind::ShinyGem => false,
BlockKind::DropGate => false, BlockKind::DropGate => false,
BlockKind::DropGateBottom => false, BlockKind::DropGateBottom => false,
BlockKind::GrassSnow => false,
_ => true, _ => true,
} }
} }
@ -370,13 +373,14 @@ impl BlockKind {
BlockKind::ShinyGem => false, BlockKind::ShinyGem => false,
BlockKind::DropGate => true, BlockKind::DropGate => true,
BlockKind::DropGateBottom => false, BlockKind::DropGateBottom => false,
BlockKind::GrassSnow => false,
_ => true, _ => true,
} }
} }
pub fn is_explodable(&self) -> bool { pub fn is_explodable(&self) -> bool {
match self { match self {
BlockKind::Leaves | BlockKind::Grass | BlockKind::Rock => true, BlockKind::Leaves | BlockKind::Grass | BlockKind::Rock | BlockKind::GrassSnow => true,
_ => false, _ => false,
} }
} }
@ -494,10 +498,9 @@ impl Block {
| BlockKind::WardrobeSingle | BlockKind::WardrobeSingle
| BlockKind::WardrobeDouble | BlockKind::WardrobeDouble
| BlockKind::Pot | BlockKind::Pot
| BlockKind::DropGate | BlockKind::DropGate
| BlockKind::DropGateBottom | BlockKind::DropGateBottom
| BlockKind::Door => Some(self.color[0] & 0b111), | BlockKind::Door => Some(self.color[0] & 0b111),
_ => None, _ => None,
} }
} }

View File

@ -19,8 +19,8 @@ use crossbeam::channel;
use dot_vox::DotVoxData; use dot_vox::DotVoxData;
use hashbrown::HashMap; use hashbrown::HashMap;
use std::{f32, fmt::Debug, i32, marker::PhantomData, time::Duration}; use std::{f32, fmt::Debug, i32, marker::PhantomData, time::Duration};
use treeculler::{BVol, Frustum, AABB};
use tracing::warn; use tracing::warn;
use treeculler::{BVol, Frustum, AABB};
use vek::*; use vek::*;
struct TerrainChunkData { struct TerrainChunkData {
@ -359,6 +359,10 @@ fn sprite_config_for(kind: BlockKind) -> Option<SpriteConfig> {
variations: 1, variations: 1,
wind_sway: 0.0, wind_sway: 0.0,
}), }),
BlockKind::GrassSnow => Some(SpriteConfig {
variations: 10,
wind_sway: 0.2,
}),
_ => None, _ => None,
} }
} }
@ -2759,6 +2763,87 @@ impl<V: RectRasterableVol> Terrain<V> {
Vec3::one(), Vec3::one(),
), ),
), ),
// Snow covered Grass
(
(BlockKind::GrassSnow, 0),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_0",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 1),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_1",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 2),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_2",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 3),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_3",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 4),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_4",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 5),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_5",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 6),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_6",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 7),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_7",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 8),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_8",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
(
(BlockKind::GrassSnow, 9),
make_models(
"voxygen.voxel.sprite.grass.grass_snow_9",
Vec3::new(-2.5, -2.5, 0.0),
Vec3::one(),
),
),
] ]
.into_iter() .into_iter()
.collect(), .collect(),
@ -3142,7 +3227,6 @@ impl<V: RectRasterableVol> Terrain<V> {
let dist_sqrd = Vec2::from(focus_pos).distance_squared(chunk_center); let dist_sqrd = Vec2::from(focus_pos).distance_squared(chunk_center);
if dist_sqrd < sprite_render_distance.powf(2.0) { if dist_sqrd < sprite_render_distance.powf(2.0) {
for (kind, instances) in &chunk.sprite_instances { for (kind, instances) in &chunk.sprite_instances {
if let Some(models) = self.sprite_models.get(&kind) { if let Some(models) = self.sprite_models.get(&kind) {
renderer.render_sprites( renderer.render_sprites(
if dist_sqrd < sprite_high_detail_distance.powf(2.0) { if dist_sqrd < sprite_high_detail_distance.powf(2.0) {

View File

@ -1,26 +1,27 @@
use crate::{ use crate::{
column::ColumnSample, column::ColumnSample,
util::{RandomField, Sampler},
sim::SimChunk, sim::SimChunk,
util::{RandomField, Sampler},
Index, Index,
}; };
use common::{ use common::{
assets, assets, comp,
comp, generation::{ChunkSupplement, EntityInfo},
lottery::Lottery, lottery::Lottery,
terrain::{Block, BlockKind}, terrain::{Block, BlockKind},
vol::{BaseVol, ReadVol, RectSizedVol, Vox, WriteVol}, vol::{BaseVol, ReadVol, RectSizedVol, Vox, WriteVol},
generation::{ChunkSupplement, EntityInfo},
}; };
use noise::NoiseFn; use noise::NoiseFn;
use rand::prelude::*;
use std::{ use std::{
f32, f32,
ops::{Mul, Sub}, ops::{Mul, Sub},
}; };
use vek::*; use vek::*;
use rand::prelude::*;
fn close(x: f32, tgt: f32, falloff: f32) -> f32 { (1.0 - (x - tgt).abs() / falloff).max(0.0).powf(0.5) } fn close(x: f32, tgt: f32, falloff: f32) -> f32 {
(1.0 - (x - tgt).abs() / falloff).max(0.0).powf(0.5)
}
pub fn apply_scatter_to<'a>( pub fn apply_scatter_to<'a>(
wpos2d: Vec2<i32>, wpos2d: Vec2<i32>,
@ -32,11 +33,50 @@ pub fn apply_scatter_to<'a>(
use BlockKind::*; use BlockKind::*;
let scatter: &[(_, fn(&SimChunk) -> (f32, Option<(f32, f32)>))] = &[ let scatter: &[(_, fn(&SimChunk) -> (f32, Option<(f32, f32)>))] = &[
// (density, Option<(wavelen, threshold)>) // (density, Option<(wavelen, threshold)>)
(BlueFlower, |c| (close(c.temp, -0.3, 0.7).min(close(c.humidity, 0.6, 0.35)) * 0.05, Some((48.0, 0.6)))), (BlueFlower, |c| {
(PinkFlower, |c| (close(c.temp, 0.15, 0.5).min(close(c.humidity, 0.6, 0.35)) * 0.05, Some((48.0, 0.6)))), (
(DeadBush, |c| (close(c.temp, 0.8, 0.3).min(close(c.humidity, 0.0, 0.4)) * 0.015, None)), close(c.temp, -0.3, 0.7).min(close(c.humidity, 0.6, 0.35)) * 0.05,
Some((48.0, 0.6)),
)
}),
(PinkFlower, |c| {
(
close(c.temp, 0.15, 0.5).min(close(c.humidity, 0.6, 0.35)) * 0.05,
Some((48.0, 0.6)),
)
}),
(DeadBush, |c| {
(
close(c.temp, 0.8, 0.3).min(close(c.humidity, 0.0, 0.4)) * 0.015,
None,
)
}),
(Twigs, |c| ((c.tree_density - 0.5).max(0.0) * 0.0025, None)), (Twigs, |c| ((c.tree_density - 0.5).max(0.0) * 0.0025, None)),
(Stones, |c| ((c.rockiness - 0.5).max(0.0) * 0.005, None)), (Stones, |c| ((c.rockiness - 0.5).max(0.0) * 0.005, None)),
(ShortGrass, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.05,
Some((48.0, 0.4)),
)
}),
(MediumGrass, |c| {
(
close(c.temp, 0.0, 0.6).min(close(c.humidity, 0.6, 0.35)) * 0.05,
Some((48.0, 0.2)),
)
}),
(LongGrass, |c| {
(
close(c.temp, 0.4, 0.4).min(close(c.humidity, 0.8, 0.2)) * 0.05,
Some((48.0, 0.1)),
)
}),
(GrassSnow, |c| {
(
close(c.temp, -0.4, 0.4).min(close(c.rockiness, 0.0, 0.5)),
Some((48.0, 0.6)),
)
}),
]; ];
for y in 0..vol.size_xy().y as i32 { for y in 0..vol.size_xy().y as i32 {
@ -52,29 +92,38 @@ pub fn apply_scatter_to<'a>(
continue; continue;
}; };
let bk = scatter let bk = scatter.iter().enumerate().find_map(|(i, (bk, f))| {
.iter() let (density, patch) = f(chunk);
.enumerate() if density <= 0.0
.find_map(|(i, (bk, f))| { || patch
let (density, patch) = f(chunk); .map(|(wavelen, threshold)| {
if density <= 0.0 || patch.map(|(wavelen, threshold)| index index.noise.scatter_nz.get(
.noise wpos2d
.scatter_nz .map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0)
.get(wpos2d.map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0).into_array()) < threshold as f64) .into_array(),
) < threshold as f64
})
.unwrap_or(false) .unwrap_or(false)
|| !RandomField::new(i as u32).chance(Vec3::new(wpos2d.x, wpos2d.y, 0), density) || !RandomField::new(i as u32).chance(Vec3::new(wpos2d.x, wpos2d.y, 0), density)
{ {
None None
} else { } else {
Some(*bk) Some(*bk)
} }
}); });
if let Some(bk) = bk { if let Some(bk) = bk {
let mut z = col_sample.alt as i32 - 4; let mut z = col_sample.alt as i32 - 4;
for _ in 0..8 { for _ in 0..8 {
if vol.get(Vec3::new(offs.x, offs.y, z)).map(|b| !b.is_solid()).unwrap_or(true) { if vol
let _ = vol.set(Vec3::new(offs.x, offs.y, z), Block::new(bk, Rgb::broadcast(0))); .get(Vec3::new(offs.x, offs.y, z))
.map(|b| !b.is_solid())
.unwrap_or(true)
{
let _ = vol.set(
Vec3::new(offs.x, offs.y, z),
Block::new(bk, Rgb::broadcast(0)),
);
break; break;
} }
z += 1; z += 1;
@ -295,57 +344,61 @@ pub fn apply_caves_supplement<'a>(
if RandomField::new(index.seed).chance(wpos2d.into(), 0.00005) if RandomField::new(index.seed).chance(wpos2d.into(), 0.00005)
&& cave_base < surface_z as i32 - 40 && cave_base < surface_z as i32 - 40
{ {
let entity = EntityInfo::at(Vec3::new(wpos2d.x as f32, wpos2d.y as f32, cave_base as f32)) let entity = EntityInfo::at(Vec3::new(
.with_alignment(comp::Alignment::Enemy) wpos2d.x as f32,
.with_body(match rng.gen_range(0, 6) { wpos2d.y as f32,
0 => { cave_base as f32,
let species = match rng.gen_range(0, 2) { ))
0 => comp::quadruped_small::Species::Truffler, .with_alignment(comp::Alignment::Enemy)
_ => comp::quadruped_small::Species::Hyena, .with_body(match rng.gen_range(0, 6) {
}; 0 => {
comp::quadruped_small::Body::random_with(rng, &species).into() let species = match rng.gen_range(0, 2) {
}, 0 => comp::quadruped_small::Species::Truffler,
1 => { _ => comp::quadruped_small::Species::Hyena,
let species = match rng.gen_range(0, 3) { };
0 => comp::quadruped_medium::Species::Tarasque, comp::quadruped_small::Body::random_with(rng, &species).into()
1 => comp::quadruped_medium::Species::Frostfang, },
_ => comp::quadruped_medium::Species::Bonerattler, 1 => {
}; let species = match rng.gen_range(0, 3) {
comp::quadruped_medium::Body::random_with(rng, &species).into() 0 => comp::quadruped_medium::Species::Tarasque,
}, 1 => comp::quadruped_medium::Species::Frostfang,
2 => { _ => comp::quadruped_medium::Species::Bonerattler,
let species = match rng.gen_range(0, 3) { };
0 => comp::quadruped_low::Species::Maneater, comp::quadruped_medium::Body::random_with(rng, &species).into()
1 => comp::quadruped_low::Species::Rocksnapper, },
_ => comp::quadruped_low::Species::Salamander, 2 => {
}; let species = match rng.gen_range(0, 3) {
comp::quadruped_low::Body::random_with(rng, &species).into() 0 => comp::quadruped_low::Species::Maneater,
}, 1 => comp::quadruped_low::Species::Rocksnapper,
3 => { _ => comp::quadruped_low::Species::Salamander,
let species = match rng.gen_range(0, 3) { };
0 => comp::critter::Species::Fungome, comp::quadruped_low::Body::random_with(rng, &species).into()
1 => comp::critter::Species::Axolotl, },
_ => comp::critter::Species::Rat, 3 => {
}; let species = match rng.gen_range(0, 3) {
comp::critter::Body::random_with(rng, &species).into() 0 => comp::critter::Species::Fungome,
}, 1 => comp::critter::Species::Axolotl,
4 => { _ => comp::critter::Species::Rat,
let species = match rng.gen_range(0, 1) { };
_ => comp::golem::Species::StoneGolem, comp::critter::Body::random_with(rng, &species).into()
}; },
comp::golem::Body::random_with(rng, &species).into() 4 => {
}, let species = match rng.gen_range(0, 1) {
_ => { _ => comp::golem::Species::StoneGolem,
let species = match rng.gen_range(0, 4) { };
0 => comp::biped_large::Species::Ogre, comp::golem::Body::random_with(rng, &species).into()
1 => comp::biped_large::Species::Cyclops, },
2 => comp::biped_large::Species::Wendigo, _ => {
_ => comp::biped_large::Species::Troll, let species = match rng.gen_range(0, 4) {
}; 0 => comp::biped_large::Species::Ogre,
comp::biped_large::Body::random_with(rng, &species).into() 1 => comp::biped_large::Species::Cyclops,
}, 2 => comp::biped_large::Species::Wendigo,
}) _ => comp::biped_large::Species::Troll,
.with_automatic_name(); };
comp::biped_large::Body::random_with(rng, &species).into()
},
})
.with_automatic_name();
supplement.add_entity(entity); supplement.add_entity(entity);
} }