mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Dark water
This commit is contained in:
parent
207568a012
commit
899a7c56ab
@ -12,7 +12,7 @@ uniform u_lights {
|
||||
|
||||
vec3 illuminate(vec3 color, vec3 light, vec3 diffuse, vec3 ambience) {
|
||||
float avg_col = (color.r + color.g + color.b) / 3.0;
|
||||
return ((color - avg_col) * light + (diffuse + ambience) * avg_col) * (diffuse);
|
||||
return ((color - avg_col) * light + (diffuse + ambience) * avg_col) * diffuse;
|
||||
}
|
||||
|
||||
float attenuation_strength(vec3 rpos) {
|
||||
|
@ -29,7 +29,7 @@ vec3 get_sun_dir(float time_of_day) {
|
||||
const float PERSISTENT_AMBIANCE = 0.1;
|
||||
|
||||
float get_sun_brightness(vec3 sun_dir) {
|
||||
return max(-sun_dir.z + 0.6, 0.0);
|
||||
return max(-sun_dir.z + 0.6, 0.0) * 0.8;
|
||||
}
|
||||
|
||||
void get_sun_diffuse(vec3 norm, float time_of_day, out vec3 light, out vec3 diffuse_light, out vec3 ambient_light) {
|
||||
|
@ -47,24 +47,26 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
for y in 0..outer.size().h {
|
||||
let mut outside = true;
|
||||
for z in (0..outer.size().d).rev() {
|
||||
if vol
|
||||
let block = vol
|
||||
.get(outer.min + Vec3::new(x, y, z))
|
||||
.map(|vox| vox.is_air() || vox.is_fluid())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
if !outside {
|
||||
voids.insert(Vec3::new(x, y, z), None);
|
||||
}
|
||||
} else if outside {
|
||||
.ok()
|
||||
.copied()
|
||||
.unwrap_or(Block::empty());
|
||||
|
||||
if !block.is_air() && outside {
|
||||
rays[(outer.size().w * y + x) as usize] = z;
|
||||
outside = false;
|
||||
}
|
||||
|
||||
if (block.is_air() || block.is_fluid()) && !outside {
|
||||
voids.insert(Vec3::new(x, y, z), None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut opens = HashSet::new();
|
||||
for (pos, l) in &mut voids {
|
||||
'voids: for (pos, l) in &mut voids {
|
||||
for dir in &DIRS {
|
||||
let col = Vec2::<i32>::from(*pos) + dir;
|
||||
if pos.z
|
||||
@ -74,8 +76,18 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
{
|
||||
*l = Some(sunlight - 1);
|
||||
opens.insert(*pos);
|
||||
continue 'voids;
|
||||
}
|
||||
}
|
||||
|
||||
if pos.z
|
||||
>= *rays
|
||||
.get(((outer.size().w * pos.y) + pos.x) as usize)
|
||||
.unwrap_or(&0)
|
||||
{
|
||||
*l = Some(sunlight - 1);
|
||||
opens.insert(*pos);
|
||||
}
|
||||
}
|
||||
|
||||
while opens.len() > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user