mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
fix
This commit is contained in:
parent
a6c4e9e22e
commit
86096553ce
3 changed files with 15 additions and 4 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
#include <shadows>
|
#include <shadows>
|
||||||
#include <fog>
|
#include <fog>
|
||||||
|
|
||||||
|
#define CLOUDS_FOG_FACTOR_MUL 0.3f
|
||||||
|
#define CLOUDS_FOG_CURVE_MUL 0.4f
|
||||||
|
|
||||||
vec4 effect() {
|
vec4 effect() {
|
||||||
vec4 pos = texture(u_position, v_uv);
|
vec4 pos = texture(u_position, v_uv);
|
||||||
float light = 1.0;
|
float light = 1.0;
|
||||||
|
|
@ -32,6 +35,10 @@ vec4 effect() {
|
||||||
light = pow(light, u_gamma);
|
light = pow(light, u_gamma);
|
||||||
|
|
||||||
vec3 fogColor = texture(u_skybox, dir).rgb;
|
vec3 fogColor = texture(u_skybox, dir).rgb;
|
||||||
float fog = calc_fog(pow(length(u_view * vec4((modelpos.xyz - u_cameraPos) * FOG_POS_SCALE, 0.0)) / 256.0, (1.0f - emission * 0.7)));
|
float fog = calc_fog(
|
||||||
|
length(u_view * vec4((modelpos.xyz - u_cameraPos) * FOG_POS_SCALE, 0.0)) / 256.0,
|
||||||
|
mix(1.0, CLOUDS_FOG_FACTOR_MUL, emission),
|
||||||
|
mix(1.0, CLOUDS_FOG_CURVE_MUL, emission)
|
||||||
|
);
|
||||||
return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0), fogColor, fog), 1.0);
|
return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0), fogColor, fog), 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,17 @@ uniform float u_weatherFogOpacity;
|
||||||
uniform float u_weatherFogDencity;
|
uniform float u_weatherFogDencity;
|
||||||
uniform float u_weatherFogCurve;
|
uniform float u_weatherFogCurve;
|
||||||
|
|
||||||
float calc_fog(float depth) {
|
float calc_fog(float depth, float fogFactor, float fogCurve) {
|
||||||
return min(
|
return min(
|
||||||
1.0,
|
1.0,
|
||||||
max(pow(depth * u_fogFactor, u_fogCurve),
|
max(pow(depth * u_fogFactor * fogFactor, u_fogCurve * fogCurve),
|
||||||
min(pow(depth * u_weatherFogDencity, u_weatherFogCurve),
|
min(pow(depth * u_weatherFogDencity, u_weatherFogCurve),
|
||||||
u_weatherFogOpacity))
|
u_weatherFogOpacity))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float calc_fog(float depth) {
|
||||||
|
return calc_fog(depth, 1.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // FOG_GLSL_
|
#endif // FOG_GLSL_
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ void CloudsRenderer::draw(
|
||||||
|
|
||||||
shader.uniform4f("u_tint", glm::vec4(weather.cloudsTint(), 1.0f));
|
shader.uniform4f("u_tint", glm::vec4(weather.cloudsTint(), 1.0f));
|
||||||
shader.uniform1f("u_fogFactor", fogFactor * 0.03f);
|
shader.uniform1f("u_fogFactor", fogFactor * 0.03f);
|
||||||
shader.uniform1f("u_fogCurve", 0.7f - 0.3f);
|
shader.uniform1f("u_fogCurve", 0.4f);
|
||||||
|
|
||||||
for (int i = 0; i < std::min<int>(quality, layers.size()); i++) {
|
for (int i = 0; i < std::min<int>(quality, layers.size()); i++) {
|
||||||
draw(layers[i], frustum, shader, camera, timer, i);
|
draw(layers[i], frustum, shader, camera, timer, i);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue