Tuesday, March 1, 2016

Lazy debugging

When I get a chunk of time I have been beavering away on a second part to my mini-book.     I just added implicit direct lighting (where you send scattered rays preferentially toward lights) and I got a bunch of speckles.

What are those?   Bad importance sampling?   A bug?   Some correct behavior I don't understand?   Who knows.   Should I track it down, or keep adding features and hope it luckily goes away in various refactors that come along organically.

Which one is less work?   Hope it goes away!   Sold!

3 comments:

Pseudonym said...

There's an easy way to tell if it's a bug or not: bump up the number of samples per pixel (to 50,000 or so) and see if the speckles disappear. Run it overnight if you have to.

I recall this artifact from my last Monte Carlo path tracer. It's not that importance sampling is incorrect (in the sense that it converges to the correct expected value), but some ultra-naive approaches don't reduce the variance in quite the way you'd like.

I don't know how long it's been since you read the Eric Veach paper, "Optimally Combining Sampling Techniques for Monte Carlo Rendering", but it might be worth just glancing at the figures to refresh your memory on that point.

Peter Shirley said...

GOOD idea. Yep it's a bug. Thanks that is a good technique!

That Veach paper is one of my favorite papers ever. I am using it for this project.

Genius Lvl said...

This is maybe insulting Pete, but did you max with zero and min with 1 everywhere that it makes sense to. I recently forget to do this with all the cosine terms, in my shader, and guess what.