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?