You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #111998 from shakesoda/fog-blend
Revise fog blending to fix over-darkening/borders.
This commit is contained in:
@@ -281,7 +281,7 @@ void main() {
|
|||||||
|
|
||||||
if (sky_scene_data.volumetric_fog_enabled) {
|
if (sky_scene_data.volumetric_fog_enabled) {
|
||||||
vec4 fog = volumetric_fog_process(uv);
|
vec4 fog = volumetric_fog_process(uv);
|
||||||
frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a * sky_scene_data.volumetric_fog_sky_affect);
|
frag_color.rgb = frag_color.rgb * (1.0 - fog.a * sky_scene_data.volumetric_fog_sky_affect) + fog.rgb * sky_scene_data.volumetric_fog_sky_affect;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (custom_fog.a > 0.0) {
|
if (custom_fog.a > 0.0) {
|
||||||
|
|||||||
@@ -1443,20 +1443,21 @@ void fragment_shader(in SceneData scene_data) {
|
|||||||
#else
|
#else
|
||||||
vec4 volumetric_fog = volumetric_fog_process(screen_uv, -vertex.z);
|
vec4 volumetric_fog = volumetric_fog_process(screen_uv, -vertex.z);
|
||||||
#endif
|
#endif
|
||||||
|
vec4 res = vec4(0.0);
|
||||||
if (bool(scene_data.flags & SCENE_DATA_FLAGS_USE_FOG)) {
|
if (bool(scene_data.flags & SCENE_DATA_FLAGS_USE_FOG)) {
|
||||||
//must use the full blending equation here to blend fogs
|
//must use the full blending equation here to blend fogs
|
||||||
vec4 res;
|
|
||||||
float sa = 1.0 - volumetric_fog.a;
|
float sa = 1.0 - volumetric_fog.a;
|
||||||
res.a = fog.a * sa + volumetric_fog.a;
|
res.a = fog.a * sa + volumetric_fog.a;
|
||||||
if (res.a == 0.0) {
|
if (res.a > 0.0) {
|
||||||
res.rgb = vec3(0.0);
|
res.rgb = (fog.rgb * fog.a * sa + volumetric_fog.rgb) / res.a;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res.rgb = (fog.rgb * fog.a * sa + volumetric_fog.rgb * volumetric_fog.a) / res.a;
|
res.a = volumetric_fog.a;
|
||||||
|
if (res.a > 0.0) {
|
||||||
|
res.rgb = volumetric_fog.rgb / res.a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fog = res;
|
fog = res;
|
||||||
} else {
|
|
||||||
fog = volumetric_fog;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif //!CUSTOM_FOG_USED
|
#endif //!CUSTOM_FOG_USED
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user