USD: improve light units conversion #109795

Manually merged
Brecht Van Lommel merged 4 commits from brecht/blender:usd-light-units into main 2023-07-07 18:27:19 +02:00
1 changed files with 10 additions and 2 deletions
Showing only changes of commit 053fd7850f - Show all commits

View File

@ -1152,9 +1152,13 @@ void LightManager::device_update_lights(Device *device, DeviceScene *dscene, Sce
float3 axis_v = normalize_len(extentv, &len_v);
float area = len_u * len_v;
if (light->ellipse) {
area *= -M_PI_4_F;
area *= M_PI_4_F;
}
float invarea = (area != 0.0f) ? 1.0f / area : 1.0f;
if (light->ellipse) {
/* Negative inverse area indicates ellipse. */
invarea = -invarea;
}
float3 dir = light->dir;
dir = safe_normalize(dir);
@ -1278,9 +1282,13 @@ void LightManager::device_update_lights(Device *device, DeviceScene *dscene, Sce
float3 axis_v = normalize_len(extentv, &len_v);
float area = len_u * len_v;
if (light->ellipse) {
area *= -M_PI_4_F;
area *= M_PI_4_F;
}
float invarea = (light->normalize && area != 0.0f) ? 1.0f / area : 1.0f;
if (light->ellipse) {
/* Negative inverse area indicates ellipse. */
invarea = -invarea;
}
float3 dir = light->dir;
const float half_spread = 0.5f * light->spread;