EEVEE: Change sun light factor to match Cycles #109831

Merged
Weizhen Huang merged 1 commits from weizhen/blender:sun-light-factor into main 2023-07-07 19:51:39 +02:00
2 changed files with 6 additions and 18 deletions
Showing only changes of commit b6496e378d - Show all commits

View File

@ -90,14 +90,9 @@ static float light_shape_radiance_get(const Light *la, const EEVEE_Light *evli)
}
default:
case LA_SUN: {
/* Disk area. */
float area = (float)M_PI * square_f(evli->radius);
/* Make illumination power closer to cycles for bigger radii. Cycles uses a cos^3 term that
* we cannot reproduce so we account for that by scaling the light power. This function is
* the result of a rough manual fitting. */
float sun_scaling = 1.0f + square_f(evli->radius) / 2.0f;
/* NOTE: Missing a factor of PI here to match Cycles. */
return sun_scaling / area;
float inv_sin_sq = 1.0f + 1.0f / square_f(evli->radius);
/* Convert irradiance to radiance. */
return (float)M_1_PI * inv_sin_sq;
}
}
}
@ -131,7 +126,6 @@ static float light_volume_radiance_factor_get(const Light *la,
}
default:
case LA_SUN: {
/* NOTE: Missing a factor of PI here to match Cycles. */
/* Do nothing. */
break;
}

View File

@ -190,14 +190,9 @@ float Light::shape_radiance_get(const ::Light *la)
}
default:
case LA_SUN: {
/* Disk area. */
float area = float(M_PI) * square_f(_radius);
/* Make illumination power closer to cycles for bigger radii. Cycles uses a cos^3 term that
* we cannot reproduce so we account for that by scaling the light power. This function is
* the result of a rough manual fitting. */
float sun_scaling = 1.0f + square_f(_radius) / 2.0f;
/* NOTE: Missing a factor of PI here to match Cycles. */
return sun_scaling / area;
float inv_sin_sq = 1.0f + 1.0f / square_f(_radius);
/* Convert irradiance to radiance. */
return float(M_1_PI) * inv_sin_sq;
}
}
}
@ -223,7 +218,6 @@ float Light::point_radiance_get(const ::Light *la)
}
default:
case LA_SUN: {
/* NOTE: Missing a factor of PI here to match Cycles. */
return 1.0f;
}
}