Cycles/EEVEE: change point light to double-sided sphere light #108506

Merged
Weizhen Huang merged 18 commits from weizhen/blender:point_light_to_sphere_light into main 2023-06-20 12:23:12 +02:00
Showing only changes of commit 19bf32dcc6 - Show all commits

View File

@ -56,9 +56,11 @@ ccl_device_inline bool point_light_sample(const ccl_global KernelLight *klight,
ls->P = ls->Ng * klight->spot.radius + klight->co; ls->P = ls->Ng * klight->spot.radius + klight->co;
} }
const float2 uv = map_to_sphere(ls->Ng); const Transform itfm = klight->itfm;
ls->u = uv.x; const float2 uv = map_to_sphere(transform_direction(&itfm, ls->Ng));
ls->v = uv.y; /* NOTE: Return barycentric coordinates in the same notation as Embree and OptiX. */
ls->u = uv.y;
ls->v = 1.0f - uv.x - uv.y;
return true; return true;
} }
@ -104,9 +106,11 @@ ccl_device_forceinline void point_light_mnee_sample_update(const ccl_global Kern
/* PDF does not change. */ /* PDF does not change. */
} }
const float2 uv = map_to_sphere(ls->Ng); const Transform itfm = klight->itfm;
ls->u = uv.x; const float2 uv = map_to_sphere(transform_direction(&itfm, ls->Ng));
ls->v = uv.y; /* NOTE: Return barycentric coordinates in the same notation as Embree and OptiX. */
ls->u = uv.y;
ls->v = 1.0f - uv.x - uv.y;
} }
ccl_device_inline bool point_light_intersect(const ccl_global KernelLight *klight, ccl_device_inline bool point_light_intersect(const ccl_global KernelLight *klight,
@ -137,9 +141,11 @@ ccl_device_inline bool point_light_sample_from_intersection(
ls->Ng = radius > 0 ? normalize(ls->P - klight->co) : -ray_D; ls->Ng = radius > 0 ? normalize(ls->P - klight->co) : -ray_D;
const float2 uv = map_to_sphere(ls->Ng); const Transform itfm = klight->itfm;
ls->u = uv.x; const float2 uv = map_to_sphere(transform_direction(&itfm, ls->Ng));
ls->v = uv.y; /* NOTE: Return barycentric coordinates in the same notation as Embree and OptiX. */
ls->u = uv.y;
ls->v = 1.0f - uv.x - uv.y;
if (ls->t == FLT_MAX) { if (ls->t == FLT_MAX) {
ls->pdf = 0.0f; ls->pdf = 0.0f;