Commit: 5d344f43603ddba8f3a009915b92a5374066efeb
Author: Erik Englesson
Date:   Tue Jul 31 11:48:27 2018 +0200
Branches: gsoc-2018-many-light-sampling
https://developer.blender.org/rB5d344f43603ddba8f3a009915b92a5374066efeb

Cycles: Light tree: Area light fix

The bounding boxes for area lights was not calculated
properly but has now been fixed.

===================================================================

M       intern/cycles/render/light.cpp
M       intern/cycles/render/light_tree.cpp

===================================================================

diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 0384a30759a..88e02265adf 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -504,6 +504,8 @@ void LightManager::device_update_distribution(Device 
*device, DeviceScene *dscen
                        }
                }
 
+               if(progress.get_cancel()) return;
+
                /* create CDF for distant lights, background lights and light 
tree */
                float tree_energy = (nodesVec.size() > 0) ? nodesVec[0].energy 
: 0.0f;
                float distant_energy = distant_lights_energy(scene, 
emissivePrims);
@@ -543,6 +545,8 @@ void LightManager::device_update_distribution(Device 
*device, DeviceScene *dscen
                        type_prob[i] = probs[i];
                }
 
+               if(progress.get_cancel()) return;
+
                /* find mapping between distribution_id to node_id, used for 
MIS */
                uint *  distribution_to_node =
                        
dscene->light_distribution_to_node.alloc(num_distribution);
@@ -559,6 +563,8 @@ void LightManager::device_update_distribution(Device 
*device, DeviceScene *dscen
                }
        }
 
+       if(progress.get_cancel()) return;
+
        /* find mapping between lamp_id to distribution_id, used for MIS */
        uint *lamp_to_distribution =
                dscene->lamp_to_distribution.alloc(num_lights);
@@ -589,6 +595,8 @@ void LightManager::device_update_distribution(Device 
*device, DeviceScene *dscen
                triangle_to_distribution[3*i+2] = std::get<2>(tri_to_distr[i]);
        }
 
+       if(progress.get_cancel()) return;
+
        /* create light distribution in same order as the emissivePrims */
 
        /* emission area */
diff --git a/intern/cycles/render/light_tree.cpp 
b/intern/cycles/render/light_tree.cpp
index 765b30b322c..7a5f7a6a988 100644
--- a/intern/cycles/render/light_tree.cpp
+++ b/intern/cycles/render/light_tree.cpp
@@ -169,17 +169,14 @@ BoundBox LightTree::get_bbox(const Primitive& prim)
                        bbox.grow(lamp->co + make_float3(radius));
                        bbox.grow(lamp->co - make_float3(radius));
                } else if(lamp->type == LIGHT_AREA){
-                       /*     p2--------p3
-                       *    /         /
-                       *   /         /
-                       *  p0--------p1
-                       */
-                       const float3& p0 = lamp->co;
-                       const float3 axisu = 
lamp->axisu*(lamp->sizeu*lamp->size);
-                       const float3 axisv = 
lamp->axisv*(lamp->sizev*lamp->size);
-                       const float3 p1 = p0 + axisu;
-                       const float3 p2 = p0 + axisv;
-                       const float3 p3 = p0 + axisu + axisv;
+                       const float3 center = lamp->co;
+                       const float3 half_axisu = 0.5f * 
lamp->axisu*(lamp->sizeu*lamp->size);
+                       const float3 half_axisv = 0.5f * 
lamp->axisv*(lamp->sizev*lamp->size);
+                       const float3 p0 = center - half_axisu - half_axisv;
+                       const float3 p1 = center - half_axisu + half_axisv;
+                       const float3 p2 = center + half_axisu - half_axisv;
+                       const float3 p3 = center + half_axisu + half_axisv;
+
                        bbox.grow(p0);
                        bbox.grow(p1);
                        bbox.grow(p2);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to