forked from bartvdbraak/blender
Cycles: De-duplicate check for MIS shaders in meshes
Should be no functional changes.
This commit is contained in:
parent
aaac4e965e
commit
87717c6449
@ -227,33 +227,30 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
|
|||||||
|
|
||||||
foreach(Object *object, scene->objects) {
|
foreach(Object *object, scene->objects) {
|
||||||
Mesh *mesh = object->mesh;
|
Mesh *mesh = object->mesh;
|
||||||
bool have_emission = false;
|
|
||||||
|
|
||||||
/* skip if we are not visible for BSDFs */
|
/* Skip if we are not visible for BSDFs. */
|
||||||
if(!(object->visibility & (PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT)))
|
if(!(object->visibility & (PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* skip motion blurred deforming meshes, not supported yet */
|
/* Skip motion blurred deforming meshes, not supported yet. */
|
||||||
if(mesh->has_motion_blur())
|
if(mesh->has_motion_blur()) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* skip if we have no emission shaders */
|
|
||||||
foreach(Shader *shader, mesh->used_shaders) {
|
|
||||||
if(shader->use_mis && shader->has_surface_emission) {
|
|
||||||
have_emission = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count triangles */
|
/* Skip if we have no emission shaders. */
|
||||||
if(have_emission) {
|
if(!mesh->has_mis_emission) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Count triangles. */
|
||||||
size_t mesh_num_triangles = mesh->num_triangles();
|
size_t mesh_num_triangles = mesh->num_triangles();
|
||||||
for(size_t i = 0; i < mesh_num_triangles; i++) {
|
for(size_t i = 0; i < mesh_num_triangles; i++) {
|
||||||
int shader_index = mesh->shader[i];
|
int shader_index = mesh->shader[i];
|
||||||
Shader *shader = (shader_index < mesh->used_shaders.size()) ?
|
Shader *shader = (shader_index < mesh->used_shaders.size())
|
||||||
mesh->used_shaders[shader_index] : scene->default_surface;
|
? mesh->used_shaders[shader_index]
|
||||||
|
: scene->default_surface;
|
||||||
|
|
||||||
if(shader->use_mis && shader->has_surface_emission)
|
if(shader->use_mis && shader->has_surface_emission) {
|
||||||
num_triangles++;
|
num_triangles++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,31 +268,29 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
foreach(Object *object, scene->objects) {
|
foreach(Object *object, scene->objects) {
|
||||||
Mesh *mesh = object->mesh;
|
if(progress.get_cancel()) return;
|
||||||
bool have_emission = false;
|
|
||||||
|
|
||||||
/* skip if we are not visible for BSDFs */
|
Mesh *mesh = object->mesh;
|
||||||
|
|
||||||
|
/* Skip if we are not visible for BSDFs. */
|
||||||
if(!(object->visibility & (PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT))) {
|
if(!(object->visibility & (PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT))) {
|
||||||
j++;
|
j++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip motion blurred deforming meshes, not supported yet */
|
/* Skip motion blurred deforming meshes, not supported yet. */
|
||||||
if(mesh->has_motion_blur()) {
|
if(mesh->has_motion_blur()) {
|
||||||
j++;
|
j++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip if we have no emission shaders */
|
/* Skip if we have no emission shaders. */
|
||||||
foreach(Shader *shader, mesh->used_shaders) {
|
if(!mesh->has_mis_emission) {
|
||||||
if(shader->use_mis && shader->has_surface_emission) {
|
j++;
|
||||||
have_emission = true;
|
continue;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum area */
|
/* sum area */
|
||||||
if(have_emission) {
|
|
||||||
bool transform_applied = mesh->transform_applied;
|
bool transform_applied = mesh->transform_applied;
|
||||||
Transform tfm = object->tfm;
|
Transform tfm = object->tfm;
|
||||||
int object_id = j;
|
int object_id = j;
|
||||||
@ -324,8 +319,9 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
|
|||||||
size_t mesh_num_triangles = mesh->num_triangles();
|
size_t mesh_num_triangles = mesh->num_triangles();
|
||||||
for(size_t i = 0; i < mesh_num_triangles; i++) {
|
for(size_t i = 0; i < mesh_num_triangles; i++) {
|
||||||
int shader_index = mesh->shader[i];
|
int shader_index = mesh->shader[i];
|
||||||
Shader *shader = (shader_index < mesh->used_shaders.size()) ?
|
Shader *shader = (shader_index < mesh->used_shaders.size())
|
||||||
mesh->used_shaders[shader_index] : scene->default_surface;
|
? mesh->used_shaders[shader_index]
|
||||||
|
: scene->default_surface;
|
||||||
|
|
||||||
if(shader->use_mis && shader->has_surface_emission) {
|
if(shader->use_mis && shader->has_surface_emission) {
|
||||||
distribution[offset].x = totarea;
|
distribution[offset].x = totarea;
|
||||||
@ -348,9 +344,6 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
|
|||||||
totarea += triangle_area(p1, p2, p3);
|
totarea += triangle_area(p1, p2, p3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(progress.get_cancel()) return;
|
|
||||||
|
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,7 @@ Mesh::Mesh()
|
|||||||
geometry_flags = GEOMETRY_NONE;
|
geometry_flags = GEOMETRY_NONE;
|
||||||
|
|
||||||
has_volume = false;
|
has_volume = false;
|
||||||
|
has_mis_emission = false;
|
||||||
has_surface_bssrdf = false;
|
has_surface_bssrdf = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1289,10 +1290,14 @@ void MeshManager::device_update_flags(Device * /*device*/,
|
|||||||
/* update flags */
|
/* update flags */
|
||||||
foreach(Mesh *mesh, scene->meshes) {
|
foreach(Mesh *mesh, scene->meshes) {
|
||||||
mesh->has_volume = false;
|
mesh->has_volume = false;
|
||||||
|
mesh->has_mis_emission = false;
|
||||||
foreach(const Shader *shader, mesh->used_shaders) {
|
foreach(const Shader *shader, mesh->used_shaders) {
|
||||||
if(shader->has_volume) {
|
if(shader->has_volume) {
|
||||||
mesh->has_volume = true;
|
mesh->has_volume = true;
|
||||||
}
|
}
|
||||||
|
if(shader->use_mis && shader->has_surface_emission) {
|
||||||
|
mesh->has_mis_emission = true;
|
||||||
|
}
|
||||||
if(shader->has_surface_bssrdf) {
|
if(shader->has_surface_bssrdf) {
|
||||||
mesh->has_surface_bssrdf = true;
|
mesh->has_surface_bssrdf = true;
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,7 @@ public:
|
|||||||
array<bool> forms_quad; /* used to tell if triangle is part of a quad patch */
|
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_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(). */
|
bool has_surface_bssrdf; /* Set in the device_update_flags(). */
|
||||||
|
|
||||||
array<float3> curve_keys;
|
array<float3> curve_keys;
|
||||||
|
Loading…
Reference in New Issue
Block a user