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
2 changed files with 4 additions and 2 deletions
Showing only changes of commit abcacaa58e - Show all commits

View File

@ -47,7 +47,6 @@ ccl_device_inline bool point_light_sample(const ccl_global KernelLight *klight,
ls->P = P + ls->D * ls->t;
/* TODO: change invarea to that of a sphere. */
ls->eval_fac = M_1_PI_F * 0.25f * klight->spot.invarea;
if (r_sqr == 0) {
/* Use intensity instead of radiance for point light. */
@ -129,7 +128,7 @@ ccl_device_inline bool point_light_sample_from_intersection(
/* We set the light normal to the outgoing direction to support texturing. */
ls->Ng = -ls->D;
ls->eval_fac = (0.25f * M_1_PI_F) * klight->spot.invarea;
ls->eval_fac = M_1_PI_F * 0.25f * klight->spot.invarea;
const float2 uv = map_to_sphere(ls->Ng);
ls->u = uv.x;

View File

@ -1213,6 +1213,9 @@ void LightManager::device_update_lights(Device *device, DeviceScene *dscene, Sce
shader_id &= ~SHADER_AREA_LIGHT;
float radius = light->size;
/* TODO: change `invarea` to that of a sphere. `invarea` was used for disk sampling, with the
* current solid angle sampling this does not seem necessary. Maybe store `eval_fac`
* directly? */
float invarea = (light->normalize && radius > 0.0f) ? 1.0f / (M_PI_F * radius * radius) :
1.0f;