Cleanup: avoid division in #spot_light_attenuation

This commit is contained in:
Weizhen Huang 2023-06-22 17:19:01 +02:00
parent 9e8bc1d579
commit 9aaf28954b
2 changed files with 2 additions and 2 deletions

@ -14,7 +14,7 @@ ccl_device float spot_light_attenuation(const ccl_global KernelSpotLight *spot,
make_float3(dot(ray, spot->axis_u), dot(ray, spot->axis_v), dot(ray, spot->dir)) /
spot->len);
return smoothstepf((scaled_ray.z - spot->cos_half_spot_angle) / spot->spot_smooth);
return smoothstepf((scaled_ray.z - spot->cos_half_spot_angle) * spot->spot_smooth);
}
template<bool in_volume_segment>

@ -1322,7 +1322,7 @@ void LightManager::device_update_lights(Device *device, DeviceScene *dscene, Sce
float invarea = (light->normalize && radius > 0.0f) ? 1.0f / (M_PI_F * radius * radius) :
1.0f;
float cos_half_spot_angle = cosf(light->spot_angle * 0.5f);
float spot_smooth = (1.0f - cos_half_spot_angle) * light->spot_smooth;
float spot_smooth = 1.0f / ((1.0f - cos_half_spot_angle) * light->spot_smooth);
if (light->use_mis && radius > 0.0f)
shader_id |= SHADER_USE_MIS;