Fix T45447: Area light importance sampling improvement
authorStefan Werner <swerner@smithmicro.com>
Thu, 16 Jul 2015 06:31:02 +0000 (08:31 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 16 Jul 2015 06:33:13 +0000 (08:33 +0200)
Turning on importance sampling on area lights increases noise on diffuse
surfaces. This was caused by PDF calculated for an intersected point on
light instead of original light position.

Patch by Stefan with some own modifications.

intern/cycles/kernel/kernel_light.h

index 1badbc3b9f7aa7b42c79dbbdc72883bd8ee1ec46..24d4b01302c1400ad6dbe5c117958b931f160013 100644 (file)
@@ -728,15 +728,15 @@ ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D,
                if(dot(D, Ng) >= 0.0f)
                        return false;
 
-               ls->P = make_float3(data0.y, data0.z, data0.w);
+               float3 light_P = make_float3(data0.y, data0.z, data0.w);
 
                if(!ray_quad_intersect(P, D, t,
-                       ls->P, axisu, axisv, &ls->P, &ls->t))
+                       light_P, axisu, axisv, &ls->P, &ls->t))
                        return false;
 
                ls->D = D;
                ls->Ng = Ng;
-               ls->pdf = area_light_sample(P, &ls->P, axisu, axisv, 0, 0, false);
+               ls->pdf = area_light_sample(P, &light_P, axisu, axisv, 0, 0, false);
                ls->eval_fac = 0.25f*invarea;
        }
        else