Fix: EEVEE: Broken bias for sunlights
The pixels size was not computed in the right space. This is the easy fix as refactoring the directional shadows is too risky/time consuming right now. Fix #121641
This commit is contained in:
@@ -461,7 +461,8 @@ void ShadowDirectional::clipmap_tilemaps_distribution(Light &light, const Camera
|
||||
light.type = LIGHT_SUN;
|
||||
|
||||
/* Used for selecting the clipmap level. */
|
||||
float3 location = camera.position() * float3x3(object_mat.view<3, 3>());
|
||||
float3 location = transform_direction_transposed(light.object_to_world, camera.position());
|
||||
/* Offset for smooth level transitions. */
|
||||
light.object_to_world.x.w = location.x;
|
||||
light.object_to_world.y.w = location.y;
|
||||
light.object_to_world.z.w = location.z;
|
||||
|
||||
@@ -338,17 +338,17 @@ vec3 shadow_pcf_offset(vec3 L, vec3 Ng, vec2 random)
|
||||
*/
|
||||
float shadow_texel_radius_at_position(LightData light, const bool is_directional, vec3 P)
|
||||
{
|
||||
vec3 lP = light_world_to_local_point(light, P);
|
||||
|
||||
float scale = 1.0;
|
||||
if (is_directional) {
|
||||
vec3 lP = light_world_to_local_point(light, P);
|
||||
lP -= light_position_get(light);
|
||||
LightSunData sun = light_sun_data_get(light);
|
||||
if (light.type == LIGHT_SUN) {
|
||||
/* Simplification of `coverage_get(shadow_directional_level_fractional)`. */
|
||||
const float narrowing = float(SHADOW_TILEMAP_RES) / (float(SHADOW_TILEMAP_RES) - 1.0001);
|
||||
scale = length(lP) * narrowing;
|
||||
scale = max(scale * exp2(light.lod_bias), exp2(light.lod_min));
|
||||
scale = min(scale, float(1 << sun.clipmap_lod_max));
|
||||
scale = min(scale, exp2(float(sun.clipmap_lod_max)));
|
||||
}
|
||||
else {
|
||||
/* Uniform distribution everywhere. No distance scaling.
|
||||
@@ -358,6 +358,7 @@ float shadow_texel_radius_at_position(LightData light, const bool is_directional
|
||||
}
|
||||
}
|
||||
else {
|
||||
vec3 lP = light_world_to_local_point(light, P);
|
||||
lP -= light_local_data_get(light).shadow_position;
|
||||
/* Simplification of `exp2(shadow_punctual_level_fractional)`. */
|
||||
scale = shadow_punctual_pixel_ratio(light,
|
||||
|
||||
Reference in New Issue
Block a user