Merge branch 'master' into blender2.8
[blender.git] / intern / cycles / render / light.cpp
index 5a77094c0c1413da0d24cf6b4ecaa3db4c20fdbf..806f1cad03ea5b2dc9a7722949ab95116658ec84 100644 (file)
@@ -119,6 +119,7 @@ NODE_DEFINE(Light)
        SOCKET_FLOAT(sizeu, "Size U", 1.0f);
        SOCKET_VECTOR(axisv, "Axis V", make_float3(0.0f, 0.0f, 0.0f));
        SOCKET_FLOAT(sizev, "Size V", 1.0f);
+       SOCKET_BOOLEAN(round, "Round", false);
 
        SOCKET_INT(map_resolution, "Map Resolution", 512);
 
@@ -735,12 +736,15 @@ void LightManager::device_update_points(Device *,
                        float3 axisu = light->axisu*(light->sizeu*light->size);
                        float3 axisv = light->axisv*(light->sizev*light->size);
                        float area = len(axisu)*len(axisv);
-                       float invarea = (area > 0.0f)? 1.0f/area: 1.0f;
+                       if(light->round) {
+                               area *= -M_PI_4_F;
+                       }
+                       float invarea = (area != 0.0f)? 1.0f/area: 1.0f;
                        float3 dir = light->dir;
                        
                        dir = safe_normalize(dir);
 
-                       if(light->use_mis && area > 0.0f)
+                       if(light->use_mis && area != 0.0f)
                                shader_id |= SHADER_USE_MIS;
 
                        klights[light_index].co[0] = co.x;
@@ -808,7 +812,10 @@ void LightManager::device_update_points(Device *,
                float3 axisu = light->axisu*(light->sizeu*light->size);
                float3 axisv = light->axisv*(light->sizev*light->size);
                float area = len(axisu)*len(axisv);
-               float invarea = (area > 0.0f)? 1.0f/area: 1.0f;
+               if(light->round) {
+                       area *= -M_PI_4_F;
+               }
+               float invarea = (area != 0.0f)? 1.0f/area: 1.0f;
                float3 dir = light->dir;
 
                dir = safe_normalize(dir);