mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
added grass sprites
This commit is contained in:
parent
6633298722
commit
c1b07465cf
BIN
assets/voxygen/voxel/sprite/grass/grass_snow_0.vox
(Stored with Git LFS)
Normal file
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
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
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
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
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
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
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
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
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
BIN
assets/voxygen/voxel/sprite/grass/grass_snow_9.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -497,7 +501,6 @@ impl Block {
|
|||||||
| BlockKind::DropGate
|
| BlockKind::DropGate
|
||||||
| BlockKind::DropGateBottom
|
| BlockKind::DropGateBottom
|
||||||
| BlockKind::Door => Some(self.color[0] & 0b111),
|
| BlockKind::Door => Some(self.color[0] & 0b111),
|
||||||
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
@ -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,15 +92,17 @@ pub fn apply_scatter_to<'a>(
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let bk = scatter
|
let bk = scatter.iter().enumerate().find_map(|(i, (bk, f))| {
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.find_map(|(i, (bk, f))| {
|
|
||||||
let (density, patch) = f(chunk);
|
let (density, patch) = f(chunk);
|
||||||
if density <= 0.0 || patch.map(|(wavelen, threshold)| index
|
if density <= 0.0
|
||||||
.noise
|
|| patch
|
||||||
.scatter_nz
|
.map(|(wavelen, threshold)| {
|
||||||
.get(wpos2d.map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0).into_array()) < threshold as f64)
|
index.noise.scatter_nz.get(
|
||||||
|
wpos2d
|
||||||
|
.map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0)
|
||||||
|
.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)
|
||||||
{
|
{
|
||||||
@ -73,8 +115,15 @@ pub fn apply_scatter_to<'a>(
|
|||||||
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,7 +344,11 @@ 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(
|
||||||
|
wpos2d.x as f32,
|
||||||
|
wpos2d.y as f32,
|
||||||
|
cave_base as f32,
|
||||||
|
))
|
||||||
.with_alignment(comp::Alignment::Enemy)
|
.with_alignment(comp::Alignment::Enemy)
|
||||||
.with_body(match rng.gen_range(0, 6) {
|
.with_body(match rng.gen_range(0, 6) {
|
||||||
0 => {
|
0 => {
|
||||||
|
Loading…
Reference in New Issue
Block a user