mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better mist access
This commit is contained in:
parent
e5ebbd31fa
commit
e413392694
@ -44,6 +44,8 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission) {
|
|||||||
float turb_noise = 0.0;
|
float turb_noise = 0.0;
|
||||||
float sun_access = 0.0;
|
float sun_access = 0.0;
|
||||||
float moon_access = 0.0;
|
float moon_access = 0.0;
|
||||||
|
float cloud_sun_access = 0.0;
|
||||||
|
float cloud_moon_access = 0.0;
|
||||||
// This is a silly optimisation but it actually nets us a fair few fps by skipping quite a few expensive calcs
|
// This is a silly optimisation but it actually nets us a fair few fps by skipping quite a few expensive calcs
|
||||||
if (cloud_tendency > 0 || mist > 0.0) {
|
if (cloud_tendency > 0 || mist > 0.0) {
|
||||||
// Turbulence (small variations in clouds/mist)
|
// Turbulence (small variations in clouds/mist)
|
||||||
@ -66,9 +68,9 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission) {
|
|||||||
cloud = cloud_flat * pow(cloud_factor, 2) * 20;
|
cloud = cloud_flat * pow(cloud_factor, 2) * 20;
|
||||||
|
|
||||||
// What proportion of sunlight is *not* being blocked by nearby cloud? (approximation)
|
// What proportion of sunlight is *not* being blocked by nearby cloud? (approximation)
|
||||||
sun_access = clamp((pos.z - cloud_attr.x + turb_noise * 250.0) * 0.002 + 0.35 + max(mist * 20000, 0), 0, 1);
|
cloud_sun_access = clamp((pos.z - cloud_attr.x + turb_noise * 250.0) * 0.002 + 0.35, 0, 1);
|
||||||
// Since we're assuming the sun/moon is always above (not always correct) it's the same for the moon
|
// Since we're assuming the sun/moon is always above (not always correct) it's the same for the moon
|
||||||
moon_access = sun_access;
|
cloud_moon_access = sun_access;
|
||||||
|
|
||||||
#if (CLOUD_MODE >= CLOUD_MODE_HIGH)
|
#if (CLOUD_MODE >= CLOUD_MODE_HIGH)
|
||||||
// Try to calculate a reasonable approximation of the cloud normal
|
// Try to calculate a reasonable approximation of the cloud normal
|
||||||
@ -79,11 +81,16 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission) {
|
|||||||
(cloud_tendency - cloud_tendency_y) * 4,
|
(cloud_tendency - cloud_tendency_y) * 4,
|
||||||
(pos.z - cloud_attr.x) / 250 + turb_noise + 0.25
|
(pos.z - cloud_attr.x) / 250 + turb_noise + 0.25
|
||||||
);
|
);
|
||||||
sun_access = mix(max(dot(-sun_dir.xyz, cloud_norm) + 0.0, 0.025), sun_access, 0.25);
|
cloud_sun_access = mix(max(dot(-sun_dir.xyz, cloud_norm) + 0.0, 0.025), cloud_sun_access, 0.25);
|
||||||
moon_access = mix(max(dot(-moon_dir.xyz, cloud_norm) + 0.35, 0.025), moon_access, 0.25);
|
cloud_moon_access = mix(max(dot(-moon_dir.xyz, cloud_norm) + 0.35, 0.025), cloud_moon_access, 0.25);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float mist_sun_access = 0.5 + turb_noise;
|
||||||
|
float mist_moon_access = mist_sun_access;
|
||||||
|
sun_access = mix(cloud_sun_access, mist_sun_access, clamp(mist * 20000, 0, 1));
|
||||||
|
moon_access = mix(cloud_moon_access, mist_moon_access, clamp(mist * 20000, 0, 1));
|
||||||
|
|
||||||
// Prevent mist (i.e: vapour beneath clouds) being accessible to the sun to avoid visual problems
|
// Prevent mist (i.e: vapour beneath clouds) being accessible to the sun to avoid visual problems
|
||||||
//float suppress_mist = clamp((pos.z - cloud_attr.x + cloud_attr.y) / 300, 0, 1);
|
//float suppress_mist = clamp((pos.z - cloud_attr.x + cloud_attr.y) / 300, 0, 1);
|
||||||
//sun_access *= suppress_mist;
|
//sun_access *= suppress_mist;
|
||||||
|
Loading…
Reference in New Issue
Block a user