Fix incorrect MIS weights in Cycles with multiple lights.
This causes some difference in the classroom scene, where ray visibility tricks are used and break the MIS balance. Otherwise there doesn't seem to be much effect, but better to use the right formulas. Problem originally identified by Lukas.
This commit is contained in:
@@ -547,7 +547,7 @@ ccl_device_inline bool lamp_light_sample(KernelGlobals *kg,
|
||||
|
||||
float costheta = dot(lightD, D);
|
||||
ls->pdf = invarea/(costheta*costheta*costheta);
|
||||
ls->eval_fac = ls->pdf*kernel_data.integrator.inv_pdf_lights;
|
||||
ls->eval_fac = ls->pdf;
|
||||
}
|
||||
#ifdef __BACKGROUND_MIS__
|
||||
else if(type == LIGHT_BACKGROUND) {
|
||||
@@ -559,7 +559,6 @@ ccl_device_inline bool lamp_light_sample(KernelGlobals *kg,
|
||||
ls->D = -D;
|
||||
ls->t = FLT_MAX;
|
||||
ls->eval_fac = 1.0f;
|
||||
ls->pdf *= kernel_data.integrator.pdf_lights;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
@@ -622,10 +621,10 @@ ccl_device_inline bool lamp_light_sample(KernelGlobals *kg,
|
||||
float invarea = data2.x;
|
||||
ls->eval_fac = 0.25f*invarea;
|
||||
}
|
||||
|
||||
ls->eval_fac *= kernel_data.integrator.inv_pdf_lights;
|
||||
}
|
||||
|
||||
ls->pdf *= kernel_data.integrator.pdf_lights;
|
||||
|
||||
return (ls->pdf > 0.0f);
|
||||
}
|
||||
|
||||
@@ -757,8 +756,11 @@ ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D,
|
||||
ls->pdf = area_light_sample(P, &light_P, axisu, axisv, 0, 0, false);
|
||||
ls->eval_fac = 0.25f*invarea;
|
||||
}
|
||||
else
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
ls->pdf *= kernel_data.integrator.pdf_lights;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1239,8 +1239,8 @@ typedef struct KernelIntegrator {
|
||||
int num_all_lights;
|
||||
float pdf_triangles;
|
||||
float pdf_lights;
|
||||
float inv_pdf_lights;
|
||||
int pdf_background_res;
|
||||
float light_inv_rr_threshold;
|
||||
|
||||
/* light portals */
|
||||
float portal_pdf;
|
||||
@@ -1298,9 +1298,8 @@ typedef struct KernelIntegrator {
|
||||
float volume_step_size;
|
||||
int volume_samples;
|
||||
|
||||
float light_inv_rr_threshold;
|
||||
|
||||
int start_sample;
|
||||
int pad;
|
||||
} KernelIntegrator;
|
||||
static_assert_align(KernelIntegrator, 16);
|
||||
|
||||
|
Reference in New Issue
Block a user