mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Improved long-range depth precision, removed unnecessary LoD polygons
This commit is contained in:
parent
63d1b2bb22
commit
f6a200d0cb
@ -31,14 +31,14 @@ vec3 lod_norm(vec2 pos) {
|
||||
|
||||
vec3 lod_col(vec2 pos) {
|
||||
vec3 warmth = mix(
|
||||
vec3(0.05, 0.4, 0.15),
|
||||
vec3(0.05, 0.4, 0.1),
|
||||
vec3(0.5, 0.4, 0.0),
|
||||
(texture(t_noise, pos * 0.0002).x - 0.5) * 2.0 + 0.5
|
||||
);
|
||||
|
||||
vec3 color = mix(
|
||||
warmth,
|
||||
vec3(0.5, 0.5, 0.5),
|
||||
vec3(0.3, 0.3, 0.4),
|
||||
alt_at(pos) / 1200.0
|
||||
);
|
||||
|
||||
|
@ -267,6 +267,8 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
|
||||
}
|
||||
|
||||
float fog(vec3 f_pos, vec3 focus_pos, uint medium) {
|
||||
return max(1.0 - 10000.0 / (1.0 + distance(f_pos.xy, focus_pos.xy)), 0.0);
|
||||
|
||||
float fog_radius = view_distance.x;
|
||||
float mist_radius = 10000000.0;
|
||||
|
||||
|
@ -13,6 +13,7 @@ out vec4 tgt_color;
|
||||
|
||||
void main() {
|
||||
vec3 f_norm = lod_norm(f_pos.xy);
|
||||
|
||||
vec3 f_col = lod_col(f_pos.xy);
|
||||
|
||||
vec3 light, diffuse_light, ambient_light;
|
||||
@ -22,7 +23,7 @@ void main() {
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
vec4 clouds;
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, cam_pos.xyz, f_pos, 1.0, true, clouds);
|
||||
vec3 color = mix(mix(surf_color, fog_color, 0.0), clouds.rgb, clouds.a);
|
||||
vec3 color = mix(mix(surf_color, vec3(1), fog_level), clouds.rgb, clouds.a);
|
||||
|
||||
tgt_color = vec4(color, 1.0);
|
||||
}
|
||||
|
@ -25,5 +25,5 @@ void main() {
|
||||
proj_mat *
|
||||
view_mat *
|
||||
vec4(f_pos, 1);
|
||||
gl_Position.z = 1.0 / (1.0 - gl_Position.z - 10.0);
|
||||
gl_Position.z = 1.0 / (1.0 - gl_Position.z * 0.001 - 100.0);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void main() {
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
vec4 clouds;
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, cam_pos.xyz, f_pos, 1.0, true, clouds);
|
||||
vec3 color = mix(mix(surf_color, fog_color, 0.0), clouds.rgb, clouds.a);
|
||||
vec3 color = mix(mix(surf_color, vec3(1), fog_level), clouds.rgb, clouds.a);
|
||||
|
||||
tgt_color = vec4(color, 1.0);
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ impl<V: RectRasterableVol<Vox = Block> + ReadVol + Debug> Meshable<TerrainPipeli
|
||||
if block.map_or(false, |vox| vox.is_opaque()) {
|
||||
vol::push_vox_verts(
|
||||
&mut opaque_mesh,
|
||||
faces_to_make(&blocks, false, |vox| !vox.is_opaque()),
|
||||
faces_to_make(&blocks, true, |vox| !vox.is_opaque()),
|
||||
offs,
|
||||
&colors,
|
||||
|pos, norm, col, ao, light| {
|
||||
@ -390,7 +390,7 @@ impl<V: RectRasterableVol<Vox = Block> + ReadVol + Debug> Meshable<TerrainPipeli
|
||||
} else if block.map_or(false, |vox| vox.is_fluid()) {
|
||||
vol::push_vox_verts(
|
||||
&mut fluid_mesh,
|
||||
faces_to_make(&blocks, false, |vox| vox.is_air()),
|
||||
faces_to_make(&blocks, true, |vox| vox.is_air()),
|
||||
offs,
|
||||
&colors,
|
||||
|pos, norm, col, _ao, light| {
|
||||
|
@ -13,7 +13,7 @@ impl Lod {
|
||||
pub fn new(renderer: &mut Renderer) -> Self {
|
||||
Self {
|
||||
model: renderer
|
||||
.create_model(&create_lod_terrain_mesh(100))
|
||||
.create_model(&create_lod_terrain_mesh(175))
|
||||
.unwrap(),
|
||||
locals: renderer.create_consts(&[Locals::default()]).unwrap(),
|
||||
}
|
||||
@ -31,6 +31,7 @@ fn create_lod_terrain_mesh(detail: usize) -> Mesh<LodTerrainPipeline> {
|
||||
|
||||
for x in 0..detail {
|
||||
for y in 0..detail {
|
||||
if Vec2::new(x, y).map(transform).magnitude() <= 1.0 {
|
||||
mesh.push_quad(Quad::new(
|
||||
Vertex::new(Vec2::new(x + 0, y + 0).map(transform)),
|
||||
Vertex::new(Vec2::new(x + 1, y + 0).map(transform)),
|
||||
@ -39,6 +40,7 @@ fn create_lod_terrain_mesh(detail: usize) -> Mesh<LodTerrainPipeline> {
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mesh
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user