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) {
|
vec3 illuminate(vec3 color, vec3 light, vec3 diffuse, vec3 ambience) {
|
||||||
float avg_col = (color.r + color.g + color.b) / 3.0;
|
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) {
|
float attenuation_strength(vec3 rpos) {
|
||||||
|
@ -29,7 +29,7 @@ vec3 get_sun_dir(float time_of_day) {
|
|||||||
const float PERSISTENT_AMBIANCE = 0.1;
|
const float PERSISTENT_AMBIANCE = 0.1;
|
||||||
|
|
||||||
float get_sun_brightness(vec3 sun_dir) {
|
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) {
|
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 {
|
for y in 0..outer.size().h {
|
||||||
let mut outside = true;
|
let mut outside = true;
|
||||||
for z in (0..outer.size().d).rev() {
|
for z in (0..outer.size().d).rev() {
|
||||||
if vol
|
let block = vol
|
||||||
.get(outer.min + Vec3::new(x, y, z))
|
.get(outer.min + Vec3::new(x, y, z))
|
||||||
.map(|vox| vox.is_air() || vox.is_fluid())
|
.ok()
|
||||||
.unwrap_or(true)
|
.copied()
|
||||||
{
|
.unwrap_or(Block::empty());
|
||||||
if !outside {
|
|
||||||
voids.insert(Vec3::new(x, y, z), None);
|
if !block.is_air() && outside {
|
||||||
}
|
|
||||||
} else if outside {
|
|
||||||
rays[(outer.size().w * y + x) as usize] = z;
|
rays[(outer.size().w * y + x) as usize] = z;
|
||||||
outside = false;
|
outside = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (block.is_air() || block.is_fluid()) && !outside {
|
||||||
|
voids.insert(Vec3::new(x, y, z), None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut opens = HashSet::new();
|
let mut opens = HashSet::new();
|
||||||
for (pos, l) in &mut voids {
|
'voids: for (pos, l) in &mut voids {
|
||||||
for dir in &DIRS {
|
for dir in &DIRS {
|
||||||
let col = Vec2::<i32>::from(*pos) + dir;
|
let col = Vec2::<i32>::from(*pos) + dir;
|
||||||
if pos.z
|
if pos.z
|
||||||
@ -74,8 +76,18 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
|||||||
{
|
{
|
||||||
*l = Some(sunlight - 1);
|
*l = Some(sunlight - 1);
|
||||||
opens.insert(*pos);
|
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 {
|
while opens.len() > 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user