<p>It comes from the relation between the area formulation and the solid angle formulation of the rendering equation: <span class="math-container">$d\omega = \frac{\cos\theta_L}{r^2}dA$</span>:</p>
<p><a href="https://arxiv.org/abs/1205.4447" rel="nofollow noreferrer">https://arxiv.org/abs/1205.4447</a></p>

CC BY-SA 4.0
2020-06-29T16:54:17.107Z
2020-06-29T16:54:17.107Z
lightxbulb
<p>When implementing explicit light sampling, I am separating the monte-carlo approximation to two parts</p>
<p><span class="math-container">$$\frac{1}{N+M}(\sum^N \text{direct} + \sum^M \text{indirect})$$</span></p>
<p><span class="math-container">$$\text{direct} = \frac{\text{bsdf} \times C \times cos(\theta)}{p}$$</span></p>
<p>I am confused as how to obtain <span class="math-container">$p$</span> for direct lightning.  My light source is an arbitrary triangularized mesh and I am sampling random points from it's surface.</p>
<p>A solution was presented here: <a href="https://computergraphics.stackexchange.com/questions/4288/path-weight-for-direct-light-sampling">Path weight for direct light sampling</a></p>
<p><span class="math-container">$$\frac{A}{r^2} (N_\text{light} \cdot -L)$$</span></p>
<p>Where does this come from?  I'm asking for a reference or a derivation. Thanks!</p>

CC BY-SA 4.0
2020-06-29T16:50:43.860Z
Read "[Shirley, 1996] Monte Carlo Techniques for Direct Lighting Calculations".
gallickgunner
CC BY-SA 4.0
2020-07-01T10:50:20.997Z
http://www.pbr-book.org/3ed-2018/Color_and_Radiometry/Working_with_Radiometric_Integrals.html
Peter
CC BY-SA 4.0
2020-07-01T10:50:57.473Z
Also, I think you need to account for the probability of picking that triangle. I believe that the first equation you list is incorrect. You can't just add the direct and indirect samples together because they are from two different sampling schemes. You should look at multiple importance sampling which is a technique for combining sampling methods together. If you want help with implementing that don't hesitate to ask.
Peter
CC BY-SA 4.0
2020-07-01T13:05:28.213Z
@Peter i thought the probability is taken into account with $A$, as long as points are sampled uniformly from the surface. However i already got decent results adding together the samples. The link I mentioned explains that the samples can be added together when using the formula
vuoriov4
CC BY-SA 4.0
2020-07-01T17:45:18.317Z
I think it would work as long as A is the surface area of the whole mesh (not the triangle you are sampling) and the probablity of selecting a triangle is proportional to its surface area. If you want to do more advanced triangle selection which takes into account occlusion or distance from the shading point then you would have to change this.
Peter
CC BY-SA 4.0
2020-07-01T17:47:45.890Z
As for why I don't think you can just add them up, even if they are in the same domain, your probablity p would actually be the probabiliy of sampling it in the indirect + the direct. The best way to check if this is right or not is to test direct, indirect and direct+indirect and make sure they all look exactly the same. If you want to read more about combining methods have a read of https://cgg.mff.cuni.cz/~jaroslav/teaching/2015-npgr010/slides/06%20-%20npgr010-2015%20-%20MIS.pdf . multiple importance sampling is easy to implement and will lower you variance even if your technique does work.
Peter
<pathtracing>
Probability density for explicit light sampling
vuoriov4
# Probability density for explicit light sampling

(Asked by: username_0 on 2020-06-29)

When implementing explicit light sampling, I am separating the monte-carlo approximation to two parts

$$\frac{1}{N+M}(\sum^N \text{direct} + \sum^M \text{indirect})$$

$$\text{direct} = \frac{\text{bsdf} \times C \times cos(\theta)}{p}$$

I am confused as how to obtain $p$ for direct lightning. My light source is an arbitrary triangularized mesh and I am sampling random points from it's surface.

A solution was presented here: [Path weight for direct light sampling](https://computergraphics.stackexchange.com/questions/4288/path-weight-for-direct-light-sampling)

$$\frac{A}{r^2} (N\_\text{light} \cdot -L)$$

Where does this come from? I'm asking for a reference or a derivation. Thanks!

**Tags:** pathtracing

> **Comments:**
> **username_1**: Read "[Shirley, 1996] Monte Carlo Techniques for Direct Lighting Calculations".  
> **username_2**: http://www.pbr-book.org/3ed-2018/Color_and_Radiometry/Working_with_Radiometric_Integrals.html  
> **username_2**: Also, I think you need to account for the probability of picking that triangle. I believe that the first equation you list is incorrect. You can't just add the direct and indirect samples together because they are from two different sampling schemes. You should look at multiple importance sampling which is a technique for combining sampling methods together. If you want help with implementing that don't hesitate to ask.  
> **username_0**: @username_2 i thought the probability is taken into account with $A$, as long as points are sampled uniformly from the surface. However i already got decent results adding together the samples. The link I mentioned explains that the samples can be added together when using the formula  
> **username_2**: I think it would work as long as A is the surface area of the whole mesh (not the triangle you are sampling) and the probablity of selecting a triangle is proportional to its surface area. If you want to do more advanced triangle selection which takes into account occlusion or distance from the shading point then you would have to change this.  
> **username_2**: As for why I don't think you can just add them up, even if they are in the same domain, your probablity p would actually be the probabiliy of sampling it in the indirect + the direct. The best way to check if this is right or not is to test direct, indirect and direct+indirect and make sure they all look exactly the same. If you want to read more about combining methods have a read of https://cgg.mff.cuni.cz/~jaroslav/teaching/2015-npgr010/slides/06%20-%20npgr010-2015%20-%20MIS.pdf . multiple importance sampling is easy to implement and will lower you variance even if your technique does work.  

---

## 1 answers

### Answer by username_3 on 2020-06-29. Score: 3 | Accepted answer

It comes from the relation between the area formulation and the solid angle formulation of the rendering equation: $d\omega = \frac{\cos\theta\_L}{r^2}dA$:

<https://arxiv.org/abs/1205.4447>


---

