<p>You can provide an <code>intersect_any(ray, scene, min_t, max_t)</code> function, that returns true at the first intersection. So it has the option to exit early compared to the usual <code>intersect</code> function. Additionally you do not care about normals, texture coordinates, positions, so you can avoid computing those in many cases. You need <code>max_t</code> though to limit the ray to the segment between the two points you are testing.</p>

<p>In the worst case scenario (there is nothing between the two points) you will still need to iterate over all objects unless you are using acceleration structures.</p>

CC BY-SA 4.0
2019-10-18T21:05:25.787Z
Thanks for your help. Where can I find the algorithms about ray tracing? I think Peter Shirley's books are vague.
bitWise
CC BY-SA 4.0
2019-10-18T21:49:21.600Z
@bitWise There's not a single one ray-tracing algorithm. You'll have to be more specific.
lightxbulb
CC BY-SA 4.0
2019-10-18T20:36:19.130Z
2019-10-18T20:36:19.130Z
lightxbulb
<p>I am trying to implement next event estimation to reduce the noise of path tracer and I need a pseudocode. </p>

<p>Edit: I know how to sample direct illumination but the visibility function is the real problem I face. How to code the visibility function without iterating over the objects in the scene?</p>

<raytracing>
How can I implement next event estimation?
bitWise
# How can I implement next event estimation?

(Asked by: username_0 on 2019-10-18)

I am trying to implement next event estimation to reduce the noise of path tracer and I need a pseudocode.

Edit: I know how to sample direct illumination but the visibility function is the real problem I face. How to code the visibility function without iterating over the objects in the scene?

**Tags:** raytracing


---

## 1 answers

### Answer by username_1 on 2019-10-18. Score: 1 | Accepted answer

You can provide an `intersect_any(ray, scene, min_t, max_t)` function, that returns true at the first intersection. So it has the option to exit early compared to the usual `intersect` function. Additionally you do not care about normals, texture coordinates, positions, so you can avoid computing those in many cases. You need `max_t` though to limit the ray to the segment between the two points you are testing.

In the worst case scenario (there is nothing between the two points) you will still need to iterate over all objects unless you are using acceleration structures.

> **Comments:**
> **username_0**: Thanks for your help. Where can I find the algorithms about ray tracing? I think Peter Shirley's books are vague.  
> **username_1**: @username_0 There's not a single one ray-tracing algorithm. You'll have to be more specific.  

---

