Repository: godot
Issue: Shader compilation error occurs when writing to `FOG` in a custom shader that uses `render_mode fog_disabled`
Labels: bug,topic:rendering,topic:3d

### Tested versions

- Reproducible in: 4.2.stable, 4.2.2.stable, 4.3.beta da4f6e439

### System information

Godot v4.3.beta (da4f6e439) - Fedora Linux 40 (KDE Plasma) - X11 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4090 (nvidia; 555.58.02) - 13th Gen Intel(R) Core(TM) i9-13900K (32 Threads)

### Issue description

A shader compilation error occurs when writing to `FOG` in a custom shader that uses `render_mode fog_disabled`. This can be reproduced with all rendering methods.

I suggest ignoring the writes to `FOG` in this case (likely better for shaders that can have their render mode adjusting for a script). We could also forbid writing to `FOG` with an error message with this case, but it may be more intrusive.

### Forward+

```
   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:297)
ERROR: Error compiling Fragment shader, variant #9 ().
   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:293)
ERROR: Failed parse:
WARNING: 0:74: '' : all default precisions are highp; use precision statements to quiet warning, e.g.:
         "precision mediump int; precision highp float;" 
ERROR: 0:2242: 'fog' : undeclared identifier 
ERROR: 0:2242: 'a' : vector swizzle selection out of range 
ERROR: 0:2242: '' : compilation terminated 
ERROR: 3 compilation errors.  No code generated.

   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:294)
ERROR: code:

[... Shader code printed here ...]

   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:297)
ERROR: Parameter "p_version->variants" is null.
   at: _allocate_placeholders (servers/rendering/renderer_rd/shader_rd.cpp:487)
ERROR: Parameter "p_version->variants" is null.
   at: _allocate_placeholders (servers/rendering/renderer_rd/shader_rd.cpp:487)
ERROR: Parameter "p_version->variants" is null.
   at: _allocate_placeholders (servers/rendering/renderer_rd/shader_rd.cpp:487)
ERROR: Condition "!shader_singleton->shader.version_is_valid(version)" is true.
   at: set_code (servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp:182)
```

### Mobile

```
ERROR: Error compiling Fragment shader, variant #0 ().
   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:293)
ERROR: Failed parse:
WARNING: 0:69: '' : all default precisions are highp; use precision statements to quiet warning, e.g.:
         "precision mediump int; precision highp float;" 
ERROR: 0:1788: 'fog' : undeclared identifier 
ERROR: 0:1788: 'a' : vector swizzle selection out of range 
ERROR: 0:1788: '' : compilation terminated 
ERROR: 3 compilation errors.  No code generated.

   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:294)

[... Shader code printed here ...]

   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:297)
ERROR: Condition "!shader_singleton->shader.version_is_valid(version)" is true.
   at: set_code (servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp:193)
```

### Compatibility

```
WARNING: shader failed to compile, unable to bind shader.
     at: _version_bind_shader (./drivers/gles3/shader_gles3.h:222)

[... Shader code printed here ...]

ERROR: SceneShaderGLES3: Fragment shader compilation failed:
0(1198) : error C1503: undefined variable "fog"
0(1199) : error C1503: undefined variable "fog"

   at: _display_error_with_code (drivers/gles3/shader_gles3.cpp:254)
ERROR: Method/function failed.
   at: _compile_specialization (drivers/gles3/shader_gles3.cpp:396)
```

### Steps to reproduce

- Write to `FOG` in a custom shader that has `render_mode fog_disabled;` at its top.

### Minimal reproduction project (MRP)

[Fog.Shader.Compatibility.Issue.MRP2.zip](https://github.com/user-attachments/files/16322950/Fog.Shader.Compatibility.Issue.MRP2.zip)

One of the boxes in the MRP uses a built-in shader with `render_mode fog_disabled;`.