fix negative values for RGB and vary dryness and strength according to biome

This commit is contained in:
Christof Petig 2022-05-02 00:04:09 +02:00
parent 827006e7e0
commit f12f79439f
2 changed files with 14 additions and 9 deletions

View File

@ -192,7 +192,7 @@ void main() {
vec3(rand2 * 0.02, rand3 * 0.02, 1.0 + rand4 * 0.1)
),
vec3(linear_scale(0.5)),
vec4(vec3(0.8, 0.8, 1) * 0.5 * (1.0 + rand0), start_end(1.0, 0.0)),
vec4(vec3(0.8, 0.8, 1) * 0.125 * (3.8 + rand0), start_end(1.0, 0.0)),
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3 + lifetime * 0.5)
);
break;
@ -200,10 +200,10 @@ void main() {
attr = Attr(
linear_motion(
vec3(0),
vec3(rand2 * 0.02, rand3 * 0.02, 0.9 + rand4 * 0.1)
vec3(rand2 * 0.02, rand3 * 0.02, 1.0 + rand4 * 0.1)
),
vec3(linear_scale(0.5)),
vec4(vec3(0.8, 0.8, 1) * 0.5 * rand0, start_end(1.0, 0.0)),
vec4(vec3(0.8, 0.8, 1) * 0.125 * (1.8 + rand0), start_end(1.0, 0.0)),
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3 + lifetime * 0.5)
);
break;

View File

@ -54,7 +54,7 @@ pub struct BlocksOfInterest {
pub lights: Vec<(Vec3<i32>, u8)>,
}
fn dryness(biome: BiomeKind) -> u8 {
fn biome_dryness(biome: BiomeKind) -> i32 {
match biome {
BiomeKind::Void => 0,
BiomeKind::Lake => 0,
@ -159,12 +159,17 @@ impl BlocksOfInterest {
_ => match block.get_sprite() {
Some(SpriteKind::Ember) => {
let mut rng2 = ChaCha8Rng::from_seed(seed_from_pos(pos));
let strength_mod = (0.5_f32 - chunk.meta().temp()).max(0.0); // -0.5 (desert) to 1.5 (ice)
let strength = rng2
.gen_range((5.0 * strength_mod)..(100.0 * strength_mod).max(1.0))
as u8;
let dryness = (biome_dryness(chunk.meta().biome())
+ rng2.gen_range(-20..20))
.min(255)
.max(0) as u8;
// tracing::trace!(?pos, ?strength, ?dryness);
fires.push(pos);
smokers.push(SmokeProperties::new(
pos,
dryness(chunk.meta().biome()),
rng2.gen_range(20..200),
));
smokers.push(SmokeProperties::new(pos, dryness, strength));
},
// Offset positions to account for block height.
// TODO: Is this a good idea?