diff --git a/assets/voxygen/shaders/clouds-frag.glsl b/assets/voxygen/shaders/clouds-frag.glsl index 9ae5009df5..fed2f2b93b 100644 --- a/assets/voxygen/shaders/clouds-frag.glsl +++ b/assets/voxygen/shaders/clouds-frag.glsl @@ -124,7 +124,7 @@ void main() { { cloud_blend = 1.0 - color.a; - #if (FLUID_MODE >= FLUID_MODE_MEDIUM) + #if (FLUID_MODE >= FLUID_MODE_MEDIUM || REFLECTION_MODE >= REFLECTION_MODE_MEDIUM) if (dir.z < 0.0) { vec3 surf_norm = normalize(vec3(nz * 0.3 / (1.0 + dist * 0.1), 1)); vec3 refl_dir = reflect(dir, surf_norm); diff --git a/assets/voxygen/shaders/fluid-frag/cheap.glsl b/assets/voxygen/shaders/fluid-frag/cheap.glsl index a0807cc9b5..430c3922f7 100644 --- a/assets/voxygen/shaders/fluid-frag/cheap.glsl +++ b/assets/voxygen/shaders/fluid-frag/cheap.glsl @@ -108,7 +108,8 @@ void main() { vec3 view_dir = -cam_to_frag; // vec3 surf_color = /*srgb_to_linear*/(vec3(0.4, 0.7, 2.0)); - vec3 water_color = (1.0 - mix(pow(MU_WATER, vec3(0.25)), pow(vec3(0.8, 0.24, 0.08), vec3(0.25)), water_col_vel(f_pos.xy))) * MU_SCATTER; + float water_shade = water_col_vel(f_pos.xy); + vec3 water_color = (1.0 - mix(pow(MU_WATER, vec3(0.25)), pow(vec3(0.8, 0.9, 0.08), vec3(0.125)), water_shade)) * MU_SCATTER * vec3(3, 0.5, 0.4); /* vec3 sun_dir = get_sun_dir(time_of_day.x); vec3 moon_dir = get_moon_dir(time_of_day.x); */ @@ -158,10 +159,18 @@ void main() { vec3 k_d = vec3(1.0); vec3 k_s = vec3(R_s); + vec3 reflect_ray_dir = reflect(cam_to_frag, f_norm); + + vec3 reflect_color = vec3(0.0); + #if (REFLECTION_MODE >= REFLECTION_MODE_MEDIUM) + reflect_color = get_sky_color(reflect_ray_dir, time_of_day.x, f_pos, vec3(-100000), 0.125, true, 1.0, true, sun_shade_frac); + #endif + vec3 emitted_light, reflected_light; // Prevent the sky affecting light when underground float not_underground = clamp((f_pos.z - f_alt) / 128.0 + 1.0, 0.0, 1.0); + reflect_color *= not_underground; // float point_shadow = shadow_at(f_pos, f_norm); // vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz); @@ -215,16 +224,16 @@ void main() { // float reflected_light_point = /*length*/(diffuse_light_point.r) + f_light * point_shadow; // reflected_light += k_d * (diffuse_light_point + f_light * point_shadow * shade_frac) + specular_light_point; - float passthrough = max(dot(cam_norm, -cam_to_frag), 0) * 0.65; + float passthrough = max(dot(cam_norm, -cam_to_frag), 0); float min_refl = 0.0; - float opacity = (1.0 - passthrough) * 1.0 / (1.0 + min_refl); + float opacity = (1.0 - passthrough) * 1.0 / (1.0 + min_refl) * 0.5; if (medium.x == MEDIUM_WATER) { // Hack to make the opacity of the surface fade when underwater to avoid artifacts - opacity = min(sqrt(max(opacity, clamp((f_pos.z - cam_pos.z) * 0.05, 0.0, 1.0))), 1.0); + opacity = min(sqrt(max(opacity, clamp((f_pos.z - cam_pos.z) * 0.05, 0.0, 1.0))), 0.99); } - vec3 surf_color = illuminate(max_light, view_dir, water_color * /* fog_color * */emitted_light, /*surf_color * */water_color * reflected_light); + vec3 surf_color = illuminate(max_light, view_dir, water_color * /* fog_color * */emitted_light, /*surf_color * */reflect_color * water_shade + water_color * reflected_light); // vec4 color = vec4(surf_color, passthrough * 1.0 / (1.0 + min_refl));// * (1.0 - /*log(1.0 + cam_attenuation)*//*cam_attenuation*/1.0 / (2.0 - log_cam))); vec4 color = vec4(surf_color, opacity); diff --git a/assets/voxygen/shaders/lod-terrain-frag.glsl b/assets/voxygen/shaders/lod-terrain-frag.glsl index 99509f4214..58691d11e0 100644 --- a/assets/voxygen/shaders/lod-terrain-frag.glsl +++ b/assets/voxygen/shaders/lod-terrain-frag.glsl @@ -650,10 +650,10 @@ void main() { vec3 surf_color; float surf_alpha = 1.0; if (length(f_col_raw - vec3(0.02, 0.06, 0.22)) < 0.025 && dot(vec3(0, 0, 1), f_norm) > 0.9) { + vec3 reflect_ray = cam_to_frag * vec3(1, 1, -1); #if (FLUID_MODE >= FLUID_MODE_MEDIUM) vec3 water_color = (1.0 - MU_WATER) * MU_SCATTER; - vec3 reflect_ray = cam_to_frag * vec3(1, 1, -1); float passthrough = dot(faceforward(f_norm, f_norm, cam_to_frag), -cam_to_frag); @@ -675,6 +675,7 @@ void main() { surf_alpha = 1.0 - passthrough; #else surf_alpha = 0.9; + surf_color = get_sky_color(reflect_ray, time_of_day.x, f_pos, vec3(-100000), 0.125, true, 1.0, true, sun_shade_frac); #endif } else { surf_color = illuminate(max_light, view_dir, f_col * emitted_light, f_col * reflected_light);