Page 1 of 1

ordering primary rays

Posted: Sat Sep 28, 2013 1:36 pm
by alidade
How do you guys order your primary rays? If you shoot bundles, how do you order your bundles? By pixel row/ column? By quadtree / Morton number? By predetermined BVH data?

Related question- anyone implement any entry point space skipping procedure into the scene acceleration structure?

thanks

Re: ordering primary rays

Posted: Mon Jan 27, 2014 1:53 am
by phkahler
In the old day of ompf.org I posted something about this. I was doing single rays even for the camera and found that shooting rays in Z-order (depth first quad tree order) resulted in some percent performance increase. i think it was between 7 and 9 percent for what I was doing at the time. The reason is simple cache performance. If you have a 1024 pixel wide image and go in scan line order, you'll have 1024 rays spread over a large portion of the scene and traversal structure. That means data needed at the start of the next line may have been discarded and need to be reloaded. If you go with Z order (or even tiling) you'll have 1024 rays in a tight 32x32 pixel bunch which will all visit similar areas of the scene and data structures. For small bundles it probably doesn't make a lot of difference weather it's 1x4 or 2x2 for example, but you do want to have successive bundles in the same area as much as possible.