<p>Only one path per sample.</p>

<p>If you had 64 bounces per first hit and 64 per second hit and so forth you'd never get an image.</p>

<p>Edit: And that's why you need to sample each pixel so many times (easily more than 1024 samples) in order to get it to converge, ie get rid of the noise.</p>

<p>As per 2) (from comment below) The 64 primary rays will not hit the same object in the same spot so you will have to calculate everything for each sample.</p>

CC BY-SA 4.0
2018-08-18T05:22:53.970Z
I don't understand why I'd never get an image in that first case? Can you elaborate a little. Also about my 2nd question, I think if i explicitly cast direction towards light that would be light sampling and if i am randomly casting according to the surface that would be BRDF sampling. Then MIS aims to combine both of these. Is this correct?
gallickgunner
CC BY-SA 4.0
2018-08-18T13:42:09.660Z
The number of rays needed would grow exponentially depending on path depth. For 3 bounces it would be 64*64*64 rays required,adding another bounce would be *64 again, and this is all caused by a single primary ray. So the final image would need an astronomical number of rays. Also this technique would introduce statistical bias as rays at a lower bounce depth will have heavy influence based on the millions of samples their children receive.
PaulHK
CC BY-SA 4.0
2018-08-19T06:10:39.230Z
@PaulHK - Aha! True. Never thought about that statistical bias. Can you also tell me about that 2nd question?
gallickgunner
CC BY-SA 4.0
2018-08-20T06:17:51.080Z
The 64 primary rays will not hit the same object in the same spot so you will have to calculate everything for each sample.
beyond
CC BY-SA 4.0
2018-08-17T11:56:43.567Z
2018-08-20T06:19:07.423Z
2018-08-20T06:19:07.423Z
beyond
<p>Suppose my path tracer is shooting 64 rays per pixel (in an 8x8 grid). The confusion is, when accounting for Global illumination, should I shoot additional <code>X</code> number of random rays for each of those initial 64 rays? This would equal to shooting <code>64 * X *number of bounces</code> rays (all sorts of) which is really large. And since I am making the path tracer on GPU memory is surely a concern.</p>

<p>OR I just shoot 1 random ray for indirect illumination. This would mean that the total secondary rays cast for GI would equal 64 per pixel.</p>

<p><strong>The problem here is, all those 64 rays cast per pixel aren't guaranteed to intersect at the same point albeit close enough. If the intersection positions aren't the same then this would mean I am calculating indirect illumination using just 1 sample which is ofcourse very low.</strong></p>

<p>Now this is again for just GI. What about Area light sources? Should I be explicitly sampling X number of rays for Area Light for each of those initial 64 rays? </p>

<p>I think this is what Cook mentioned in his paper on <strong>Distributed Ray Tracing</strong>. He says</p>

<blockquote>
  <p>Rather than adding more rays for each dimension, the existing rays are
  distributed in each dimension according to the values of the
  corresponding parameter. The key is that no extra rays are needed beyond
  those used for oversampling.</p>
</blockquote>

<p>I am confused because mostly I have seen algorithms and code snippets following the second approach. Casting X number of rays for GI.</p>

<p><strong>2)</strong> Secondly for direct illumination is the light path explicitly calculated or it's taken from the samples created for GI? The former means if I am sampling 1 ray for GI for each of the 64 rays per pixel, then I am also shooting another ray explicitly for the light path. The random sampled ray, if points to the light source I ignore it.</p>

<p>The latter means, I sample only 1 ray, if it doesn't hits the light source that's my GI, and if it hits the light source I accumulate it's color as direct lighting.</p>

<pathtracing><sampling><importance-sampling>
Path Tracer - sampling dimensions confusion
gallickgunner
# Path Tracer - sampling dimensions confusion

(Asked by: username_0 on 2018-08-17)

Suppose my path tracer is shooting 64 rays per pixel (in an 8x8 grid). The confusion is, when accounting for Global illumination, should I shoot additional `X` number of random rays for each of those initial 64 rays? This would equal to shooting `64 * X *number of bounces` rays (all sorts of) which is really large. And since I am making the path tracer on GPU memory is surely a concern.

OR I just shoot 1 random ray for indirect illumination. This would mean that the total secondary rays cast for GI would equal 64 per pixel.

**The problem here is, all those 64 rays cast per pixel aren't guaranteed to intersect at the same point albeit close enough. If the intersection positions aren't the same then this would mean I am calculating indirect illumination using just 1 sample which is ofcourse very low.**

Now this is again for just GI. What about Area light sources? Should I be explicitly sampling X number of rays for Area Light for each of those initial 64 rays?

I think this is what Cook mentioned in his paper on **Distributed Ray Tracing**. He says

> Rather than adding more rays for each dimension, the existing rays are
> distributed in each dimension according to the values of the
> corresponding parameter. The key is that no extra rays are needed username_1
> those used for oversampling.

I am confused because mostly I have seen algorithms and code snippets following the second approach. Casting X number of rays for GI.

**2)** Secondly for direct illumination is the light path explicitly calculated or it's taken from the samples created for GI? The former means if I am sampling 1 ray for GI for each of the 64 rays per pixel, then I am also shooting another ray explicitly for the light path. The random sampled ray, if points to the light source I ignore it.

The latter means, I sample only 1 ray, if it doesn't hits the light source that's my GI, and if it hits the light source I accumulate it's color as direct lighting.

**Tags:** pathtracing, sampling, importance-sampling


---

## 1 answers

### Answer by username_1 on 2018-08-17. Score: 3 | Accepted answer

Only one path per sample.

If you had 64 bounces per first hit and 64 per second hit and so forth you'd never get an image.

Edit: And that's why you need to sample each pixel so many times (easily more than 1024 samples) in order to get it to converge, ie get rid of the noise.

As per 2) (from comment below) The 64 primary rays will not hit the same object in the same spot so you will have to calculate everything for each sample.

> **Comments:**
> **username_0**: I don't understand why I'd never get an image in that first case? Can you elaborate a little. Also about my 2nd question, I think if i explicitly cast direction towards light that would be light sampling and if i am randomly casting according to the surface that would be BRDF sampling. Then MIS aims to combine both of these. Is this correct?  
> **username_2**: The number of rays needed would grow exponentially depending on path depth. For 3 bounces it would be 64*64*64 rays required,adding another bounce would be *64 again, and this is all caused by a single primary ray. So the final image would need an astronomical number of rays. Also this technique would introduce statistical bias as rays at a lower bounce depth will have heavy influence based on the millions of samples their children receive.  
> **username_0**: @username_2 - Aha! True. Never thought about that statistical bias. Can you also tell me about that 2nd question?  
> **username_1**: The 64 primary rays will not hit the same object in the same spot so you will have to calculate everything for each sample.  

---

