Cycles: Fix missing mesh flags update when tweaking shaders

This is a bit weak, but better than tagging whole mesh manager for update.

Maybe we'll solve such dual-look up in the future.

This commit finally solves T48963: Noise when changing Diffuse node to Emission node
This commit is contained in:
Sergey Sharybin 2016-07-28 12:37:44 +02:00
parent 9f18e3acd6
commit df00529648
3 changed files with 9 additions and 9 deletions

View File

@ -220,10 +220,16 @@ bool LightManager::object_usable_as_light(Object *object) {
return false;
}
/* Skip if we have no emission shaders. */
if(!mesh->has_mis_emission) {
return false;
/* TODO(sergey): Ideally we want to avoid such duplicated loop, since it'll
* iterate all mesh shaders twice (when counting and when calculating
* triangle area.
*/
foreach(const Shader *shader, mesh->used_shaders) {
if(shader->use_mis && shader->has_surface_emission) {
return true;
}
}
return true;
return false;
}
void LightManager::device_update_distribution(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)

View File

@ -156,7 +156,6 @@ Mesh::Mesh()
geometry_flags = GEOMETRY_NONE;
has_volume = false;
has_mis_emission = false;
has_surface_bssrdf = false;
}
@ -1290,14 +1289,10 @@ void MeshManager::device_update_flags(Device * /*device*/,
/* update flags */
foreach(Mesh *mesh, scene->meshes) {
mesh->has_volume = false;
mesh->has_mis_emission = false;
foreach(const Shader *shader, mesh->used_shaders) {
if(shader->has_volume) {
mesh->has_volume = true;
}
if(shader->use_mis && shader->has_surface_emission) {
mesh->has_mis_emission = true;
}
if(shader->has_surface_bssrdf) {
mesh->has_surface_bssrdf = true;
}

View File

@ -122,7 +122,6 @@ public:
array<bool> forms_quad; /* used to tell if triangle is part of a quad patch */
bool has_volume; /* Set in the device_update_flags(). */
bool has_mis_emission; /* Set in the device_update_flags(). */
bool has_surface_bssrdf; /* Set in the device_update_flags(). */
array<float3> curve_keys;