1
$\begingroup$

I am very new to computer graphics, so I am sorry if this results in a stupid question.

For educational purposes I am looking through the pbrt code and I have noticed that before computing the direction for the next path for the subsequent bounce, they flip the direction of the incoming ray. Specifically:

    Vector3f wo = -ray.d, wi;
    Float pdf;
    BxDFType flags;
    Spectrum f = isect.bsdf->Sample_f(wo, &wi, sampler.Get2D(), &pdf,
                                      BSDF_ALL, &flags);

Now my rationale to justify that (also hinted by the name of the variable), is that we are tracing the rays from the camera, but really the phenomenon we are simulating is light coming from light into the camera, so even if the algorithm does:

a) Eye --> Object --> Light

What we are simulating is more like

b) Eye <-- Object <-- Light

So my assumption here is that the direction is flipped because of this reason. But if this is the case, should the resulting wi be flipped again before giving it to the next ray as direction? In the next bounce we'll find ourselves in the same process as in the option a) , but if we don't flip wi, don't we have

PrevObject <-- Object --> Light instead of

PrevObject --> Object --> Light

?

Is Sample_f returning an already flipped wi (i.e. ready for the next step)? Is my reasoning all wrong?

Note that I don't have the book yet, I am just trying to guess from code what's happening.

$\endgroup$
2
  • 1
    $\begingroup$ The incoming direction woW(coming from eye) is filipped as in pbrt "the incoming and outgoing vectors direction are outward facing, after being transformed into local coordinate system, at the surface". It's just pbrt convention to ease the calculation. $\endgroup$
    – ali
    Sep 7, 2017 at 3:54
  • $\begingroup$ @ali Please post that as an answer. Comments are for seeking clarification, not for answering the question. $\endgroup$
    – Dan Hulme
    Sep 7, 2017 at 8:44

1 Answer 1

1
$\begingroup$

The incoming direction $\omega_o$ (coming from eye) is flipped in pbrt:

"Another convention we will follow is that the incident light direction $\omega_i$ and the outgoing viewing direction $\omega_o$ will both be normalized and outward facing after being transformed into the local coordinate system at the surface. By convention, the surface normal always points to the "outside" of the object...".

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.