mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed water in caves, made water reflection vary with lighting
This commit is contained in:
parent
5d4079b165
commit
825d8bb632
@ -21,15 +21,15 @@ out vec4 tgt_color;
|
||||
|
||||
void main() {
|
||||
vec3 light = get_sun_diffuse(f_norm, time_of_day.x) * f_light + light_at(f_pos, f_norm);
|
||||
vec3 surf_color = f_col * light;
|
||||
vec3 surf_color = f_col * light;
|
||||
|
||||
float fog_level = fog(f_pos.xy, focus_pos.xy);
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x);
|
||||
|
||||
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
|
||||
vec3 warped_norm = normalize(f_norm + smooth_rand(f_pos * 0.35, tick.x) * 0.2);
|
||||
vec3 reflect_color = get_sky_color(reflect(cam_to_frag, warped_norm), time_of_day.x);
|
||||
float passthrough = max(dot(f_norm, -cam_to_frag), 0.0);
|
||||
vec3 reflect_color = get_sky_color(reflect(cam_to_frag, warped_norm), time_of_day.x) * light;
|
||||
float passthrough = dot(faceforward(f_norm, f_norm, cam_to_frag), -cam_to_frag);
|
||||
|
||||
vec4 color = mix(vec4(reflect_color, 1.0), vec4(surf_color, f_opac), passthrough);
|
||||
|
||||
|
@ -108,7 +108,7 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
if terrain
|
||||
.get(block_pos)
|
||||
.map(|vox| !vox.is_empty())
|
||||
.map(|vox| vox.is_solid())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let player_aabb = Aabb {
|
||||
@ -183,7 +183,7 @@ impl<'a> System<'a> for Sys {
|
||||
.filter(|(block_pos, _)| {
|
||||
terrain
|
||||
.get(*block_pos)
|
||||
.map(|vox| !vox.is_empty())
|
||||
.map(|vox| vox.is_solid())
|
||||
.unwrap_or(false)
|
||||
})
|
||||
// Find the maximum of the minimum collision axes (this bit is weird, trust me that it works)
|
||||
|
@ -34,6 +34,14 @@ impl BlockKind {
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_solid(&self) -> bool {
|
||||
match self {
|
||||
BlockKind::Air => false,
|
||||
BlockKind::Water => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -13,12 +13,12 @@ use vek::*;
|
||||
type TerrainVertex = <TerrainPipeline as render::Pipeline>::Vertex;
|
||||
type FluidVertex = <FluidPipeline as render::Pipeline>::Vertex;
|
||||
|
||||
fn block_shadow_density(kind: BlockKind) -> Option<f32> {
|
||||
fn block_shadow_density(kind: BlockKind) -> (f32, f32) {
|
||||
match kind {
|
||||
BlockKind::Air => None,
|
||||
BlockKind::Normal => Some(0.85),
|
||||
BlockKind::Dense => Some(3.0),
|
||||
BlockKind::Water => Some(0.8),
|
||||
BlockKind::Air => (0.0, 0.0),
|
||||
BlockKind::Normal => (0.085, 0.3),
|
||||
BlockKind::Dense => (0.3, 0.0),
|
||||
BlockKind::Water => (0.08, 0.0),
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,16 +94,14 @@ impl<V: BaseVol<Vox = Block> + ReadVol + Debug, S: VolSize + Clone> Meshable for
|
||||
// Accumulate shade under opaque blocks
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
neighbour_light[0][i][j] = if let Some(density) = self
|
||||
let (density, cap) = self
|
||||
.get(pos + Vec3::new(i as i32 - 1, j as i32 - 1, -1))
|
||||
.ok()
|
||||
.and_then(|vox| block_shadow_density(vox.kind()))
|
||||
{
|
||||
(neighbour_light[0][i][j] * (1.0 - density * 0.1))
|
||||
.max(1.0 - density)
|
||||
} else {
|
||||
(neighbour_light[0][i][j] * 1.025).min(1.0)
|
||||
};
|
||||
.map(|vox| block_shadow_density(vox.kind()))
|
||||
.unwrap_or((0.0, 0.0));
|
||||
|
||||
neighbour_light[0][i][j] =
|
||||
(neighbour_light[0][i][j] * (1.0 - density)).max(cap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ impl<'a> BlockGen<'a> {
|
||||
let (definitely_underground, height, water_height) =
|
||||
if (wposf.z as f32) < alt - 64.0 * chaos {
|
||||
// Shortcut warping
|
||||
(true, alt, water_level)
|
||||
(true, alt, CONFIG.sea_level /*water_level*/)
|
||||
} else {
|
||||
// Apply warping
|
||||
let warp = (world
|
||||
@ -204,7 +204,11 @@ impl<'a> BlockGen<'a> {
|
||||
(alt + warp).max(cliff_height)
|
||||
};
|
||||
|
||||
(false, height, (water_level + warp).max(CONFIG.sea_level))
|
||||
(
|
||||
false,
|
||||
height,
|
||||
/*(water_level + warp).max(*/ CONFIG.sea_level, /*)*/
|
||||
)
|
||||
};
|
||||
|
||||
// Sample blocks
|
||||
@ -250,9 +254,6 @@ impl<'a> BlockGen<'a> {
|
||||
BlockKind::Normal,
|
||||
saturate_srgb(col, 0.45).map(|e| (e * 255.0) as u8),
|
||||
))
|
||||
} else if (wposf.z as f32) < water_height {
|
||||
// Ocean
|
||||
Some(water)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -296,6 +297,16 @@ impl<'a> BlockGen<'a> {
|
||||
}
|
||||
});
|
||||
|
||||
// Water
|
||||
let block = block.or_else(|| {
|
||||
if (wposf.z as f32) < water_height {
|
||||
// Ocean
|
||||
Some(water)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
let block = structures
|
||||
.iter()
|
||||
.find_map(|st| {
|
||||
|
Loading…
Reference in New Issue
Block a user