Tedious bugs in my bidirectional path tracer. back

Board: Home Board index Raytracing General Development

(L) [2012/07/05] [ost by shiqiu1105] [Tedious bugs in my bidirectional path tracer.] Wayback!

Hi guys,

I have been trying to create my bidirectional path tracer for a long while.
But there were always bugs which I was having a hard time debugging!

The result image is down below.
My bidir path tracer generates noiser images than my path tracer when the same amount of samples are used [SMILEY :(]

Bidir:
[IMG #1 Image]
Normal path tracer:
[IMG #2 Image]

Notice that not only is the bidir version noiser, they seem to converge to different colors too. Any idea how to debug?
Bidir path tracer is particularly noisy in the edges, as you can see.

Or can I put up the source code so that you guys can help?
[IMG #1]:Not scraped: https://web.archive.org/web/20201130144459im_/http://www.edxgraphics.com/uploads/8/5/2/1/8521459/3031187.jpg?623
[IMG #2]:Not scraped: https://web.archive.org/web/20201130144459im_/http://www.edxgraphics.com/uploads/8/5/2/1/8521459/7394597.jpg?624
(L) [2012/07/06] [ost by spectral] [Tedious bugs in my bidirectional path tracer.] Wayback!

Hum,

There are plenty possible problems... I have a few ideas like floating point precision problems, probabilities computation error, wrong MIS computation, non uniform light sampling etc...

But without code it is difficult... if you share your code we will be able to take a closer look and debug !
(L) [2012/07/06] [ost by ingenious] [Tedious bugs in my bidirectional path tracer.] Wayback!

If you're trying to do multiple importance sampling with balance/power heuristic weighting, then your weights are definitely wrong. Try first with uniform weights to see whether the path contributions are computed correctly. That is, set the weight for each path to 1 / number_of_possible_ways_to_generate_path. If contributions are computed correctly, then applying these weights will make the two images have the same overall brightness, but you'll still have the speckles around the corners. And at this point it will be clear how useless bidirectional path tracing is without multiple importance sampling. After that you can move on to MIS.
(L) [2012/07/07] [ost by shiqiu1105] [Tedious bugs in my bidirectional path tracer.] Wayback!

>> ingenious wrote:If you're trying to do multiple importance sampling with balance/power heuristic weighting, then your weights are definitely wrong. Try first with uniform weights to see whether the path contributions are computed correctly. That is, set the weight for each path to 1 / number_of_possible_ways_to_generate_path. If contributions are computed correctly, then applying these weights will make the two images have the same overall brightness, but you'll still have the speckles around the corners. And at this point it will be clear how useless bidirectional path tracing is without multiple importance sampling. After that you can move on to MIS.
How do you know if two images have the same overall brightness?
I am now trying the unform-weighted bidir path tracing, and I am posting the result.

Uniform-weighted bidir path tracing with 36 samples per pixel, maximum path length 5

[IMG #1 bidir.jpg]


and regular path tracing with also 36 spp.

[IMG #2 path.jpg]


The bidirectional version has A LOT fireflies, and seems to be a little brighter, which I am not sure is caused by the uniform weights or bugs...

Do you know?
[IMG #1]:Not scraped: /web/20201130144459im_/http://ompf2.com/download/file.php?id=25&sid=0e9c78f8578bd2bfcedc821d597d7b2c
[IMG #2]:Not scraped: /web/20201130144459im_/http://ompf2.com/download/file.php?id=26&sid=0e9c78f8578bd2bfcedc821d597d7b2c
(L) [2012/07/07] [ost by graphicsMan] [Tedious bugs in my bidirectional path tracer.] Wayback!

just take a larger number of samples and then average all the samples in the image.
(L) [2012/07/07] [ost by ingenious] [Tedious bugs in my bidirectional path tracer.] Wayback!

>> shiqiu1105 wrote:How do you know if two images have the same overall brightness?
I am now trying the unform-weighted bidir path tracing, and I am posting the result.

The bidirectional version has A LOT fireflies, and seems to be a little brighter, which I am not sure is caused by the uniform weights or bugs...

Do you know?
For checking the brightness, I use a very trivial and easy method, which has proven extremely useful to me. I just paste both images in Windows Paint one after the other in the same document and then flip between them many times with the undo/redo shortcut keys to get a visual comparison. Zooming out a bit before flipping often helps, as the averaging essentially performs oversampling (albeit lowering the resolution, obviously).

I just compared your images in the above way and yes, one is definitely brighter. But before any comparisons, you must be absolutely sure than the path lengths in both images are the same. Otherwise this comparison is useless.

The bidirectional version is normal to have a lot of fireflies, as we discussed already. This is due to a notorious singularity in the path contribution, which occurs around corners. MIS will solve this problem, don't worry for now.
 >> graphicsMan wrote:just take a larger number of samples and then average all the samples in the image.
This is very sensitive to outliers. I recommend a visual comparison. If differences are not apparent in this way, you can save high dynamic range renderings, diff the two images, save the positive/negative difference as a file, and finally examine this file visually (with increased brightness).
(L) [2012/07/08] [ost by shiqiu1105] [Tedious bugs in my bidirectional path tracer.] Wayback!

>> ingenious wrote:shiqiu1105 wrote:How do you know if two images have the same overall brightness?
I am now trying the unform-weighted bidir path tracing, and I am posting the result.

The bidirectional version has A LOT fireflies, and seems to be a little brighter, which I am not sure is caused by the uniform weights or bugs...

Do you know?
For checking the brightness, I use a very trivial and easy method, which has proven extremely useful to me. I just paste both images in Windows Paint one after the other in the same document and then flip between them many times with the undo/redo shortcut keys to get a visual comparison. Zooming out a bit before flipping often helps, as the averaging essentially performs oversampling (albeit lowering the resolution, obviously).

I just compared your images in the above way and yes, one is definitely brighter. But before any comparisons, you must be absolutely sure than the path lengths in both images are the same. Otherwise this comparison is useless.

The bidirectional version is normal to have a lot of fireflies, as we discussed already. This is due to a notorious singularity in the path contribution, which occurs around corners. MIS will solve this problem, don't worry for now.
graphicsMan wrote:just take a larger number of samples and then average all the samples in the image.
This is very sensitive to outliers. I recommend a visual comparison. If differences are not apparent in this way, you can save high dynamic range renderings, diff the two images, save the positive/negative difference as a file, and finally examine this file visually (with increased brightness).
Thanks a lot for your help.

I rendered 2 images with uniform-weighted bidirectional path tracing and regular path tracing with path length being 5 and no russian roultte. The result is still that the bidirection one is slightly brighter and with a lot more firefilies.

I made comparison with results from this site: [LINK http://graphics.ucsd.edu/~iman/BDPT/]
It looks like his unform-weighted bidir path tracing is darker in general than path tracing. (though we don't know his path length or if RR is applied)
And he has much less fireflies than I do in uniform-weighted bidir path tracing.

So I am wondering if there is still bug, or just the MIS is lacking. If it's the later case, hopefully, then I can just add MIS now [SMILEY :)]
(L) [2012/07/08] [ost by ingenious] [Tedious bugs in my bidirectional path tracer.] Wayback!

Are you absolutely, 100 percent sure that the paths in both images have maximum length of 5 and that you don't miss some possible paths? When connecting eye and light sub-paths, you need to watch out for the length of the resulting full path!

And image without MIS can be slightly darker, but *only* around corners, where the fireflies converge very slowly. In the middle of the walls, the brightness should be the same.

And I have strong suspicion that the implementation from the web page you linked above is wrong. I've compared the images, and they have different brightnesses. Moreover, with proper MIS implementation, all fireflies in a diffuse Cornell box go away, so there's absolutely no need for special treatments of short paths as suggested there. So take the results with a grain of salt.
(L) [2012/07/09] [ost by shiqiu1105] [Tedious bugs in my bidirectional path tracer.] Wayback!

>> ingenious wrote:Are you absolutely, 100 percent sure that the paths in both images have maximum length of 5 and that you don't miss some possible paths? When connecting eye and light sub-paths, you need to watch out for the length of the resulting full path!

And image without MIS can be slightly darker, but *only* around corners, where the fireflies converge very slowly. In the middle of the walls, the brightness should be the same.

And I have strong suspicion that the implementation from the web page you linked above is wrong. I've compared the images, and they have different brightnesses. Moreover, with proper MIS implementation, all fireflies in a diffuse Cornell box go away, so there's absolutely no need for special treatments of short paths as suggested there. So take the results with a grain of salt.
Well, the scene I rendered was an open Cornell box, which means it's possible for rays to fly out of the scene. I guess I can make some adjustments and do the test again.

However, I did some other experiments last night. I made a closed scene, where all the boundaries are emitting objects with emitting power being 0.5. In this case, both my path tracer and my bidir path tracer(uniform-weighted) converge to 1.0, which I think is correct.
Does this render my bidir path tracer bugs-free?
(L) [2012/07/09] [ost by shiqiu1105] [Tedious bugs in my bidirectional path tracer.] Wayback!

>> ingenious wrote:Are you absolutely, 100 percent sure that the paths in both images have maximum length of 5 and that you don't miss some possible paths? When connecting eye and light sub-paths, you need to watch out for the length of the resulting full path!

And image without MIS can be slightly darker, but *only* around corners, where the fireflies converge very slowly. In the middle of the walls, the brightness should be the same.

And I have strong suspicion that the implementation from the web page you linked above is wrong. I've compared the images, and they have different brightnesses. Moreover, with proper MIS implementation, all fireflies in a diffuse Cornell box go away, so there's absolutely no need for special treatments of short paths as suggested there. So take the results with a grain of salt.
Thanks for your really helpful reply!

The thing is, I've tried implemented the MIS myself, but failed.
I was following Veach's thesis, [LINK http://graphics.stanford.edu/courses/cs348b-03/papers/veach-chapter10.pdf]

But I didn't use the forward/backward ratio suggested in this paper.
Basically I pre-computed the exact probability of each light/eye vertex, using the equation: P(pi) = P(pi-1 to pi) * GeoTerm * P(pi-1), where P() stands for probability.
And then I sum all the weights for one sampling technique up to an array. And when connecting two paths, I just mutiply the two connecting-nodes' pre-computed weights and divided them by the sum to weight the current connection. So the sum of all weights should be one.

But this doesn't work, image is still noisy.

I have some specifics to mention though.
1. Since I used a pinhole camera(no way to sample on the camera lens), I assign the first eye vertex with probability 1.0
2. I assign the first light vertex with probability 1.0f / Area.

I don't know if I did those right.

Do you know where I can find some easy-to-read implementation of BDPT with MIS? I've been reading Lux, but it seems very complicated... [SMILEY :(]

back