add fog_curve parameter & update shaders

This commit is contained in:
MihailRis
2025-02-26 04:49:45 +03:00
parent d7f20e7388
commit e6ea4fe37e
8 changed files with 29 additions and 27 deletions
+11 -2
View File
@@ -7,7 +7,7 @@ layout (location = 3) in float v_light;
out vec4 a_color;
out vec2 a_texCoord;
out float a_distance;
out float a_fog;
out vec3 a_dir;
uniform mat4 u_model;
@@ -16,6 +16,11 @@ uniform mat4 u_view;
uniform vec3 u_cameraPos;
uniform float u_gamma;
uniform float u_opacity;
uniform float u_fogFactor;
uniform float u_fogCurve;
uniform float u_weatherFogOpacity;
uniform float u_weatherFogDencity;
uniform float u_weatherFogCurve;
uniform samplerCube u_cubemap;
uniform vec3 u_torchlightColor;
@@ -38,6 +43,10 @@ void main() {
vec3 skyLightColor = pick_sky_color(u_cubemap);
a_color.rgb = max(a_color.rgb, skyLightColor.rgb*decomp_light.a) * v_color;
a_color.a = u_opacity;
a_distance = length(u_view * u_model * vec4(pos3d * FOG_POS_SCALE, 0.0));
float dist = length(u_view * u_model * vec4(pos3d * FOG_POS_SCALE, 0.0));
float depth = (dist / 256.0);
a_fog = min(1.0, max(pow(depth * u_fogFactor, u_fogCurve),
min(pow(depth * u_weatherFogDencity, u_weatherFogCurve), u_weatherFogOpacity)));
gl_Position = u_proj * u_view * modelpos;
}