mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made clouds render over terrain
This commit is contained in:
parent
9d48cc8fb7
commit
2c2dd49aed
@ -39,8 +39,9 @@ void main() {
|
||||
vec3 surf_color = illuminate(srgb_to_linear(model_col.rgb * f_col), light, diffuse_light, ambient_light);
|
||||
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, f_pos, 0.5, true);
|
||||
vec3 color = mix(surf_color, fog_color, fog_level);
|
||||
vec4 clouds;
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, f_pos, 0.5, true, clouds);
|
||||
vec3 color = mix(mix(surf_color, fog_color, fog_level), clouds.rgb, clouds.a);
|
||||
|
||||
tgt_color = vec4(color, 1.0);
|
||||
}
|
||||
|
@ -114,21 +114,21 @@ void main() {
|
||||
vec3 surf_color = illuminate(srgb_to_linear(f_col), light, diffuse_light, ambient_light);
|
||||
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
vec3 fog_color = vec3(0);
|
||||
if (fog_level > 0.0)
|
||||
fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, f_pos, 0.25, true);
|
||||
vec4 clouds;
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, f_pos, 0.25, true, clouds);
|
||||
|
||||
vec3 reflect_ray_dir = reflect(cam_to_frag, norm);
|
||||
// Hack to prevent the reflection ray dipping below the horizon and creating weird blue spots in the water
|
||||
reflect_ray_dir.z = max(reflect_ray_dir.z, 0.05);
|
||||
|
||||
vec3 reflect_color = get_sky_color(reflect_ray_dir, time_of_day.x, vec3(-100000), 0.5, false) * f_light;
|
||||
vec4 _clouds;
|
||||
vec3 reflect_color = get_sky_color(reflect_ray_dir, time_of_day.x, vec3(-100000), 0.5, false, _clouds) * f_light;
|
||||
// Tint
|
||||
reflect_color = mix(reflect_color, surf_color, 0.6);
|
||||
// 0 = 100% reflection, 1 = translucent water
|
||||
float passthrough = pow(dot(faceforward(f_norm, f_norm, cam_to_frag), -cam_to_frag), 0.5);
|
||||
|
||||
vec4 color = mix(vec4(reflect_color * 2.0, 1.0), vec4(surf_color, 4.0 / (4.0 + diffuse_light * 1.0)), passthrough);
|
||||
vec4 color = mix(vec4(reflect_color * 2.0, 1.0), vec4(surf_color, 1.0 / (1.0 + diffuse_light * 0.25)), passthrough);
|
||||
|
||||
tgt_color = mix(color, vec4(fog_color, 0.0), fog_level);
|
||||
tgt_color = mix(mix(color, vec4(fog_color, 0.0), fog_level), vec4(clouds.rgb, 0.0), clouds.a);
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ vec4 get_cloud_color(vec3 dir, float time_of_day, float max_dist, float quality)
|
||||
return vec4(vec3(cloud_shade), 1.0 - passthrough / (1.0 + min(delta, max_dist) * 0.0003));
|
||||
}
|
||||
|
||||
vec3 get_sky_color(vec3 dir, float time_of_day, vec3 f_pos, float quality, bool with_stars) {
|
||||
vec3 get_sky_color(vec3 dir, float time_of_day, vec3 f_pos, float quality, bool with_stars, out vec4 clouds) {
|
||||
// Sky color
|
||||
vec3 sun_dir = get_sun_dir(time_of_day);
|
||||
vec3 moon_dir = get_moon_dir(time_of_day);
|
||||
@ -261,10 +261,10 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 f_pos, float quality, bool
|
||||
);
|
||||
|
||||
// Approximate distance to fragment
|
||||
float f_dist = vsum(abs(cam_pos.xyz - f_pos));
|
||||
float f_dist = distance(cam_pos.xyz, f_pos);
|
||||
|
||||
// Clouds
|
||||
vec4 clouds = get_cloud_color(dir, time_of_day, f_dist, quality);
|
||||
clouds = get_cloud_color(dir, time_of_day, f_dist, quality);
|
||||
clouds.rgb *= get_sun_brightness(sun_dir) * (sun_halo * 2.5 + get_sun_color(sun_dir)) + get_moon_brightness(moon_dir) * (moon_halo * 20.5 + get_moon_color(moon_dir));
|
||||
|
||||
if (f_dist > 5000.0) {
|
||||
|
@ -13,5 +13,6 @@ uniform u_locals {
|
||||
out vec4 tgt_color;
|
||||
|
||||
void main() {
|
||||
tgt_color = vec4(get_sky_color(normalize(f_pos), time_of_day.x, vec3(-100000), 1.0, true), 1.0);
|
||||
vec4 _clouds;
|
||||
tgt_color = vec4(get_sky_color(normalize(f_pos), time_of_day.x, vec3(-100000), 1.0, true, _clouds), 1.0);
|
||||
}
|
||||
|
@ -27,8 +27,9 @@ void main() {
|
||||
vec3 surf_color = illuminate(f_col, light, diffuse_light, ambient_light);
|
||||
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, f_pos, 0.5, true);
|
||||
vec3 color = mix(surf_color, fog_color, fog_level);
|
||||
vec4 clouds;
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, f_pos, 0.5, true, clouds);
|
||||
vec3 color = mix(mix(surf_color, fog_color, fog_level), clouds.rgb, clouds.a);
|
||||
|
||||
tgt_color = vec4(color, 1.0 - clamp((distance(focus_pos.xy, f_pos.xy) - (RENDER_DIST - FADE_DIST)) / FADE_DIST, 0, 1));
|
||||
}
|
||||
|
@ -40,10 +40,9 @@ void main() {
|
||||
vec3 surf_color = illuminate(srgb_to_linear(f_col), light, diffuse_light, ambient_light);
|
||||
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
vec3 fog_color = vec3(0);
|
||||
if (fog_level > 0.0)
|
||||
fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, f_pos, 0.5, true);
|
||||
vec3 color = mix(surf_color, fog_color, fog_level);
|
||||
vec4 clouds;
|
||||
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, f_pos, 0.5, true, clouds);
|
||||
vec3 color = mix(mix(surf_color, fog_color, fog_level), clouds.rgb, clouds.a);
|
||||
|
||||
tgt_color = vec4(color, 1.0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user