Lights: Option to use old point light falloff #117832

Merged
Brecht Van Lommel merged 14 commits from brecht/blender:point-sphere-light into blender-v4.1-release 2024-02-07 19:07:23 +01:00
2 changed files with 14 additions and 10 deletions
Showing only changes of commit 420ab97c1d - Show all commits

View File

@ -55,7 +55,7 @@ ccl_device_inline bool point_light_sample(const ccl_global KernelLight *klight,
ls->P = ls->Ng * klight->spot.radius + klight->co;
}
else {
/* Point light with ad-hoc radius based on orienteded disk. */
/* Point light with ad-hoc radius based on oriented disk. */
ls->P = klight->co;
if (r_sq > 0.0f) {
ls->P += disk_light_sample(lightN, rand) * klight->spot.radius;
@ -67,6 +67,8 @@ ccl_device_inline bool point_light_sample(const ccl_global KernelLight *klight,
/* PDF. */
const float invarea = (r_sq > 0.0f) ? 1.0f / (r_sq * M_PI_F) : 1.0f;
ls->pdf = invarea * light_pdf_area_to_solid_angle(lightN, -ls->D, ls->t);
/* TODO: texture coordinates. */
}
/* Texture coordinates. */
@ -79,7 +81,7 @@ ccl_device_inline bool point_light_sample(const ccl_global KernelLight *klight,
return true;
}
ccl_device_forceinline float point_light_pdf(
ccl_device_forceinline float sphere_light_pdf(
const float d_sq, const float r_sq, const float3 N, const float3 D, const uint32_t path_flag)
{
if (d_sq > r_sq) {
@ -106,9 +108,9 @@ ccl_device_forceinline void point_light_mnee_sample_update(const ccl_global Kern
const float t_sq = sqr(ls->t);
/* NOTE : preserve pdf in area measure. */
const float pdf_solid_angle_to_area = 0.5f * fabsf(d_sq - r_sq - t_sq) /
(radius * ls->t * t_sq);
ls->pdf = point_light_pdf(d_sq, r_sq, N, ls->D, path_flag) * pdf_solid_angle_to_area;
const float jacobian_solid_angle_to_area = 0.5f * fabsf(d_sq - r_sq - t_sq) /
(radius * ls->t * t_sq);
ls->pdf = sphere_light_pdf(d_sq, r_sq, N, ls->D, path_flag) * jacobian_solid_angle_to_area;
ls->Ng = normalize(ls->P - klight->co);
}
@ -161,7 +163,7 @@ ccl_device_inline bool point_light_sample_from_intersection(
if (klight->spot.is_sphere) {
const float d_sq = len_squared(ray_P - klight->co);
ls->pdf = point_light_pdf(d_sq, r_sq, N, ray_D, path_flag);
ls->pdf = sphere_light_pdf(d_sq, r_sq, N, ray_D, path_flag);
ls->Ng = normalize(ls->P - klight->co);
}
else {
@ -174,6 +176,8 @@ ccl_device_inline bool point_light_sample_from_intersection(
ls->pdf = 0.0f;
}
ls->Ng = -ray_D;
// TODO: texture coordinates.
}
/* Texture coordinates. */

View File

@ -118,7 +118,7 @@ ccl_device_inline bool spot_light_sample(const ccl_global KernelLight *klight,
spot_light_uv(local_ray, klight->spot.half_cot_half_spot_angle, &ls->u, &ls->v);
}
else {
/* Point light with ad-hoc radius based on orienteded disk. */
/* Point light with ad-hoc radius based on oriented disk. */
ls->P = klight->co;
if (r_sq > 0.0f) {
ls->P += disk_light_sample(lightN, rand) * klight->spot.radius;
@ -179,10 +179,10 @@ ccl_device_forceinline void spot_light_mnee_sample_update(const ccl_global Kerne
const float t_sq = sqr(ls->t);
/* NOTE : preserve pdf in area measure. */
const float pdf_solid_angle_to_area = 0.5f * fabsf(d_sq - r_sq - t_sq) /
(radius * ls->t * t_sq);
const float jacobian_solid_angle_to_area = 0.5f * fabsf(d_sq - r_sq - t_sq) /
(radius * ls->t * t_sq);
ls->pdf = spot_light_pdf(klight->spot.cos_half_spot_angle, d_sq, r_sq, N, ls->D, path_flag) *
pdf_solid_angle_to_area;
jacobian_solid_angle_to_area;
ls->Ng = normalize(ls->P - klight->co);