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

<p>"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...".</p>

<p><a href="https://i.sstatic.net/aFn0D.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aFn0D.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2017-09-07T09:52:40.797Z
2017-09-07T13:10:37.660Z
2017-09-07T13:10:37.660Z
ali
<p>I am very new to computer graphics, so I am sorry if this results in a stupid question. </p>

<p>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:</p>

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

<p>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:</p>

<p>a) Eye --> Object --> Light </p>

<p>What we are simulating is more like </p>

<p>b) Eye &lt;-- Object &lt;-- Light </p>

<p>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</p>

<p>PrevObject &lt;-- Object --> Light  instead of </p>

<p>PrevObject --> Object --> Light </p>

<p>? </p>

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

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

CC BY-SA 3.0
2017-09-07T03:54:43.683Z
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.
ali
CC BY-SA 3.0
2017-09-07T08:44:10.873Z
@ali Please post that as an answer. Comments are for seeking clarification, not for answering the question.
Dan Hulme
<pathtracing>
PBRT path tracing: negation of ray direction before next event estimation
jackten
# PBRT path tracing: negation of ray direction before next event estimation

(Asked by: username_0 on 2017-09-06)

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.

**Tags:** pathtracing

> **Comments:**
> **username_1**: 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.  
> **username_2**: @username_1 Please post that as an answer. Comments are for seeking clarification, not for answering the question.  

---

## 1 answers

### Answer by username_1 on 2017-09-07. Score: 1 | Accepted answer

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](https://i.sstatic.net/aFn0D.png)](https://i.sstatic.net/aFn0D.png)


---

