mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Lighting fix
This commit is contained in:
parent
427339cc9a
commit
afd983f6f8
@ -26,11 +26,11 @@ impl Block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_opacity(&self) -> f32 {
|
pub fn get_opacity(&self) -> Option<f32> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
0 => 0.0,
|
0 => None,
|
||||||
1 => 0.3,
|
1 => Some(0.85),
|
||||||
2 => 1.0,
|
2 => Some(1.0),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ impl<V: BaseVol<Vox = Block> + ReadVol + Debug, S: VolSize + Clone> Meshable for
|
|||||||
|
|
||||||
for x in range.min.x + 1..range.max.x - 1 {
|
for x in range.min.x + 1..range.max.x - 1 {
|
||||||
for y in range.min.y + 1..range.max.y - 1 {
|
for y in range.min.y + 1..range.max.y - 1 {
|
||||||
let mut neighbour_light = [[1.0f32; 3]; 3];
|
let mut neighbour_light = [[(1.0f32, 0.0); 3]; 3];
|
||||||
|
|
||||||
for z in (range.min.z..range.max.z).rev() {
|
for z in (range.min.z..range.max.z).rev() {
|
||||||
let pos = Vec3::new(x, y, z);
|
let pos = Vec3::new(x, y, z);
|
||||||
@ -62,7 +62,7 @@ impl<V: BaseVol<Vox = Block> + ReadVol + Debug, S: VolSize + Clone> Meshable for
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|col| col.iter())
|
.map(|col| col.iter())
|
||||||
.flatten()
|
.flatten()
|
||||||
.fold(0.0, |a, x| a + x)
|
.fold(0.0, |a, (x, _)| a + x)
|
||||||
/ 9.0;
|
/ 9.0;
|
||||||
let light = avg_light;
|
let light = avg_light;
|
||||||
|
|
||||||
@ -85,13 +85,19 @@ impl<V: BaseVol<Vox = Block> + ReadVol + Debug, S: VolSize + Clone> Meshable for
|
|||||||
// Accumulate shade under opaque blocks
|
// Accumulate shade under opaque blocks
|
||||||
for i in 0..3 {
|
for i in 0..3 {
|
||||||
for j in 0..3 {
|
for j in 0..3 {
|
||||||
neighbour_light[i][j] = if let Ok(opacity) = self
|
let max_opacity = neighbour_light[i][j].1;
|
||||||
|
neighbour_light[i][j] = if let Some(opacity) = self
|
||||||
.get(pos + Vec3::new(i as i32 - 1, j as i32 - 1, 0))
|
.get(pos + Vec3::new(i as i32 - 1, j as i32 - 1, 0))
|
||||||
.map(|vox| vox.get_opacity())
|
.ok()
|
||||||
|
.and_then(|vox| vox.get_opacity())
|
||||||
{
|
{
|
||||||
neighbour_light[i][j] * (1.0 - opacity * 0.5)
|
(
|
||||||
|
(neighbour_light[i][j].0 * (1.0 - max_opacity * 0.3))
|
||||||
|
.max(1.0 - max_opacity * 0.999),
|
||||||
|
max_opacity.max(opacity),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
(neighbour_light[i][j] * 1.05).min(1.0)
|
((neighbour_light[i][j].0 * 1.02).min(1.0), max_opacity)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ impl<'a> Sampler<'a> {
|
|||||||
.mul(0.5);
|
.mul(0.5);
|
||||||
|
|
||||||
// Colours
|
// Colours
|
||||||
let cold_grass = Rgb::new(0.1, 0.6, 0.3);
|
let cold_grass = Rgb::new(0.0, 0.55, 0.15);
|
||||||
let warm_grass = Rgb::new(0.25, 0.8, 0.05);
|
let warm_grass = Rgb::new(0.25, 0.8, 0.05);
|
||||||
let cold_stone = Rgb::new(0.55, 0.7, 0.75);
|
let cold_stone = Rgb::new(0.55, 0.7, 0.75);
|
||||||
let warm_stone = Rgb::new(0.65, 0.65, 0.35);
|
let warm_stone = Rgb::new(0.65, 0.65, 0.35);
|
||||||
@ -461,7 +461,6 @@ impl SimChunk {
|
|||||||
.add(1.0)
|
.add(1.0)
|
||||||
.mul(0.5)
|
.mul(0.5)
|
||||||
.mul(1.0 - chaos * 0.85)
|
.mul(1.0 - chaos * 0.85)
|
||||||
.mul(1.2)
|
|
||||||
.add(0.1)
|
.add(0.1)
|
||||||
.mul(if alt > SEA_LEVEL + 2.0 { 1.0 } else { 0.0 }),
|
.mul(if alt > SEA_LEVEL + 2.0 { 1.0 } else { 0.0 }),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user