mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix some issues with underwater rendering.
This commit is contained in:
parent
bfda6da42f
commit
ffe0f5928c
@ -144,6 +144,7 @@ void main() {
|
|||||||
vec3 norm = vec3(0, 0, 1) * nmap.z + b_norm * nmap.x + c_norm * nmap.y;
|
vec3 norm = vec3(0, 0, 1) * nmap.z + b_norm * nmap.x + c_norm * nmap.y;
|
||||||
// vec3 norm = f_norm;
|
// vec3 norm = f_norm;
|
||||||
|
|
||||||
|
vec3 water_color = (1.0 - MU_WATER) * MU_SCATTER;
|
||||||
#if (SHADOW_MODE == SHADOW_MODE_CHEAP || SHADOW_MODE == SHADOW_MODE_MAP || FLUID_MODE == FLUID_MODE_SHINY)
|
#if (SHADOW_MODE == SHADOW_MODE_CHEAP || SHADOW_MODE == SHADOW_MODE_MAP || FLUID_MODE == FLUID_MODE_SHINY)
|
||||||
float f_alt = alt_at(f_pos.xy);
|
float f_alt = alt_at(f_pos.xy);
|
||||||
#elif (SHADOW_MODE == SHADOW_MODE_NONE || FLUID_MODE == FLUID_MODE_CHEAP)
|
#elif (SHADOW_MODE == SHADOW_MODE_NONE || FLUID_MODE == FLUID_MODE_CHEAP)
|
||||||
@ -282,7 +283,7 @@ void main() {
|
|||||||
// diffuse_light += point_light;
|
// diffuse_light += point_light;
|
||||||
// reflected_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 = srgb_to_linear(vec3(0.2, 0.5, 1.0)) * light * diffuse_light * ambient_light;
|
||||||
vec3 surf_color = illuminate(max_light, view_dir, 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 * reflected_light/* * log(1.0 - MU_WATER)*/);
|
||||||
|
|
||||||
// passthrough = pow(passthrough, 1.0 / (1.0 + water_depth_to_camera));
|
// passthrough = pow(passthrough, 1.0 / (1.0 + water_depth_to_camera));
|
||||||
/* surf_color = cam_attenuation.g < 0.5 ?
|
/* surf_color = cam_attenuation.g < 0.5 ?
|
||||||
|
@ -107,7 +107,7 @@ DirectionalLight get_sun_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return DirectionalLight(/*dir, */shade_frac * shadow/*, get_sun_color(dir), get_sun_brightness(dir)*/);
|
return DirectionalLight(/*dir, */shadow/*, get_sun_color(dir), get_sun_brightness(dir)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectionalLight get_moon_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/) {
|
DirectionalLight get_moon_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/) {
|
||||||
@ -414,8 +414,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
|
|||||||
);
|
);
|
||||||
|
|
||||||
vec3 sky_mid = mix(
|
vec3 sky_mid = mix(
|
||||||
mix(
|
mix( SKY_DUSK_MID,
|
||||||
SKY_DUSK_MID,
|
|
||||||
SKY_NIGHT_MID,
|
SKY_NIGHT_MID,
|
||||||
max(pow(sun_dir.z, 0.2), 0)
|
max(pow(sun_dir.z, 0.2), 0)
|
||||||
),
|
),
|
||||||
|
@ -489,6 +489,9 @@ vec3 compute_attenuation(vec3 wpos, vec3 ray_dir, vec3 mu, float surface_alt, ve
|
|||||||
#if (LIGHTING_TRANSPORT_MODE == LIGHTING_TRANSPORT_MODE_IMPORTANCE)
|
#if (LIGHTING_TRANSPORT_MODE == LIGHTING_TRANSPORT_MODE_IMPORTANCE)
|
||||||
return vec3(1.0);
|
return vec3(1.0);
|
||||||
#elif (LIGHTING_TRANSPORT_MODE == LIGHTING_TRANSPORT_MODE_RADIANCE)
|
#elif (LIGHTING_TRANSPORT_MODE == LIGHTING_TRANSPORT_MODE_RADIANCE)
|
||||||
|
#if (LIGHTING_TYPE & LIGHTING_TYPE_TRANSMISSION) != 0
|
||||||
|
return vec3(1.0);
|
||||||
|
#else
|
||||||
// return vec3(1.0);
|
// return vec3(1.0);
|
||||||
/*if (mu == vec3(0.0)) {
|
/*if (mu == vec3(0.0)) {
|
||||||
return vec3(1.0);
|
return vec3(1.0);
|
||||||
@ -497,33 +500,35 @@ vec3 compute_attenuation(vec3 wpos, vec3 ray_dir, vec3 mu, float surface_alt, ve
|
|||||||
}*/
|
}*/
|
||||||
// return vec3(0.0);
|
// return vec3(0.0);
|
||||||
// vec3 surface_dir = /*surface_alt < wpos.z ? vec3(0.0, 0.0, -1.0) : vec3(0.0, 0.0, 1.0)*/vec3(0.0, 0.0, sign(surface_alt - wpos.z));
|
// vec3 surface_dir = /*surface_alt < wpos.z ? vec3(0.0, 0.0, -1.0) : vec3(0.0, 0.0, 1.0)*/vec3(0.0, 0.0, sign(surface_alt - wpos.z));
|
||||||
|
ray_dir = faceforward(ray_dir, vec3(0.0, 0.0, -1.0), ray_dir);
|
||||||
vec3 surface_dir = surface_alt < wpos.z ? vec3(0.0, 0.0, -1.0) : vec3(0.0, 0.0, 1.0);
|
vec3 surface_dir = surface_alt < wpos.z ? vec3(0.0, 0.0, -1.0) : vec3(0.0, 0.0, 1.0);
|
||||||
// vec3 surface_dir = faceforward(vec3(0.0, 0.0, 1.0), ray_dir, vec3(0.0, 0.0, 1.0));
|
// vec3 surface_dir = faceforward(vec3(0.0, 0.0, 1.0), ray_dir, vec3(0.0, 0.0, 1.0));
|
||||||
bool _intersects_surface = IntersectRayPlane(wpos, ray_dir, vec3(0.0, 0.0, surface_alt), surface_dir, defaultpos);
|
bool _intersects_surface = IntersectRayPlane(wpos, ray_dir, vec3(0.0, 0.0, surface_alt), surface_dir, defaultpos);
|
||||||
float depth = length(defaultpos - wpos);
|
float depth = length(defaultpos - wpos);
|
||||||
return exp(-mu * depth);
|
return exp(-mu * depth);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 compute_attenuation2(vec3 wpos, vec3 ray_dir, vec3 mu, float surface_alt, vec3 defaultpos) {
|
// vec3 compute_attenuation2(vec3 wpos, vec3 ray_dir, vec3 mu, float surface_alt, vec3 defaultpos) {
|
||||||
#if (LIGHTING_TRANSPORT_MODE == LIGHTING_TRANSPORT_MODE_IMPORTANCE)
|
// #if (LIGHTING_TRANSPORT_MODE == LIGHTING_TRANSPORT_MODE_IMPORTANCE)
|
||||||
return vec3(1.0);
|
// return vec3(1.0);
|
||||||
#elif (LIGHTING_TRANSPORT_MODE == LIGHTING_TRANSPORT_MODE_RADIANCE)
|
// #elif (LIGHTING_TRANSPORT_MODE == LIGHTING_TRANSPORT_MODE_RADIANCE)
|
||||||
// return vec3(1.0);
|
// // return vec3(1.0);
|
||||||
/*if (mu == vec3(0.0)) {
|
// /*if (mu == vec3(0.0)) {
|
||||||
return vec3(1.0);
|
// return vec3(1.0);
|
||||||
}*//* else {
|
// }*//* else {
|
||||||
return vec3(0.0);
|
// return vec3(0.0);
|
||||||
}*/
|
// }*/
|
||||||
// return vec3(0.0);
|
// // return vec3(0.0);
|
||||||
// vec3 surface_dir = /*surface_alt < wpos.z ? vec3(0.0, 0.0, -1.0) : vec3(0.0, 0.0, 1.0)*/vec3(0.0, 0.0, sign(surface_alt - wpos.z));
|
// // vec3 surface_dir = /*surface_alt < wpos.z ? vec3(0.0, 0.0, -1.0) : vec3(0.0, 0.0, 1.0)*/vec3(0.0, 0.0, sign(surface_alt - wpos.z));
|
||||||
vec3 surface_dir = surface_alt < wpos.z ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 0.0, -1.0);
|
// vec3 surface_dir = surface_alt < wpos.z ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 0.0, -1.0);
|
||||||
// vec3 surface_dir = faceforward(vec3(0.0, 0.0, 1.0), ray_dir, vec3(0.0, 0.0, 1.0));
|
// // vec3 surface_dir = faceforward(vec3(0.0, 0.0, 1.0), ray_dir, vec3(0.0, 0.0, 1.0));
|
||||||
bool _intersects_surface = IntersectRayPlane(wpos, ray_dir, vec3(0.0, 0.0, surface_alt), surface_dir, defaultpos);
|
// bool _intersects_surface = IntersectRayPlane(wpos, ray_dir, vec3(0.0, 0.0, surface_alt), surface_dir, defaultpos);
|
||||||
float depth = length(defaultpos - wpos);
|
// float depth = length(defaultpos - wpos);
|
||||||
return exp(-mu * depth);
|
// return exp(-mu * depth);
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Same as compute_attenuation but since both point are known, set a maximum to make sure we don't exceed the length
|
// Same as compute_attenuation but since both point are known, set a maximum to make sure we don't exceed the length
|
||||||
// from the default point.
|
// from the default point.
|
||||||
|
Loading…
Reference in New Issue
Block a user