add fog_curve parameter & update shaders
This commit is contained in:
@@ -16,5 +16,6 @@
|
||||
},
|
||||
"fog_opacity": 0.8,
|
||||
"fog_dencity": 2.0,
|
||||
"fog_curve": 0.5,
|
||||
"clouds": 0.5
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
in vec4 a_color;
|
||||
in vec2 a_texCoord;
|
||||
in float a_distance;
|
||||
in vec3 a_dir;
|
||||
in float a_fog;
|
||||
out vec4 f_color;
|
||||
|
||||
uniform sampler2D u_texture0;
|
||||
@@ -14,12 +14,10 @@ uniform bool u_alphaClip;
|
||||
void main() {
|
||||
vec3 fogColor = texture(u_cubemap, a_dir).rgb;
|
||||
vec4 tex_color = texture(u_texture0, a_texCoord);
|
||||
float depth = (a_distance/256.0);
|
||||
float alpha = a_color.a * tex_color.a;
|
||||
// anyway it's any alpha-test alternative required
|
||||
if (alpha < (u_alphaClip ? 0.5f : 0.15f))
|
||||
discard;
|
||||
f_color = mix(a_color * tex_color, vec4(fogColor,1.0),
|
||||
min(1.0, pow(depth*u_fogFactor, u_fogCurve)));
|
||||
f_color = mix(a_color * tex_color, vec4(fogColor,1.0), a_fog);
|
||||
f_color.a = alpha;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
in vec4 a_color;
|
||||
in vec2 a_texCoord;
|
||||
in float a_distance;
|
||||
in float a_fog;
|
||||
in vec3 a_dir;
|
||||
out vec4 f_color;
|
||||
|
||||
uniform sampler2D u_texture0;
|
||||
uniform samplerCube u_cubemap;
|
||||
uniform vec3 u_fogColor;
|
||||
uniform bool u_alphaClip;
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -19,6 +19,8 @@ uniform float u_fogFactor;
|
||||
uniform float u_fogCurve;
|
||||
uniform float u_weatherFogOpacity;
|
||||
uniform float u_weatherFogDencity;
|
||||
uniform float u_weatherFogCurve;
|
||||
uniform float u_timer;
|
||||
uniform samplerCube u_cubemap;
|
||||
|
||||
uniform vec3 u_torchlightColor;
|
||||
@@ -44,6 +46,6 @@ void main() {
|
||||
a_distance = length(u_view * u_model * vec4(pos3d * FOG_POS_SCALE, 0.0));
|
||||
float depth = (a_distance / 256.0);
|
||||
a_fog = min(1.0, max(pow(depth * u_fogFactor, u_fogCurve),
|
||||
min(depth * u_weatherFogDencity, u_weatherFogOpacity)));
|
||||
min(pow(depth * u_weatherFogDencity, u_weatherFogCurve), u_weatherFogOpacity)));
|
||||
gl_Position = u_proj * u_view * modelpos;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user