Created
August 14, 2020 12:32
-
-
Save zesterer/b9292fa8ae7d09902c3b758eead3ae2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/assets/voxygen/shaders/figure-frag.glsl b/assets/voxygen/shaders/figure-frag.glsl | |
| index 315807549..d5bea01a3 100644 | |
| --- a/assets/voxygen/shaders/figure-frag.glsl | |
| +++ b/assets/voxygen/shaders/figure-frag.glsl | |
| @@ -146,7 +146,7 @@ void main() { | |
| // DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos); | |
| float point_shadow = shadow_at(f_pos, f_norm); | |
| - DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos); | |
| + DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos, view_dir); | |
| DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/); | |
| vec3 surf_color = /*srgb_to_linear*/(model_col.rgb * f_col); | |
| diff --git a/assets/voxygen/shaders/fluid-frag/cheap.glsl b/assets/voxygen/shaders/fluid-frag/cheap.glsl | |
| index 1b876d678..ae8cb380c 100644 | |
| --- a/assets/voxygen/shaders/fluid-frag/cheap.glsl | |
| +++ b/assets/voxygen/shaders/fluid-frag/cheap.glsl | |
| @@ -104,7 +104,7 @@ void main() { | |
| // DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos); | |
| float point_shadow = shadow_at(f_pos, f_norm); | |
| - DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos); | |
| + DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos, view_dir); | |
| DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/); | |
| float fluid_alt = f_pos.z;//max(ceil(f_pos.z), floor(f_alt));// f_alt;//max(f_alt - f_pos.z, 0.0); | |
| diff --git a/assets/voxygen/shaders/fluid-frag/shiny.glsl b/assets/voxygen/shaders/fluid-frag/shiny.glsl | |
| index bd3add41f..9273e18da 100644 | |
| --- a/assets/voxygen/shaders/fluid-frag/shiny.glsl | |
| +++ b/assets/voxygen/shaders/fluid-frag/shiny.glsl | |
| @@ -173,6 +173,9 @@ void main() { | |
| // vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz); | |
| // Squared to account for prior saturation. | |
| float f_light = 1.0;// pow(f_light, 1.5); | |
| + if (dot(-cam_to_frag, norm) < 0.0) { | |
| + f_light = 0.0; | |
| + } | |
| vec3 reflect_color = get_sky_color(/*reflect_ray_dir*/beam_view_dir, time_of_day.x, f_pos, vec3(-100000), 0.25, false, _clouds) * f_light; | |
| // /*const */vec3 water_color = srgb_to_linear(vec3(0.2, 0.5, 1.0)); | |
| // /*const */vec3 water_color = srgb_to_linear(vec3(0.8, 0.9, 1.0)); | |
| @@ -196,7 +199,7 @@ void main() { | |
| // DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos); | |
| float point_shadow = shadow_at(f_pos, f_norm); | |
| - DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos); | |
| + DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos, view_dir); | |
| DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/); | |
| // Hack to determine water depth: color goes down with distance through water, so | |
| @@ -283,7 +286,7 @@ void main() { | |
| // diffuse_light += point_light; | |
| // reflected_light += point_light; | |
| // vec3 surf_color = srgb_to_linear(vec3(0.2, 0.5, 1.0)) * light * diffuse_light * ambient_light; | |
| - vec3 surf_color = illuminate(max_light, view_dir, water_color * emitted_light/* * log(1.0 - MU_WATER)*/, /*cam_attenuation * *//*water_color * */reflect_color * reflected_light/* * log(1.0 - MU_WATER)*/); | |
| + vec3 surf_color = illuminate(max_light, view_dir, water_color * emitted_light/* * log(1.0 - MU_WATER)*/, /*cam_attenuation * *//*water_color * */reflect_color * 1.0/* * log(1.0 - MU_WATER)*/); | |
| // passthrough = pow(passthrough, 1.0 / (1.0 + water_depth_to_camera)); | |
| /* surf_color = cam_attenuation.g < 0.5 ? | |
| @@ -309,7 +312,7 @@ void main() { | |
| // float log_cam = log(min(cam_attenuation.r, min(cam_attenuation.g, cam_attenuation.b))); | |
| float min_refl = min(emitted_light.r, min(emitted_light.g, emitted_light.b)); | |
| - 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, (1.0 - 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, mix(1.0, 1.0 / (1.0 + /*0.25 * *//*diffuse_light*/(/*f_light * point_shadow*/reflected_light_point)), passthrough)); | |
| // vec4 color = vec4(surf_color, mix(1.0, length(cam_attenuation), passthrough)); | |
| @@ -325,7 +328,10 @@ void main() { | |
| vec3 fog_color = get_sky_color(cam_to_frag/*-view_dir*/, time_of_day.x, cam_pos.xyz, f_pos, 0.25, false, clouds); | |
| vec4 final_color = mix(mix(color, vec4(fog_color, 0.0), fog_level), vec4(clouds.rgb, 0.0), clouds.a); | |
| #elif (CLOUD_MODE == CLOUD_MODE_NONE) | |
| - vec4 final_color = color; | |
| + float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x); | |
| + vec4 clouds; | |
| + vec3 fog_color = get_sky_color(cam_to_frag/*-view_dir*/, time_of_day.x, cam_pos.xyz, f_pos, 0.25, false, clouds); | |
| + vec4 final_color = mix(color, vec4(fog_color, 0.0), fog_level); | |
| #endif | |
| tgt_color = final_color; | |
| } | |
| diff --git a/assets/voxygen/shaders/include/sky.glsl b/assets/voxygen/shaders/include/sky.glsl | |
| index 5ae73158f..9c9dae17b 100644 | |
| --- a/assets/voxygen/shaders/include/sky.glsl | |
| +++ b/assets/voxygen/shaders/include/sky.glsl | |
| @@ -89,7 +89,9 @@ vec3 get_moon_color(/*vec3 moon_dir*/) { | |
| return vec3(0.05, 0.05, 0.6); | |
| } | |
| -DirectionalLight get_sun_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/, /*vec4 sun_pos*/vec3 f_pos) { | |
| +DirectionalLight get_sun_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/, /*vec4 sun_pos*/vec3 f_pos, vec3 view_dir) { | |
| + f_pos += (_dir.xyz * 0.5 + view_dir) * distance(f_pos, cam_pos.xyz) / 200.0; | |
| + | |
| float shadow = shade_frac; | |
| #ifdef HAS_SHADOW_MAPS | |
| #if (SHADOW_MODE == SHADOW_MODE_MAP) | |
| @@ -363,7 +365,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q | |
| const bool has_clouds = true; | |
| #endif | |
| - if (with_stars || has_clouds) { | |
| + if (with_stars || has_clouds || true) { | |
| // Sky color | |
| /* vec3 sun_dir = get_sun_dir(time_of_day); | |
| vec3 moon_dir = get_moon_dir(time_of_day); */ | |
| diff --git a/assets/voxygen/shaders/lod-terrain-frag.glsl b/assets/voxygen/shaders/lod-terrain-frag.glsl | |
| index 8ae0f0ab2..bd51e18ef 100644 | |
| --- a/assets/voxygen/shaders/lod-terrain-frag.glsl | |
| +++ b/assets/voxygen/shaders/lod-terrain-frag.glsl | |
| @@ -530,7 +530,7 @@ void main() { | |
| // // float brightness_denominator = (ambient_sides + vec3(SUN_AMBIANCE * sun_light + moon_light); | |
| // DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos); | |
| - DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, /*sun_pos*/f_pos); | |
| + DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, /*sun_pos*/f_pos, view_dir); | |
| DirectionalLight moon_info = get_moon_info(moon_dir, moon_shade_frac/*, light_pos*/); | |
| float alpha = 1.0;//0.1;//0.2;///1.0;//sqrt(2.0); | |
| diff --git a/assets/voxygen/shaders/particle-frag.glsl b/assets/voxygen/shaders/particle-frag.glsl | |
| index 4dfbd6dbc..26eef0da6 100644 | |
| --- a/assets/voxygen/shaders/particle-frag.glsl | |
| +++ b/assets/voxygen/shaders/particle-frag.glsl | |
| @@ -47,7 +47,7 @@ void main() { | |
| float moon_shade_frac = 1.0; | |
| float point_shadow = shadow_at(f_pos, f_norm); | |
| - DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, f_pos); | |
| + DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, f_pos, view_dir); | |
| DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac); | |
| vec3 surf_color = f_col; | |
| diff --git a/assets/voxygen/shaders/sprite-frag.glsl b/assets/voxygen/shaders/sprite-frag.glsl | |
| index fd97f688a..0b24c8829 100644 | |
| --- a/assets/voxygen/shaders/sprite-frag.glsl | |
| +++ b/assets/voxygen/shaders/sprite-frag.glsl | |
| @@ -124,7 +124,7 @@ void main() { | |
| // DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos); | |
| float point_shadow = shadow_at(f_pos, f_norm); | |
| - DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos); | |
| + DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos, view_dir); | |
| DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/); | |
| vec3 surf_color = /*srgb_to_linear*//*linear_to_srgb*/(f_col); | |
| diff --git a/assets/voxygen/shaders/terrain-frag.glsl b/assets/voxygen/shaders/terrain-frag.glsl | |
| index efbc5d412..22875b635 100644 | |
| --- a/assets/voxygen/shaders/terrain-frag.glsl | |
| +++ b/assets/voxygen/shaders/terrain-frag.glsl | |
| @@ -227,7 +227,7 @@ void main() { | |
| // DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos); | |
| float point_shadow = shadow_at(f_pos, f_norm); | |
| - DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos); | |
| + DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos, view_dir); | |
| DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/); | |
| float max_light = 0.0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment