Repository: godotengine/godot (language: cpp)

Issue:
Regression: LightmapGI OmniLight3D light_size no longer emits outside of radius.
### Tested versions

- Reproducible in: 4.4.dev (https://github.com/godotengine/godot/commit/2fcd8223e8840d9e6151b9981b11f982cb3b568d)
- Not reproducible in: 4.4.dev7.

### System information

Godot v4.4.dev (efa144396) - Nobara Linux 40 (KDE Plasma) on X11 - X11 display driver, Single-window, 2 monitors - Vulkan (Forward+) - dedicated AMD Radeon RX 6600 XT (RADV NAVI23) - AMD Ryzen 7 3700X 8-Core Processor (16 threads)

### Issue description

In my project I place static OmniLight3Ds in light bulb meshes, combined with glowing materials it can look very nice.

The lights in my scene have a size of 0.55m and the bulb's radius is 0.49m
4.4.dev7:
![Image](https://github.com/user-attachments/assets/dbade421-3d85-478a-9fe7-3090f9c78d63)

Master:
![Image](https://github.com/user-attachments/assets/f92dab80-1f45-4989-ac01-f82494e6ed14)

### Steps to reproduce

1 - Create a MeshInstance3D and give it a SphereMesh with UV2 and static baking enabled.
2 - Add an OmniLight3D with Static bake_mode.
3 - Position the light inside the mesh.
4 - Increase the light's size to be larger than the mesh
5 - Add a LightmapGI node and bake the scene.

### Minimal reproduction project (MRP)

[lightregression_mrp.zip](https://github.com/user-attachments/files/18270418/lightregression_mrp.zip)

Open node_3d.tscn, select the LightmapGI node and click bake.

The 0.0m size light behaves as expected, where the mesh fully blocks it, but the 0.6m size light is expected to emit outside of the mesh like a light bulb

4.4.dev7:
![Image](https://github.com/user-attachments/assets/6362a825-4671-400d-9331-f4993147abbf)

Master:
![Image](https://github.com/user-attachments/assets/38249007-81f8-4eb0-941c-51cea25e93fb)


Discussion / hints:
Bisected to #99538, @Geometror

![Image](https://github.com/user-attachments/assets/020f1a21-a987-4a16-af93-7f164d462eec)

<br>

Also, the editor prints a "little" spam of this message while baking: `No material for mesh with vertex count  12672`

![Image](https://github.com/user-attachments/assets/e2bd84b4-6770-4f15-956b-b6d46cbb02df)

For the output spam I've already opened a PR: https://github.com/godotengine/godot/pull/100774
The main issue though is strange, I'll investigate.

Fix patch:
diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl
index cb9350c1de92..4614e0feb5db 100644
--- a/modules/lightmapper_rd/lm_compute.glsl
+++ b/modules/lightmapper_rd/lm_compute.glsl
@@ -492,7 +492,6 @@ void trace_direct_light(vec3 p_position, vec3 p_normal, uint p_light_index, bool
 		vec3 light_to_point_tan = normalize(cross(light_to_point, light_aux));
 		vec3 light_to_point_bitan = normalize(cross(light_to_point, light_to_point_tan));
 
-		uint hits = 0;
 		float aa_power = 0.0;
 		for (uint i = 0; i < ray_count; i++) {
 			// Create a random sample within the texel.
@@ -566,8 +565,7 @@ void trace_direct_light(vec3 p_position, vec3 p_normal, uint p_light_index, bool
 					power_accm++;
 				}
 
-				hits += soft_shadow_hits;
-			} else { // No soft shadows.
+			} else { // No soft shadows (size == 0).
 				float sample_penumbra = 0.0;
 				bool sample_did_hit = false;
 				for (uint iter = 0; iter < bake_params.transparency_rays; iter++) {
@@ -579,7 +577,6 @@ void trace_direct_light(vec3 p_position, vec3 p_normal, uint p_light_index, bool
 						if (!sample_did_hit) {
 							sample_penumbra = 1.0;
 						}
-						hits++;
 						break;
 					} else if (ret == RAY_FRONT || ret == RAY_BACK) {
 						bool contribute = ret == RAY_FRONT || !sample_did_hit;
@@ -588,8 +585,6 @@ void trace_direct_light(vec3 p_position, vec3 p_normal, uint p_light_index, bool
 							sample_did_hit = true;
 						}
 
-						hits++;
-
 						if (contribute) {
 							sample_penumbra = max(sample_penumbra - hit_albedo.a - EPSILON, 0.0);
 						}
@@ -600,13 +595,13 @@ void trace_direct_light(vec3 p_position, vec3 p_normal, uint p_light_index, bool
 						}
 					}
 				}
-				power += sample_penumbra;
+				power = sample_penumbra;
 				power_accm = 1;
 			}
-			aa_power = power / float(power_accm);
+			aa_power += power / float(power_accm);
 		}
-		penumbra = aa_power;
-	} else { // No soft shadows.
+		penumbra = aa_power / ray_count;
+	} else { // No soft shadows and anti-aliasing (disabled via parameter).
 		bool did_hit = false;
 		penumbra = 0.0;
 		for (uint iter = 0; iter < bake_params.transparency_rays; iter++) {


Test patch: