0

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

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

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

vuoriov4
  • 67
  • 5
  • Read "[Shirley, 1996] Monte Carlo Techniques for Direct Lighting Calculations". – gallickgunner Jun 29 '20 at 16:50
  • http://www.pbr-book.org/3ed-2018/Color_and_Radiometry/Working_with_Radiometric_Integrals.html – Peter Jul 01 '20 at 10:50
  • 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 Jul 01 '20 at 10:50
  • @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 Jul 01 '20 at 13:05
  • 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 Jul 01 '20 at 17:45
  • 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 Jul 01 '20 at 17:47

1 Answers1

3

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

lightxbulb
  • 2,226
  • 1
  • 6
  • 14