mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Faster meshing, better dusk
This commit is contained in:
parent
d719c69fca
commit
4bbc340f52
@ -11,7 +11,7 @@ const vec3 SUN_HALO_DAY = vec3(0.35, 0.35, 0.0);
|
||||
const vec3 SKY_DUSK_TOP = vec3(0.06, 0.1, 0.20);
|
||||
const vec3 SKY_DUSK_MID = vec3(0.35, 0.1, 0.15);
|
||||
const vec3 SKY_DUSK_BOT = vec3(0.0, 0.1, 0.13);
|
||||
const vec3 DUSK_LIGHT = vec3(3.0, 1.0, 0.3);
|
||||
const vec3 DUSK_LIGHT = vec3(3.0, 1.5, 0.3);
|
||||
const vec3 SUN_HALO_DUSK = vec3(0.6, 0.1, 0.0);
|
||||
|
||||
const vec3 SKY_NIGHT_TOP = vec3(0.001, 0.001, 0.0025);
|
||||
@ -56,7 +56,7 @@ void get_sun_diffuse(vec3 norm, float time_of_day, out vec3 light, out vec3 diff
|
||||
vec3 sun_chroma = sun_color * sun_light;
|
||||
|
||||
light = sun_chroma + PERSISTENT_AMBIANCE;
|
||||
diffuse_light = sun_chroma * mix(1.0, dot(-norm, sun_dir) * 0.5 + 0.5, diffusion) + PERSISTENT_AMBIANCE;
|
||||
diffuse_light = sun_chroma * mix(1.0, max(dot(-norm, sun_dir) * 0.6 + 0.4, 0.0), diffusion) + PERSISTENT_AMBIANCE;
|
||||
ambient_light = vec3(SUN_AMBIANCE * sun_light);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
let mut vol_cached = vol.cached();
|
||||
|
||||
let mut voids = HashMap::new();
|
||||
let mut rays = vec![outer.size().d; outer.size().product() as usize];
|
||||
let mut rays = vec![(outer.size().d, 0); outer.size().product() as usize];
|
||||
for x in 0..outer.size().w {
|
||||
for y in 0..outer.size().h {
|
||||
let mut outside = true;
|
||||
@ -55,9 +55,12 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
.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() {
|
||||
if outside {
|
||||
rays[(outer.size().w * y + x) as usize].0 = z;
|
||||
outside = false;
|
||||
}
|
||||
rays[(outer.size().w * y + x) as usize].1 = z;
|
||||
}
|
||||
|
||||
if (block.is_air() || block.is_fluid()) && !outside {
|
||||
@ -74,6 +77,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
if pos.z
|
||||
> *rays
|
||||
.get(((outer.size().w * col.y) + col.x) as usize)
|
||||
.map(|(ray, _)| ray)
|
||||
.unwrap_or(&0)
|
||||
{
|
||||
*l = Some(sunlight - 1);
|
||||
@ -85,6 +89,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
if pos.z
|
||||
>= *rays
|
||||
.get(((outer.size().w * pos.y) + pos.x) as usize)
|
||||
.map(|(ray, _)| ray)
|
||||
.unwrap_or(&0)
|
||||
{
|
||||
*l = Some(sunlight - 1);
|
||||
@ -114,7 +119,15 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
move |wpos| {
|
||||
let pos = wpos - outer.min;
|
||||
rays.get(((outer.size().w * pos.y) + pos.x) as usize)
|
||||
.and_then(|ray| if pos.z > *ray { Some(1.0) } else { None })
|
||||
.and_then(|(ray, deep)| {
|
||||
if pos.z > *ray {
|
||||
Some(1.0)
|
||||
} else if pos.z < *deep {
|
||||
Some(0.0)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.or_else(|| {
|
||||
if let Some(Some(l)) = voids.get(&pos) {
|
||||
Some(*l as f32 / sunlight as f32)
|
||||
|
Loading…
Reference in New Issue
Block a user