Sunday, January 15, 2012

Environment Importance Sampling

I submitted a patch for environment importance sampling (and multiple importance sampling too) that should help reduce noise in scenes with any sort of complex environment them.  It treats the environment as a light so that it participates in the direct lighting machinery, and it also adds an importance map to know where the bright spots on the image are, and favor those.

Here is a scene with the Grace Cathedral light probe as the environment, before and after.  Click each image to get a full size, as you will see the noise better.  This first set has 1000 paths/pixel, and the difference is noticeable:

Before - no environment light
After - with environment light


Even more dramatic is to see it with fewer paths/pixel.  Here is the same, but with 100 paths/pixel:

Before - no environment light (100 paths/pixel)

After - with environment light (100 paths/pixel)

In order to ensure I had this right, I used a debug environment map that looks like this:


I just placed a sphere with smoothed normals in the scene, and ran with 400 paths/pixel.  The difference is pretty striking:

Before - no environment light (debug scene, 400 paths/pixel)

After - with environment light (debug scene, 400 paths/pixel)


It took longer than expected because I was learning my way around the codebase, and there were a couple of noise issues that are subtle and hard to catch if you don't know to look for them.  It didn't seem right, so I kept digging, and when I finally found the code that was wrong (one line of it!) everything fell into place and it looked great.

12 comments:

  1. Wow! Seems like yesterday we talked about a new dev for cycles on BA, and here they are! Performance improvements! And this is so cool already! Can't wait to be able to write "Seems like yesterday we talked about bi-dir path tracing..." ;)
    Great job, keep up the good work Farny!

    ReplyDelete
  2. Excellent work Mike, the differences are very apparent!

    Keep up the good work! :)

    ReplyDelete
  3. Looks greeeaaattt. :)
    Very nice to see. I will make a speed comparison at my interior-scene. ;)

    ReplyDelete
  4. floric -- keep in mind that this only improves things for environment-lit scenes, although if you are letting environment-lit stuff in through a window/doorway it'll help a little there too. If you are only using lights on an interior, this patch unfortunately won't do you any good.

    If you have an env map for 'indoors' then it'll obviously help there too.

    ReplyDelete
    Replies
    1. Of course this scene uses a EnvMap (and a Sun). The patch isn't in SVN yet, right?
      I will simply test it and post a reply. ;)

      Delete
    2. No, the patch isn't in SVN yet; I'm waiting for Brecht to review it. There are builds on graphicall.org ( http://graphicall.org/798 and http://graphicall.org/799 ) if you want to try those, but these days I tend to just build from source.

      Delete
    3. This comment has been removed by the author.

      Delete
    4. Nice!

      I don't know if the volumetric work has been accepted, and I'm building from svn source. I'm tempted to grab those two, but I'm trying to keep my build tree pristine (aside from my own changes).

      But everyone else should take advantage of those builds, for sure.

      Delete
    5. Don't forget, my volume builds also include this patch and selection speedup patch, so you can have all three at the same time. :)

      Delete
    6. (Anyone wondering about removed/reposted comment, accidentally posted under old account)

      Delete
  5. Congratulations and thanks for your efforts! I luuuv speedups! Could you tell us a bit about yourself? what is you background?

    note: please increase exposure in your renders so we can better appreciate the awesome speedups :)

    ReplyDelete
  6. Yeah, sorry about the exposure. I kept waiting until the kids were in bed to work on this stuff, so it was always at night with the lights out. Now that I see all the images in the daytime, well... =)

    As for my background, there are numerous posts on my blog for my own renderer (RenderSpud); see the sidebar for a link to that. If you go way back in the history there I talk about how I came to working on rendering software.

    ReplyDelete