mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Improved cloud falloff mist, faster noise sampling
This commit is contained in:
parent
f6a200d0cb
commit
745e7540dd
@ -12,7 +12,7 @@ vec2 splay(vec2 pos, float e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec3 lod_pos(vec2 v_pos) {
|
vec3 lod_pos(vec2 v_pos) {
|
||||||
vec2 hpos = focus_pos.xy + splay(v_pos, 3.0) * 20000.0;
|
vec2 hpos = focus_pos.xy + splay(v_pos, 4.0) * 100000.0;
|
||||||
return vec3(hpos, alt_at(hpos));
|
return vec3(hpos, alt_at(hpos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ vec2 cloud_at(vec3 pos) {
|
|||||||
|
|
||||||
float shade = ((pos.z - CLOUD_AVG_HEIGHT) / (CLOUD_AVG_HEIGHT - CLOUD_HEIGHT_MIN) + 0.5);
|
float shade = ((pos.z - CLOUD_AVG_HEIGHT) / (CLOUD_AVG_HEIGHT - CLOUD_HEIGHT_MIN) + 0.5);
|
||||||
|
|
||||||
return vec2(shade, density / (1.0 + vsum(abs(pos - cam_pos.xyz)) / 5000));
|
return vec2(shade, density / (1.0 + vsum(abs(pos - cam_pos.xyz)) / 10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, float quality) {
|
vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, float quality) {
|
||||||
@ -143,7 +143,8 @@ vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, f
|
|||||||
float maxd = (CLOUD_HEIGHT_MAX - origin.z) / dir.z;
|
float maxd = (CLOUD_HEIGHT_MAX - origin.z) / dir.z;
|
||||||
|
|
||||||
float start = max(min(mind, maxd), 0.0);
|
float start = max(min(mind, maxd), 0.0);
|
||||||
float delta = min(abs(mind - maxd), max_dist);
|
float cloud_delta = abs(mind - maxd);
|
||||||
|
float delta = min(cloud_delta, max_dist);
|
||||||
|
|
||||||
bool do_cast = true;
|
bool do_cast = true;
|
||||||
if (mind < 0.0 && maxd < 0.0) {
|
if (mind < 0.0 && maxd < 0.0) {
|
||||||
@ -170,7 +171,7 @@ vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float total_density = 1.0 - passthrough;// / (1.0 + max(max_dist, start) * 0.0001);
|
float total_density = 1.0 - passthrough / (1.0 + (max_dist / (1.0 + max(abs(dir.z), 0.03) * 100.0)) * 0.00003);
|
||||||
|
|
||||||
total_density = max(total_density - 1.0 / pow(max_dist, 0.25), 0.0); // Hack
|
total_density = max(total_density - 1.0 / pow(max_dist, 0.25), 0.0); // Hack
|
||||||
|
|
||||||
@ -267,7 +268,7 @@ 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) {
|
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);
|
return max(1.0 - 5000.0 / (1.0 + distance(f_pos.xy, focus_pos.xy)), 0.0);
|
||||||
|
|
||||||
float fog_radius = view_distance.x;
|
float fog_radius = view_distance.x;
|
||||||
float mist_radius = 10000000.0;
|
float mist_radius = 10000000.0;
|
||||||
|
@ -23,7 +23,7 @@ void main() {
|
|||||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||||
vec4 clouds;
|
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 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, vec3(1), fog_level), clouds.rgb, clouds.a);
|
vec3 color = mix(mix(surf_color, fog_color, fog_level), clouds.rgb, clouds.a);
|
||||||
|
|
||||||
tgt_color = vec4(color, 1.0);
|
tgt_color = vec4(color, 1.0);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ void main() {
|
|||||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||||
vec4 clouds;
|
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 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, vec3(1), fog_level), clouds.rgb, clouds.a);
|
vec3 color = mix(mix(surf_color, fog_color, fog_level), clouds.rgb, clouds.a);
|
||||||
|
|
||||||
tgt_color = vec4(color, 1.0);
|
tgt_color = vec4(color, 1.0);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ impl Renderer {
|
|||||||
let noise_tex = Texture::new(
|
let noise_tex = Texture::new(
|
||||||
&mut factory,
|
&mut factory,
|
||||||
&assets::load_expect("voxygen.texture.noise"),
|
&assets::load_expect("voxygen.texture.noise"),
|
||||||
Some(gfx::texture::FilterMethod::Trilinear),
|
Some(gfx::texture::FilterMethod::Bilinear),
|
||||||
Some(gfx::texture::WrapMode::Tile),
|
Some(gfx::texture::WrapMode::Tile),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -1240,7 +1240,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
// a sample of the terrain that includes both the chunk we want and
|
// a sample of the terrain that includes both the chunk we want and
|
||||||
// its neighbours.
|
// its neighbours.
|
||||||
let volume = match client.state().terrain().sample(aabr) {
|
let volume = match client.state().terrain().sample(aabr) {
|
||||||
Ok(sample) => sample,
|
Ok(sample) => sample, // TODO: Ensure that all of the chunk's neighbours still exist to avoid buggy shadow borders
|
||||||
// Either this chunk or its neighbours doesn't yet exist, so we keep it in the
|
// Either this chunk or its neighbours doesn't yet exist, so we keep it in the
|
||||||
// queue to be processed at a later date when we have its neighbours.
|
// queue to be processed at a later date when we have its neighbours.
|
||||||
Err(VolGrid2dError::NoSuchChunk) => return,
|
Err(VolGrid2dError::NoSuchChunk) => return,
|
||||||
|
Loading…
Reference in New Issue
Block a user