#### OSL trace to gather information on second hit

Hi,

I'm trying to create a mask of everything after the first hit using `trace`. The way I was thinking of going about this is to do another trace call after the initial hit based on its P. I'm kind of getting the result I am after, however everything is really grainy and I cannot really wrap my head around as to why that is.

I'm using the following code:

```

int hit = trace(P, I);

if (hit)

{

point PP;

getmessage("trace", "P", PP);

int tt = trace(PP, I);

out = tt;

}

```

Which gives me this result:

I'm basically looking for exactly this result minus all the noise, which I'm not really sure why it's happening :) My approach is probably not the proper way to go about this.

Any help would be greatly appreciated!

Thanks, Julius

Hi,

I'm trying to create a mask of everything after the first hit using `trace`. The way I was thinking of going about this is to do another trace call after the initial hit based on its P. I'm kind of getting the result I am after, however everything is really grainy and I cannot really wrap my head around as to why that is.

I'm using the following code:

```

int hit = trace(P, I);

if (hit)

{

point PP;

getmessage("trace", "P", PP);

int tt = trace(PP, I);

out = tt;

}

```

Which gives me this result:

I'm basically looking for exactly this result minus all the noise, which I'm not really sure why it's happening :) My approach is probably not the proper way to go about this.

Any help would be greatly appreciated!

Thanks, Julius

Hey Anders,

Thanks so much for the quick answer! I indeed didn't think of this earlier hehe. That did the trick just perfectly!

Many thanks,

Julius

Have you tried adding ray offset to the second trace call? ie something like:

int tt = trace(PP + I * 1e-3, I);

On Sun, 18 Sep 2022 at 07:28, Julius Ihle <julius.ihle@...> wrote:

Hi,

I'm trying to create a mask of everything after the first hit using `trace`. The way I was thinking of going about this is to do another trace call after the initial hit based on its P. I'm kind of getting the result I am after, however everything is really grainy and I cannot really wrap my head around as to why that is.

I'm using the following code:

```

int hit = trace(P, I);

if (hit)

{

point PP;

getmessage("trace", "P", PP);

int tt = trace(PP, I);

out = tt;

}

```

Which gives me this result:

I'm basically looking for exactly this result minus all the noise, which I'm not really sure why it's happening :) My approach is probably not the proper way to go about this.

Any help would be greatly appreciated!

Thanks, Julius