mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
improve bad weather clouds, fix clouds fog distance calculation
This commit is contained in:
parent
95b4ba3b4b
commit
8ad05049bb
@ -187,10 +187,13 @@ class CloudsRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateRainColor(time: WorldTime, rain: Float): Vec3 {
|
||||
private fun calculateRainColor(time: WorldTime, rain: Float, thunder: Float): Vec3 {
|
||||
val normal = calculateNormal(time)
|
||||
val brightness = normal.length()
|
||||
return interpolateLinear(rain, normal, RAIN_COLOR) * brightness
|
||||
var color = RAIN_COLOR
|
||||
color = color * maxOf(1.0f - thunder, 0.4f)
|
||||
|
||||
return interpolateLinear(maxOf(rain, thunder), normal, color) * brightness * 0.8f
|
||||
}
|
||||
|
||||
private fun calculateCloudsColor(): Vec3 {
|
||||
@ -200,7 +203,7 @@ class CloudsRenderer(
|
||||
}
|
||||
val time = sky.time
|
||||
if (weather.rain > 0.0f || weather.thunder > 0.0f) {
|
||||
return calculateRainColor(time, maxOf(weather.rain, weather.thunder))
|
||||
return calculateRainColor(time, weather.rain, weather.thunder)
|
||||
}
|
||||
return calculateNormal(time)
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ uniform float uFogDistance = 15.0f * 15.0f;
|
||||
uniform vec4 uFogColor;
|
||||
uniform bool uUseFogColor = false;
|
||||
|
||||
#ifndef DISTANCE_MULTIPLIER
|
||||
#define DISTANCE_MULTIPLIER 1.0f
|
||||
#endif
|
||||
|
||||
float calulate_fog_alpha(float distance2) {
|
||||
if (distance2 < uFogStart) {
|
||||
return 1.0f;
|
||||
@ -43,7 +47,7 @@ float calculate_fog() {
|
||||
vec2 distance_vec2 = finFragmentPosition.xz - uCameraPosition.xz;
|
||||
float distance = dot(distance_vec2, distance_vec2);
|
||||
#endif
|
||||
return calulate_fog_alpha(distance);
|
||||
return calulate_fog_alpha(distance * DISTANCE_MULTIPLIER);
|
||||
}
|
||||
|
||||
void set_fog() {
|
||||
|
@ -20,6 +20,7 @@ uniform vec4 uCloudsColor;
|
||||
flat in float finBrightness;
|
||||
|
||||
|
||||
#define DISTANCE_MULTIPLIER 0.3f
|
||||
#include "minosoft:fog"
|
||||
|
||||
void main() {
|
||||
|
@ -33,7 +33,7 @@ void main() {
|
||||
|
||||
gl_Position = uViewProjectionMatrix * vec4(position, 1.0);
|
||||
|
||||
finFragmentPosition = position / 3;
|
||||
finFragmentPosition = position;
|
||||
|
||||
switch (vinSide) {
|
||||
case 0u: finBrightness = 0.7f; break; // DOWN
|
||||
|
Loading…
x
Reference in New Issue
Block a user