Fix issue in with multiple importance sampling in recent code refactor.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 17 May 2016 23:50:35 +0000 (01:50 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 17 May 2016 23:51:30 +0000 (01:51 +0200)
intern/cycles/render/light.cpp
intern/cycles/render/mesh_displace.cpp

index 4564b935de4c48b6ccaa76b3c8fb7d75e43e66e1..91a9f22276fddd205f7a7443f5bb4dd33c5e7c13 100644 (file)
@@ -233,7 +233,9 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                /* count triangles */
                if(have_emission) {
                        for(size_t i = 0; i < mesh->triangles.size(); i++) {
-                               Shader *shader = scene->shaders[mesh->shader[i]];
+                               int shader_index = mesh->shader[i];
+                               Shader *shader = (shader_index < mesh->used_shaders.size()) ?
+                                       mesh->used_shaders[shader_index] : scene->default_surface;
 
                                if(shader->use_mis && shader->has_surface_emission)
                                        num_triangles++;
@@ -303,7 +305,9 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                        }
 
                        for(size_t i = 0; i < mesh->triangles.size(); i++) {
-                               Shader *shader = scene->shaders[mesh->shader[i]];
+                               int shader_index = mesh->shader[i];
+                               Shader *shader = (shader_index < mesh->used_shaders.size()) ?
+                                       mesh->used_shaders[shader_index] : scene->default_surface;
 
                                if(shader->use_mis && shader->has_surface_emission) {
                                        distribution[offset].x = totarea;
index df8be4cbe2fdff02d49ab4b9b7701b638012be05..d19bf2084d708ad2c0ec4ddffe45f0ba715a65a9 100644 (file)
@@ -62,7 +62,9 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
 
        for(size_t i = 0; i < mesh->triangles.size(); i++) {
                Mesh::Triangle t = mesh->triangles[i];
-               Shader *shader = scene->shaders[mesh->shader[i]];
+               int shader_index = mesh->shader[i];
+               Shader *shader = (shader_index < mesh->used_shaders.size()) ?
+                       mesh->used_shaders[shader_index] : scene->default_surface;
 
                if(!shader->has_displacement)
                        continue;
@@ -146,7 +148,9 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
        Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
        for(size_t i = 0; i < mesh->triangles.size(); i++) {
                Mesh::Triangle t = mesh->triangles[i];
-               Shader *shader = scene->shaders[mesh->shader[i]];
+               int shader_index = mesh->shader[i];
+               Shader *shader = (shader_index < mesh->used_shaders.size()) ?
+                       mesh->used_shaders[shader_index] : scene->default_surface;
 
                if(!shader->has_displacement)
                        continue;