mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better mesa layer colours
This commit is contained in:
parent
48ebe004c0
commit
05863eb1ef
@ -62,6 +62,16 @@
|
||||
|
||||
grass_high: (0.15, 0.2, 0.15),
|
||||
tropical_high: (0.95, 0.55, 0.50),
|
||||
mesa_layers: [
|
||||
(0.6, 0.3, 0.2),
|
||||
(0.4, 0.03, 0.1),
|
||||
(0.8, 0.5, 0.2),
|
||||
(0.6, 0.25, 0.1),
|
||||
(0.35, 0.3, 0.15),
|
||||
(0.4, 0.15, 0.05),
|
||||
(0.2, 0.15, 0.1),
|
||||
(0.7, 0.6, 0.3),
|
||||
],
|
||||
),
|
||||
// NOTE: I think (but am not sure) that this is the color of stuff below the bottom-most
|
||||
// ground. I'm not sure how easy it is to see.
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
all::ForestKind,
|
||||
sim::{local_cells, Cave, Path, RiverKind, SimChunk, WorldSim},
|
||||
site::SpawnRules,
|
||||
util::{RandomField, Sampler},
|
||||
util::{RandomField, RandomPerm, Sampler},
|
||||
IndexRef, CONFIG,
|
||||
};
|
||||
use common::{
|
||||
@ -14,6 +14,7 @@ use common::{
|
||||
vol::RectVolSize,
|
||||
};
|
||||
use noise::NoiseFn;
|
||||
use rand::seq::SliceRandom;
|
||||
use serde::Deserialize;
|
||||
use std::ops::{Add, Div, Mul, Sub};
|
||||
use tracing::error;
|
||||
@ -47,6 +48,7 @@ pub struct Colors {
|
||||
|
||||
pub grass_high: (f32, f32, f32),
|
||||
pub tropical_high: (f32, f32, f32),
|
||||
pub mesa_layers: Vec<(f32, f32, f32)>,
|
||||
}
|
||||
|
||||
/// Generalised power function, pushes values in the range 0-1 to extremes.
|
||||
@ -926,25 +928,27 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
warm_stone_high,
|
||||
grass_high,
|
||||
tropical_high,
|
||||
} = index.colors.column;
|
||||
mesa_layers,
|
||||
} = &index.colors.column;
|
||||
|
||||
let cold_grass = cold_grass.into();
|
||||
let warm_grass = warm_grass.into();
|
||||
let dark_grass = dark_grass.into();
|
||||
let wet_grass = wet_grass.into();
|
||||
let cold_stone = cold_stone.into();
|
||||
let hot_stone = hot_stone.into();
|
||||
let warm_stone: Rgb<f32> = warm_stone.into();
|
||||
let beach_sand = beach_sand.into();
|
||||
let desert_sand = desert_sand.into();
|
||||
let snow = snow.into();
|
||||
let stone_col = stone_col.into();
|
||||
let dirt_low: Rgb<f32> = dirt_low.into();
|
||||
let dirt_high = dirt_high.into();
|
||||
let snow_high = snow_high.into();
|
||||
let warm_stone_high = warm_stone_high.into();
|
||||
let grass_high = grass_high.into();
|
||||
let tropical_high = tropical_high.into();
|
||||
let cold_grass = (*cold_grass).into();
|
||||
let warm_grass = (*warm_grass).into();
|
||||
let dark_grass = (*dark_grass).into();
|
||||
let wet_grass = (*wet_grass).into();
|
||||
let cold_stone = (*cold_stone).into();
|
||||
let hot_stone = (*hot_stone).into();
|
||||
let warm_stone: Rgb<f32> = (*warm_stone).into();
|
||||
let beach_sand = (*beach_sand).into();
|
||||
let desert_sand = (*desert_sand).into();
|
||||
let snow = (*snow).into();
|
||||
let snow_moss = (*snow_moss).into();
|
||||
let stone_col = (*stone_col).into();
|
||||
let dirt_low: Rgb<f32> = (*dirt_low).into();
|
||||
let dirt_high = (*dirt_high).into();
|
||||
let snow_high = (*snow_high).into();
|
||||
let warm_stone_high = (*warm_stone_high).into();
|
||||
let grass_high = (*grass_high).into();
|
||||
let tropical_high = (*tropical_high).into();
|
||||
|
||||
let dirt = Lerp::lerp(dirt_low, dirt_high, marble_mixed);
|
||||
let tundra = Lerp::lerp(snow, snow_high, 0.4 + marble_mixed * 0.6);
|
||||
@ -959,11 +963,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
.add(1.0.sub(humidity).mul(0.5))
|
||||
.powf(1.5),
|
||||
);
|
||||
let snow_moss = Rgb::lerp(
|
||||
snow_moss.into(),
|
||||
cold_grass,
|
||||
0.4 + marble_mixed.powf(1.5) * 0.6,
|
||||
);
|
||||
let snow_moss = Rgb::lerp(snow_moss, cold_grass, 0.4 + marble_mixed.powf(1.5) * 0.6);
|
||||
let moss = Rgb::lerp(dark_grass, cold_grass, marble_mixed.powf(1.5));
|
||||
let rainforest = Rgb::lerp(wet_grass, warm_grass, marble_mixed.powf(1.5));
|
||||
let sand = Rgb::lerp(beach_sand, desert_sand, marble_mixed);
|
||||
@ -1155,19 +1155,23 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
) * 0.9;
|
||||
let alt = Lerp::lerp(alt, mesa_alt, mesa.powf(2.0) * warp_factor);
|
||||
|
||||
let idx = alt * 0.35 + (alt * 0.35 + marble * 10.0).sin();
|
||||
let mesa_color = Lerp::lerp(
|
||||
Lerp::lerp(
|
||||
Rgb::new(0.6, 0.3, 0.2),
|
||||
Rgb::new(0.4, 0.03, 0.1),
|
||||
(alt * 0.2).sin() * 0.5 + 0.5,
|
||||
Rgb::from(
|
||||
mesa_layers
|
||||
.choose(&mut RandomPerm::new(idx as u32))
|
||||
.copied()
|
||||
.unwrap_or_default(),
|
||||
),
|
||||
Lerp::lerp(
|
||||
Rgb::new(0.8, 0.5, 0.2),
|
||||
Rgb::new(0.6, 0.25, 0.25),
|
||||
(alt * 0.3).sin() * 0.5 + 0.5,
|
||||
Rgb::from(
|
||||
mesa_layers
|
||||
.choose(&mut RandomPerm::new(idx as u32 + 1))
|
||||
.copied()
|
||||
.unwrap_or_default(),
|
||||
),
|
||||
(alt * 0.5).sin() * 0.5 + 0.5,
|
||||
idx.fract(),
|
||||
);
|
||||
|
||||
let sub_surface_color = Lerp::lerp(sub_surface_color, mesa_color, mesa.powf(0.25));
|
||||
|
||||
(sub_surface_color, ground, alt)
|
||||
|
@ -2472,15 +2472,19 @@ impl SimChunk {
|
||||
let mut alt = CONFIG.sea_level.add(alt_pre);
|
||||
let basement = CONFIG.sea_level.add(basement_pre);
|
||||
let water_alt = CONFIG.sea_level.add(water_alt_pre);
|
||||
let downhill = if downhill_pre == -2 {
|
||||
None
|
||||
let (downhill, _gradient) = if downhill_pre == -2 {
|
||||
(None, 0.0)
|
||||
} else if downhill_pre < 0 {
|
||||
panic!("Uh... shouldn't this never, ever happen?");
|
||||
} else {
|
||||
Some(
|
||||
uniform_idx_as_vec2(map_size_lg, downhill_pre as usize)
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32)
|
||||
+ TerrainChunkSize::RECT_SIZE.map(|e| e as i32 / 2),
|
||||
(
|
||||
Some(
|
||||
uniform_idx_as_vec2(map_size_lg, downhill_pre as usize)
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32)
|
||||
+ TerrainChunkSize::RECT_SIZE.map(|e| e as i32 / 2),
|
||||
),
|
||||
(alt_pre - gen_cdf.alt[downhill_pre as usize] as f32).abs()
|
||||
/ TerrainChunkSize::RECT_SIZE.x as f32,
|
||||
)
|
||||
};
|
||||
|
||||
@ -2528,10 +2532,12 @@ impl SimChunk {
|
||||
let tree_density = if is_underwater {
|
||||
0.0
|
||||
} else {
|
||||
let tree_density = (gen_ctx.tree_nz.get((wposf.div(1024.0)).into_array()))
|
||||
.mul(0.75)
|
||||
.add(0.55)
|
||||
.clamp(0.0, 1.0);
|
||||
let tree_density = Lerp::lerp(
|
||||
-1.5,
|
||||
2.5,
|
||||
gen_ctx.tree_nz.get((wposf.div(1024.0)).into_array()) * 0.5 + 0.5,
|
||||
)
|
||||
.clamp(0.0, 1.0);
|
||||
// Tree density should go (by a lot) with humidity.
|
||||
if humidity <= 0.0 || tree_density <= 0.0 {
|
||||
0.0
|
||||
@ -2546,8 +2552,9 @@ impl SimChunk {
|
||||
.add(0.5)
|
||||
} as f32;
|
||||
const MIN_TREE_HUM: f32 = 0.15;
|
||||
// Tree density increases exponentially with humidity...
|
||||
let tree_density = (tree_density * (humidity - MIN_TREE_HUM).max(0.0).mul(1.0 + MIN_TREE_HUM) / temp.max(0.75))
|
||||
let tree_density = tree_density
|
||||
// Tree density increases exponentially with humidity...
|
||||
.mul((humidity - MIN_TREE_HUM).max(0.0).mul(1.0 + MIN_TREE_HUM) / temp.max(0.75))
|
||||
// Places that are *too* wet (like marshes) also get fewer trees because the ground isn't stable enough for
|
||||
// them.
|
||||
//.mul((1.0 - flux * 0.05/*(humidity - 0.9).max(0.0) / 0.1*/).max(0.0))
|
||||
|
Loading…
Reference in New Issue
Block a user