<p dir="ltr">The background is added as a light when MIS is enabled. So just like point or area lights, it&#39;s in the list of lights that will we be used for direct light sampling. So we are in fact taking light samples, look for LIGHT_BACKGROUND in the code.</p>

<p dir="ltr">The unusual thing that we do is that we don&#39;t take BSDF samples specifically for a light, but rather take advantage of the BSDF sample that we are already taking for indirect light bounces.</p>
<p dir="ltr">BSDF samples for the background are handled in indirect_background, and light samples for the background in direct_emission.</p>
<p dir="ltr">On Jul 15, 2014 3:50 AM, &quot;jumpjump88&quot; &lt;<a href="mailto:jumpjump88@hotmail.com">jumpjump88@hotmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi Brecht and Mike,<br>
&gt; I am having trouble understanding this part:<br>
&gt; &quot;It is not needed that for every Light sample ray, there is a matching<br>
&gt; BSDF sample ray, all that is needed is that the pdf&#39;s match. Avoiding<br>
&gt; that extra BSDF sample and instead doing it using the BSDF sample that<br>
&gt; is already done for the next path vertex gives a nice speedup.&quot;<br>
&gt; I learned MIS from PBRT, and as Mike said, PBRT takes one sample generated<br>
&gt; from Light and one sample generated from BSDF, and then use power heuristic<br>
&gt; to weight their contribution. My understanding is, for MIS to work, there<br>
&gt; needs to have probabilities to sample from both light and BSDF. But if we<br>
&gt; are only generating samples from BSDF, how will the light samples weigh in?<br>
&gt; To be more specific, I am looking at the code in function<br>
&gt; indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float<br>
&gt; bsdf_pdf, int bounce), before calling indirect_background, the ray direction<br>
&gt; is already determined by importance sampling the BSDF, it seems that there<br>
&gt; is no chance to generate a ray direction by importance sampling the<br>
&gt; background as a light source. Could you please point out what I am missing?<br>
&gt;<br>
&gt; Thanks a lot,<br>
&gt; Zhanpeng<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; View this message in context: <a href="http://blender.45788.x6.nabble.com/Lightprobe-importance-sampling-tp6534p123496.html">http://blender.45788.x6.nabble.com/Lightprobe-importance-sampling-tp6534p123496.html</a><br>

&gt; Sent from the Bf-cycles mailing list archive at Nabble.com.<br>
&gt; _______________________________________________<br>
&gt; Bf-cycles mailing list<br>
&gt; <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
&gt; <a href="http://lists.blender.org/mailman/listinfo/bf-cycles">http://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
</p>