Skip to content

Commit

Permalink
Fix lightmapper penumbra computation
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometror committed Dec 30, 2024
1 parent efa1443 commit 4155a0a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions modules/lightmapper_rd/lm_compute.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,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++) {
Expand All @@ -579,7 +578,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;
Expand All @@ -588,8 +586,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);
}
Expand All @@ -600,13 +596,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++) {
Expand Down

0 comments on commit 4155a0a

Please sign in to comment.