Fix Cycles uninitialized variables in mesh light sampling
Causing wrong renders and differences between platforms.
This commit is contained in:
parent
1af8ddf69f
commit
5270610b29
|
@ -361,6 +361,8 @@ ccl_device_forceinline bool area_light_tree_parameters(const ccl_global KernelLi
|
|||
distance = make_float2(min_distance, min_distance);
|
||||
}
|
||||
|
||||
cos_theta_u = FLT_MAX;
|
||||
|
||||
const float3 extentu = klight->area.axis_u * klight->area.len_u;
|
||||
const float3 extentv = klight->area.axis_v * klight->area.len_v;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
|
|
@ -302,6 +302,8 @@ ccl_device_forceinline bool triangle_light_tree_parameters(
|
|||
distance = make_float2(min_distance, min_distance);
|
||||
}
|
||||
|
||||
cos_theta_u = FLT_MAX;
|
||||
|
||||
const int object = kemitter->mesh_light.object_id;
|
||||
float3 vertices[3];
|
||||
triangle_world_space_vertices(kg, object, kemitter->prim_id, -1.0f, vertices);
|
||||
|
|
|
@ -456,7 +456,7 @@ void LightManager::device_update_distribution(Device *,
|
|||
dscene->light_distribution.copy_to_device();
|
||||
}
|
||||
|
||||
void LightManager::device_update_tree(Device *device,
|
||||
void LightManager::device_update_tree(Device *,
|
||||
DeviceScene *dscene,
|
||||
Scene *scene,
|
||||
Progress &progress)
|
||||
|
|
|
@ -88,7 +88,7 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id)
|
|||
|
||||
/* TODO: need a better way to handle this when textures are used. */
|
||||
float area = triangle_area(vertices[0], vertices[1], vertices[2]);
|
||||
energy = area * scene->shader_manager->linear_rgb_to_gray(shader->emission_estimate);
|
||||
energy = area * average(shader->emission_estimate);
|
||||
|
||||
/* NOTE: the original implementation used the bounding box centroid, but primitive centroid
|
||||
* seems to work fine */
|
||||
|
@ -181,7 +181,7 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id)
|
|||
strength *= lamp->get_shader()->emission_estimate;
|
||||
}
|
||||
|
||||
energy = scene->shader_manager->linear_rgb_to_gray(strength);
|
||||
energy = average(strength);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue