Fix for translucency blocking clouds

This commit is contained in:
Joshua Barretto 2022-01-21 17:29:59 +00:00
parent d2d4ca33c9
commit 31b9cd0565
3 changed files with 16 additions and 3 deletions

View File

@ -70,7 +70,13 @@ void main() {
vec3 dir = (wpos - cam_pos.xyz) / dist;
// Apply clouds
color.rgb = get_cloud_color(color.rgb, dir, cam_pos.xyz, time_of_day.x, dist, 1.0);
float cloud_blend = 1.0;
if (color.a < 1.0) {
cloud_blend = 1.0 - color.a;
dist = 50000;
}
color.rgb = mix(color.rgb, get_cloud_color(color.rgb, dir, cam_pos.xyz, time_of_day.x, dist, 1.0), cloud_blend);
#if (CLOUD_MODE == CLOUD_MODE_NONE)
color.rgb = apply_point_glow(cam_pos.xyz + focus_off.xyz, dir, dist, color.rgb);
#endif

View File

@ -272,7 +272,7 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
#endif
// Underwater light attenuation
surf_color.rgb = water_diffuse(surf_color.rgb, dir, max_dist);
surf_color = water_diffuse(surf_color, dir, max_dist);
// Apply point glow
surf_color = apply_point_glow(origin, dir, max_dist, surf_color);

View File

@ -98,7 +98,14 @@ impl SkyboxPipeline {
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: wgpu::TextureFormat::Rgba16Float,
blend: None,
blend: Some(wgpu::BlendState {
color: wgpu::BlendComponent::REPLACE,
alpha: wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::Zero,
dst_factor: wgpu::BlendFactor::One,
operation: wgpu::BlendOperation::Add,
},
}),
write_mask: wgpu::ColorWrite::ALL,
}],
}),