mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better water shaders
This commit is contained in:
parent
63d5e196e9
commit
3a989f061f
@ -34,16 +34,6 @@ void main() {
|
||||
|
||||
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
|
||||
|
||||
/*
|
||||
// Round the position to the nearest triangular grid cell
|
||||
vec3 hex_pos = f_pos * 2.0;
|
||||
hex_pos = hex_pos + vec3(hex_pos.y * 1.4 / 3.0, hex_pos.y * 0.1, 0);
|
||||
if (fract(hex_pos.x) > fract(hex_pos.y)) {
|
||||
hex_pos += vec3(1.0, 1.0, 0);
|
||||
}
|
||||
hex_pos = floor(hex_pos);
|
||||
*/
|
||||
|
||||
vec3 light, diffuse_light, ambient_light;
|
||||
get_sun_diffuse(f_norm, time_of_day.x, light, diffuse_light, ambient_light, 0.0);
|
||||
float point_shadow = shadow_at(f_pos,f_norm);
|
||||
@ -52,7 +42,7 @@ void main() {
|
||||
vec3 point_light = light_at(f_pos, f_norm);
|
||||
light += point_light;
|
||||
diffuse_light += point_light;
|
||||
vec3 surf_color = illuminate(srgb_to_linear(vec3(0.2, 0.2, 1.0)), light, diffuse_light, ambient_light);
|
||||
vec3 surf_color = srgb_to_linear(vec3(0.4, 0.7, 2.0)) * light * diffuse_light * ambient_light;
|
||||
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
vec4 clouds;
|
||||
|
@ -68,16 +68,6 @@ void main() {
|
||||
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
|
||||
float frag_dist = length(f_pos - cam_pos.xyz);
|
||||
|
||||
/*
|
||||
// Round the position to the nearest triangular grid cell
|
||||
vec3 hex_pos = f_pos * 2.0;
|
||||
hex_pos = hex_pos + vec3(hex_pos.y * 1.4 / 3.0, hex_pos.y * 0.1, 0);
|
||||
if (fract(hex_pos.x) > fract(hex_pos.y)) {
|
||||
hex_pos += vec3(1.0, 1.0, 0);
|
||||
}
|
||||
hex_pos = floor(hex_pos);
|
||||
*/
|
||||
|
||||
vec3 b_norm;
|
||||
if (f_norm.z > 0.0) {
|
||||
b_norm = vec3(1, 0, 0);
|
||||
@ -111,7 +101,7 @@ void main() {
|
||||
vec3 point_light = light_at(f_pos, norm);
|
||||
light += point_light;
|
||||
diffuse_light += point_light;
|
||||
vec3 surf_color = illuminate(srgb_to_linear(f_col), light, diffuse_light, ambient_light);
|
||||
vec3 surf_color = srgb_to_linear(vec3(0.2, 0.5, 1.0)) * light * diffuse_light * ambient_light;
|
||||
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
vec4 clouds;
|
||||
@ -119,7 +109,7 @@ void main() {
|
||||
|
||||
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);
|
||||
reflect_ray_dir.z = max(reflect_ray_dir.z, 0.01);
|
||||
|
||||
vec4 _clouds;
|
||||
vec3 reflect_color = get_sky_color(reflect_ray_dir, time_of_day.x, f_pos, vec3(-100000), 0.25, false, _clouds) * f_light;
|
||||
|
@ -27,6 +27,9 @@ void main() {
|
||||
f_pos.z *= min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0);
|
||||
f_pos.z -= 25.0 * pow(distance(focus_pos.xy, f_pos.xy) / view_distance.x, 20.0);
|
||||
|
||||
// Small waves
|
||||
f_pos.z -= 0.05 + 0.05 * (sin(tick.x * 2.0 + f_pos.x * 2.0 + f_pos.y * 2.0) + 1.0) * 0.5;
|
||||
|
||||
f_col = vec3(
|
||||
float((v_col_light >> 8) & 0xFFu),
|
||||
float((v_col_light >> 16) & 0xFFu),
|
||||
|
@ -21,6 +21,8 @@ const vec3 SKY_NIGHT_MID = vec3(0.001, 0.005, 0.02);
|
||||
const vec3 SKY_NIGHT_BOT = vec3(0.002, 0.004, 0.004);
|
||||
const vec3 NIGHT_LIGHT = vec3(0.002, 0.01, 0.03);
|
||||
|
||||
const float UNDERWATER_MIST_DIST = 100.0;
|
||||
|
||||
vec3 get_sun_dir(float time_of_day) {
|
||||
const float TIME_FACTOR = (PI * 2.0) / (3600.0 * 24.0);
|
||||
|
||||
@ -202,7 +204,7 @@ float fog(vec3 f_pos, vec3 focus_pos, uint medium) {
|
||||
float max_fog = 1.0;
|
||||
|
||||
if (medium == 1u) {
|
||||
mist_radius = 96.0;
|
||||
mist_radius = UNDERWATER_MIST_DIST;
|
||||
min_fog = 0.0;
|
||||
}
|
||||
|
||||
|
@ -14,5 +14,13 @@ out vec4 tgt_color;
|
||||
|
||||
void main() {
|
||||
vec4 _clouds;
|
||||
tgt_color = vec4(get_sky_color(normalize(f_pos), time_of_day.x, cam_pos.xyz, vec3(-100000), 1.0, true, _clouds), 1.0);
|
||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||
|
||||
float dist = 100000.0;
|
||||
if (medium.x == 1u) {
|
||||
dist = UNDERWATER_MIST_DIST;
|
||||
}
|
||||
vec3 wpos = cam_pos.xyz + normalize(f_pos) * dist;
|
||||
|
||||
tgt_color = vec4(get_sky_color(normalize(f_pos), time_of_day.x, cam_pos.xyz, wpos, 1.0, true, _clouds), 1.0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user