Keep fog local to world geometry
This commit is contained in:
parent
b7e5b7806c
commit
ffaa2ac37c
5 changed files with 107 additions and 90 deletions
|
|
@ -1,5 +1,5 @@
|
|||
shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_never, cull_back, unshaded;
|
||||
render_mode blend_mix, depth_draw_never, cull_back, unshaded, fog_disabled;
|
||||
|
||||
uniform sampler2D depth_texture : hint_depth_texture, repeat_disable, filter_nearest;
|
||||
|
||||
|
|
@ -35,10 +35,8 @@ uniform float open_water_drift_strength : hint_range(0.0, 0.08, 0.001) = 0.045;
|
|||
|
||||
uniform float distant_alpha_start : hint_range(10.0, 2000.0, 1.0) = 260.0;
|
||||
uniform float distant_alpha_end : hint_range(20.0, 5000.0, 1.0) = 1400.0;
|
||||
uniform vec4 distant_fog_color : source_color = vec4(0.549, 0.749, 0.765, 1.0);
|
||||
uniform float distant_fog_begin : hint_range(0.0, 2000.0, 1.0) = 42.0;
|
||||
uniform float distant_fog_end : hint_range(1.0, 5000.0, 1.0) = 170.0;
|
||||
uniform float distant_fog_strength : hint_range(0.0, 1.0, 0.01) = 0.18;
|
||||
uniform vec4 environment_tint : source_color = vec4(1.0);
|
||||
uniform float environment_brightness : hint_range(0.1, 1.2, 0.01) = 1.0;
|
||||
|
||||
varying vec3 world_position;
|
||||
varying float surface_view_depth;
|
||||
|
|
@ -237,14 +235,7 @@ void fragment() {
|
|||
water_color = mix(water_color, deep_color.rgb, distant_mix * 0.72);
|
||||
water_alpha = mix(water_alpha, 0.96, distant_mix);
|
||||
|
||||
float fog_distance_mix = smoothstep(
|
||||
distant_fog_begin,
|
||||
max(distant_fog_end, distant_fog_begin + 1.0),
|
||||
surface_view_depth
|
||||
);
|
||||
float water_fog_mix = fog_distance_mix * distant_fog_strength;
|
||||
water_color = mix(water_color, distant_fog_color.rgb, water_fog_mix);
|
||||
water_alpha = mix(water_alpha, 0.96, water_fog_mix);
|
||||
water_color *= environment_tint.rgb * environment_brightness;
|
||||
|
||||
ALBEDO = water_color;
|
||||
ALPHA = clamp(water_alpha, 0.1, 0.96);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,5 @@ shader_parameter/open_water_drift_speed = Vector2(0.01, -0.007)
|
|||
shader_parameter/open_water_drift_strength = 0.045
|
||||
shader_parameter/distant_alpha_start = 260.0
|
||||
shader_parameter/distant_alpha_end = 1400.0
|
||||
shader_parameter/distant_fog_color = Color(0.54902, 0.74902, 0.764706, 1)
|
||||
shader_parameter/distant_fog_begin = 42.0
|
||||
shader_parameter/distant_fog_end = 170.0
|
||||
shader_parameter/distant_fog_strength = 0.18
|
||||
shader_parameter/environment_tint = Color(1, 1, 1, 1)
|
||||
shader_parameter/environment_brightness = 1.0
|
||||
|
|
|
|||
|
|
@ -21,3 +21,5 @@ shader_parameter/open_water_drift_speed = Vector2(0.01, -0.007)
|
|||
shader_parameter/open_water_drift_strength = 0.045
|
||||
shader_parameter/distant_alpha_start = 260.0
|
||||
shader_parameter/distant_alpha_end = 1400.0
|
||||
shader_parameter/environment_tint = Color(1, 1, 1, 1)
|
||||
shader_parameter/environment_brightness = 1.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue