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.