mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix occlusion artifact
Former-commit-id: 23be3f1173706076802809576e3455833e64b4e4
This commit is contained in:
parent
7091557b82
commit
0bd84b58ec
@ -15,24 +15,28 @@ fn get_ao_quad<V: ReadVol>(vol: &V, pos: Vec3<i32>, dirs: &[Vec3<i32>]) -> Vec4<
|
|||||||
.map(|offs| {
|
.map(|offs| {
|
||||||
let (s1, s2) = (
|
let (s1, s2) = (
|
||||||
vol.get(pos + offs[0])
|
vol.get(pos + offs[0])
|
||||||
.map(|v| v.is_empty() as i32)
|
.map(|v| !v.is_empty())
|
||||||
.unwrap_or(1),
|
.unwrap_or(false),
|
||||||
vol.get(pos + offs[1])
|
vol.get(pos + offs[1])
|
||||||
.map(|v| v.is_empty() as i32)
|
.map(|v| !v.is_empty())
|
||||||
.unwrap_or(1),
|
.unwrap_or(false),
|
||||||
);
|
);
|
||||||
|
|
||||||
if s1 == 0 && s2 == 0 {
|
if s1 && s2 {
|
||||||
0
|
0.0
|
||||||
} else {
|
} else {
|
||||||
let corner = vol
|
let corner = vol
|
||||||
.get(pos + offs[0] + offs[1])
|
.get(pos + offs[0] + offs[1])
|
||||||
.map(|v| v.is_empty() as i32)
|
.map(|v| !v.is_empty())
|
||||||
.unwrap_or(1);
|
.unwrap_or(false);
|
||||||
s1 + s2 + corner
|
// Map both 1 and 2 neighbors to 0.5 occlusion
|
||||||
|
if s1 || s2 || corner {
|
||||||
|
0.5
|
||||||
|
} else {
|
||||||
|
1.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|i| i as f32 / 3.0)
|
|
||||||
.collect::<Vec4<f32>>()
|
.collect::<Vec4<f32>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user