Block-hopping fix, better dusk shaders

This commit is contained in:
Joshua Barretto 2019-06-29 22:09:36 +01:00
parent f1ba97ae7a
commit f2df3a9d18
3 changed files with 6 additions and 8 deletions

View File

@ -260,10 +260,8 @@ impl<'a> System<'a> for Sys {
// If the space above is free...
if !collision_with(pos.0 + Vec3::unit_z() * 1.1, near_iter.clone())
&& resolve_dir.z == 0.0
&& terrain
.get((pos.0 - Vec3::unit_z()).map(|e| e.floor() as i32)) // Make sure we're close to the ground
.map(|vox| !vox.is_empty())
.unwrap_or(false)
&& vel.0.z <= 0.0
&& collision_with(pos.0 + resolve_dir - Vec3::unit_z() * 1.05, near_iter.clone())
{
// ...block-hop!
pos.0.z = (pos.0.z + 1.0).ceil();
@ -284,7 +282,7 @@ impl<'a> System<'a> for Sys {
if on_ground {
on_grounds.insert(entity, OnGround);
// If we're not on the ground but the space below us is free, then "snap" to the ground
} else if collision_with(pos.0 - Vec3::unit_z() * 1.0, near_iter.clone())
} else if collision_with(pos.0 - Vec3::unit_z() * 1.05, near_iter.clone())
&& vel.0.z < 0.0
&& vel.0.z > -1.0
&& was_on_ground

View File

@ -45,9 +45,9 @@ vec3 get_sun_diffuse(vec3 norm, float time_of_day) {
),
DAY_LIGHT,
clamp(-sun_dir.z, 0, 1)
)) / 2.0 + 0.5;
));
vec3 diffuse_light = (SUN_AMBIANCE + max(dot(-norm, sun_dir), 0.0)) * sun_light * sun_color + PERSISTENT_AMBIANCE;
vec3 diffuse_light = (SUN_AMBIANCE + max(dot(-norm, sun_dir), 0.0) * sun_color) * sun_light + PERSISTENT_AMBIANCE;
return diffuse_light;
}

View File

@ -58,7 +58,7 @@ impl World {
pub fn generate_chunk(&self, chunk_pos: Vec2<i32>) -> TerrainChunk {
let air = Block::empty();
let stone = Block::new(1, Rgb::new(200, 220, 255));
let stone = Block::new(2, Rgb::new(200, 220, 255));
let water = Block::new(5, Rgb::new(100, 150, 255));
let chunk_size2d = Vec2::from(TerrainChunkSize::SIZE);