Division by zero when there are no lights and only emissive surfaces
When rendering the test scene in T79190 which has only emissive surfaces a division by zero occurs. This is a simple patch to remove this. Reviewed By: brecht Maniphest Tasks: T79190 Differential Revision: https://developer.blender.org/D11682
This commit is contained in:
parent
e2bbb5b07e
commit
5eed7cdc8c
Notes:
blender-bot
2023-02-13 21:42:54 +01:00
Referenced by issue #79190, Cycles PMJ adaptive sampling working poorly with many bounces
|
@ -410,38 +410,39 @@ void LightManager::device_update_distribution(Device *,
|
|||
}
|
||||
|
||||
float trianglearea = totarea;
|
||||
|
||||
/* point lights */
|
||||
float lightarea = (totarea > 0.0f) ? totarea / num_lights : 1.0f;
|
||||
bool use_lamp_mis = false;
|
||||
|
||||
int light_index = 0;
|
||||
foreach (Light *light, scene->lights) {
|
||||
if (!light->is_enabled)
|
||||
continue;
|
||||
|
||||
if (num_lights > 0) {
|
||||
float lightarea = (totarea > 0.0f) ? totarea / num_lights : 1.0f;
|
||||
foreach (Light *light, scene->lights) {
|
||||
if (!light->is_enabled)
|
||||
continue;
|
||||
|
||||
distribution[offset].totarea = totarea;
|
||||
distribution[offset].prim = ~light_index;
|
||||
distribution[offset].lamp.pad = 1.0f;
|
||||
distribution[offset].lamp.size = light->size;
|
||||
totarea += lightarea;
|
||||
distribution[offset].totarea = totarea;
|
||||
distribution[offset].prim = ~light_index;
|
||||
distribution[offset].lamp.pad = 1.0f;
|
||||
distribution[offset].lamp.size = light->size;
|
||||
totarea += lightarea;
|
||||
|
||||
if (light->light_type == LIGHT_DISTANT) {
|
||||
use_lamp_mis |= (light->angle > 0.0f && light->use_mis);
|
||||
}
|
||||
else if (light->light_type == LIGHT_POINT || light->light_type == LIGHT_SPOT) {
|
||||
use_lamp_mis |= (light->size > 0.0f && light->use_mis);
|
||||
}
|
||||
else if (light->light_type == LIGHT_AREA) {
|
||||
use_lamp_mis |= light->use_mis;
|
||||
}
|
||||
else if (light->light_type == LIGHT_BACKGROUND) {
|
||||
num_background_lights++;
|
||||
background_mis |= light->use_mis;
|
||||
}
|
||||
if (light->light_type == LIGHT_DISTANT) {
|
||||
use_lamp_mis |= (light->angle > 0.0f && light->use_mis);
|
||||
}
|
||||
else if (light->light_type == LIGHT_POINT || light->light_type == LIGHT_SPOT) {
|
||||
use_lamp_mis |= (light->size > 0.0f && light->use_mis);
|
||||
}
|
||||
else if (light->light_type == LIGHT_AREA) {
|
||||
use_lamp_mis |= light->use_mis;
|
||||
}
|
||||
else if (light->light_type == LIGHT_BACKGROUND) {
|
||||
num_background_lights++;
|
||||
background_mis |= light->use_mis;
|
||||
}
|
||||
|
||||
light_index++;
|
||||
offset++;
|
||||
light_index++;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
/* normalize cumulative distribution functions */
|
||||
|
|
Loading…
Reference in New Issue