Implement render mode fog_disabled and BaseMaterial3D setting Disable Fog

This commit is contained in:
Milan Gruner 2023-09-04 00:04:14 +02:00
parent 75de1ca768
commit 45a33cc749
10 changed files with 45 additions and 2 deletions

View file

@ -962,7 +962,9 @@ void main() {
float clearcoat_roughness = 0.0;
float anisotropy = 0.0;
vec2 anisotropy_flow = vec2(1.0, 0.0);
#ifndef FOG_DISABLED
vec4 fog = vec4(0.0);
#endif // !FOG_DISABLED
#if defined(CUSTOM_RADIANCE_USED)
vec4 custom_radiance = vec4(0.0);
#endif
@ -1075,6 +1077,7 @@ void main() {
#ifndef MODE_RENDER_DEPTH
#ifndef FOG_DISABLED
#ifndef CUSTOM_FOG_USED
#ifndef DISABLE_FOG
// fog must be processed as early as possible and then packed.
@ -1088,6 +1091,7 @@ void main() {
uint fog_rg = packHalf2x16(fog.rg);
uint fog_ba = packHalf2x16(fog.ba);
#endif // !FOG_DISABLED
// Convert colors to linear
albedo = srgb_to_linear(albedo);
@ -1300,6 +1304,8 @@ void main() {
frag_color.rgb += emission + ambient_light;
#endif
#endif //MODE_UNSHADED
#ifndef FOG_DISABLED
fog = vec4(unpackHalf2x16(fog_rg), unpackHalf2x16(fog_ba));
#ifndef DISABLE_FOG
@ -1310,7 +1316,8 @@ void main() {
frag_color.rgb *= (1.0 - fog.a);
#endif // BASE_PASS
}
#endif
#endif // !DISABLE_FOG
#endif // !FOG_DISABLED
// Tonemap before writing as we are writing to an sRGB framebuffer
frag_color.rgb *= exposure;