mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed rain occlusion issues
This commit is contained in:
parent
fc21b54f02
commit
d4906f55bc
@ -93,11 +93,14 @@ void main() {
|
|||||||
vec3 rpos = vec3(0.0);
|
vec3 rpos = vec3(0.0);
|
||||||
float t = 0.0;
|
float t = 0.0;
|
||||||
const float PLANCK = 0.01;
|
const float PLANCK = 0.01;
|
||||||
while (t < 64.0) {
|
while (true) {
|
||||||
float scale = min(pow(2, ceil(t / 2.0)), 32);
|
float scale = min(pow(2, ceil(t / 2.0)), 32);
|
||||||
vec2 deltas = (step(vec2(0), dir2d) - fract(rpos.xy / scale + 100.0)) / dir2d;
|
vec2 deltas = (step(vec2(0), dir2d) - fract(rpos.xy / scale + 100.0)) / dir2d;
|
||||||
float jump = max(min(deltas.x, deltas.y) * scale, PLANCK);
|
float jump = max(min(deltas.x, deltas.y) * scale, PLANCK);
|
||||||
t += jump;
|
t += jump;
|
||||||
|
|
||||||
|
if (t >= 64.0) { break; }
|
||||||
|
|
||||||
rpos = rorigin + adjusted_dir * t;
|
rpos = rorigin + adjusted_dir * t;
|
||||||
|
|
||||||
vec2 diff = abs(round(rpos.xy) - rpos.xy);
|
vec2 diff = abs(round(rpos.xy) - rpos.xy);
|
||||||
@ -105,18 +108,18 @@ void main() {
|
|||||||
wall_pos.xz *= vec2(4, 0.3);
|
wall_pos.xz *= vec2(4, 0.3);
|
||||||
wall_pos.z += hash_two(uvec2(wall_pos.xy + vec2(0, 0.5)));
|
wall_pos.z += hash_two(uvec2(wall_pos.xy + vec2(0, 0.5)));
|
||||||
|
|
||||||
float depth_adjust = fract(hash_two(uvec2(wall_pos.xz)));
|
float depth_adjust = fract(hash_two(uvec2(wall_pos.xz) + 500u));
|
||||||
float wpos_dist = t - jump * depth_adjust;
|
float wpos_dist = t - jump * depth_adjust;
|
||||||
vec3 wpos = cam_pos.xyz + dir * wpos_dist;
|
vec3 wpos = cam_pos.xyz + dir * wpos_dist;
|
||||||
|
|
||||||
if (wpos_dist > dist) { break; }
|
if (wpos_dist > dist) { break; }
|
||||||
if (length((fract(wall_pos.xz) - 0.5)) < 0.1 + pow(max(0.0, wpos_dist - (dist - 0.25)) / 0.25, 4.0) * 0.2) {
|
if (length((fract(wall_pos.xz) - 0.5)) < 0.1 + pow(max(0.0, wpos_dist - (dist - 0.25)) / 0.25, 4.0) * 0.2) {
|
||||||
float density = rain_density * rain_occlusion_at(wpos);
|
float density = rain_density * rain_occlusion_at(wpos);
|
||||||
if (fract(hash_two(uvec2(wall_pos.xz))) >= density) { continue; }
|
if (fract(hash_two(uvec2(wall_pos.xz) + 1000u)) >= density) { continue; }
|
||||||
|
|
||||||
float alpha = 0.5 * clamp((wpos_dist - 1.0) * 0.5, 0.0, 1.0);
|
float alpha = 0.5 * clamp((wpos_dist - 1.0) * 0.5, 0.0, 1.0);
|
||||||
float light = dot(color.rgb, vec3(1)) + 0.1 + (get_sun_brightness() + get_moon_brightness()) * 0.3;
|
float light = dot(color.rgb, vec3(1)) + 0.05 + (get_sun_brightness() + get_moon_brightness()) * 0.2;
|
||||||
color.rgb = mix(color.rgb, vec3(0.1, 0.2, 0.5) * light, alpha);
|
color.rgb = mix(color.rgb, vec3(0.3, 0.35, 0.5) * light, alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ impl RainOcclusionPipeline {
|
|||||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||||
strip_index_format: None,
|
strip_index_format: None,
|
||||||
front_face: wgpu::FrontFace::Ccw,
|
front_face: wgpu::FrontFace::Ccw,
|
||||||
cull_mode: Some(wgpu::Face::Front),
|
cull_mode: Some(wgpu::Face::Back),
|
||||||
clamp_depth: true,
|
clamp_depth: true,
|
||||||
polygon_mode: wgpu::PolygonMode::Fill,
|
polygon_mode: wgpu::PolygonMode::Fill,
|
||||||
conservative: false,
|
conservative: false,
|
||||||
|
@ -48,7 +48,7 @@ const SPRITE_LOD_LEVELS: usize = 5;
|
|||||||
|
|
||||||
// For rain occlusion we only need to render the closest chunks.
|
// For rain occlusion we only need to render the closest chunks.
|
||||||
/// How many chunks are maximally rendered for rain occlusion.
|
/// How many chunks are maximally rendered for rain occlusion.
|
||||||
pub const RAIN_OCCLUSION_CHUNKS: usize = 9;
|
pub const RAIN_OCCLUSION_CHUNKS: usize = 25;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
struct Visibility {
|
struct Visibility {
|
||||||
|
Loading…
Reference in New Issue
Block a user