I'm currently visual effects supervisor on the new Fast and Furious movie. Every now and then, I come up with some ideas on graphics programming that I'd like to share, so I started this blog.

Thursday, June 30, 2005

Fast ambient occlusion

Ambient occlusion, of course, is essential to modern 3D rendering. It adds "life" or "atmosphere" to 3D models in environments, and once you've seen anything with it, you'll never settle for anything less.

On The Chronicles of Riddick we did our first ambient occlusion rendering, and while it worked fine, it was very slow to compute. So slow, in fact, that we did ambient occlusion as a pre-process on the model, and saved the model with the occlusion baked in. Fortunately, we were dealing with almost-rigid spaceships and props most of the time, and this worked fine.

I noticed that all commercial renderers now support ambient occlusion to some extent. I've done some testing with the Gelato beta, and RenderMan 11.5 (both of course obsolete now.) We also did had an overly aggressive animator take home a shot and do the ambient occlusion on his home network using the Brazil renderer. My experience is that these obsolete versions of Gelato and RenderMan worked OK, but had significant artifacts and were pretty slow -- whereas the Brazil AO was amazingly fast and seemed artifact free, but it doesn't run on Linux (yet!) Brazil's AO seemed so fast that I could hardly believe it, they must be doing some amazing acceleration. I couldn't figure it out -- if you think about ambient occlusion, you realize that the close polygons are much more important than the far away ones -- the big ones are more important than the little ones -- and there has to be some way of coming up with an approximate solution quickly.

We also thought about using hardware rendering to accelerate ambient occlusion. We hired this spectacular programmer Hal Bertram to experiment with this, he did it in an afternoon by rendering the scene with the light in 256 different directions, and averaging these images together. Unfortunately, hardware (at the time, this was almost two years ago) was still pretty limited, and there were serious artifacts (aliasing, limited Z resolution, banding...) but it was super fast (a few seconds a frame.)

Finally I read of a nice acceleration for AO that is part of the GPU Gems book. As with many things in that book, it's a technique that applies perfectly well to traditional computers too -- although it would be slower on traditional computers (and perhaps that delta will increase over time as GPUs have been increasing in speed somewhat faster than CPUs) At this point, the article is available online at

although you can always just go buy the book. The trick in this article is to represent each vertex as a disk, and calculate how much each disk shadows each other disk -- independently! -- and add them up. This is quick and easy, but it's still an O(n2) algorithm.

The acceleration comes from building a spatial tree. At each level of the tree, you have a list of disks in that part of the tree, plus some kind of approximation of all the disks from there on down. When calculating the occlusion for a particular vertex, you note how much shadow a particular subtree might contribute, and if it's less than a tolerance parameter, you use the approximate model.

The article in the book is just about that vague, leaving a lot of room for interpretation.

For my tree, I used a kd tree. The root of the tree contains the whole model, and the bounding box is divided into two subtrees by a median -- that is, half the discs are on one side of the plane, half on the other. I choose the axis of the plane (x, y, or z) to give the largest smallest extent. That is, if I have a box that has dimensions (10, 5, 3) and the median in each dimension is at (3, 2, 1) (say), then the x dimension would be partitioned into two parts 3 and 7 units wide, the y dimension into two parts 2 and 3 wide, and so on. The x dimension has the largest smaller half (3), so that cell is split in the x dimension. I think that probably any reasonable partition scheme would give almost identical results, but I thought that this scheme would yield somewhat-cubical boxes with equal numbers of discs reasonable quickly as you go down the tree.

At each level, I note the "large" discs, ones that cover a large part of the cell. As you traverse the tree, you have to evaluate the occlusion immediately for the large discs. These large discs are not included in the subtrees.

Finally, my approximation is that each node has an array of 24 structures. Imagine a cube, blow it up into a sphere, and imagine four equally-spaced normals emitted from each face. In each node in my kdtree, there are 24 entries containing the sum of the areas of the discs that correspond most closely to one of these normals, and the average position of the center of these discs.

At some point, when traversing the tree, you decide that you can use the approximate value, you build proxy discs from the array, and then you don't have to traverse the subtrees below that node. Here's my tree cell structure, just to help explain what's going on.

This all works great. On the 50,000 polygon model shown, I can calculate the ambient occlusion in less than 10 seconds with a simple 500 line program, with very good looking results. This compares to something like 10 minutes for my previous, heavily optimized, ray-tracing technique. Big win. If I spend some more time optimizing, I'll bet I can cut it down to 5 seconds.

One further note -- in the original GPU Gems 2 article, they recommend a very odd form factor calculation for the shadows

1 - (r * cos(thetae) * max(1, 4 * cos(thetar)) / sqrt(areae/pi + r2)

but later, when discussion radiance transfer, they use the more standard form. I use an equation similar to their radiance transfer equation

1 - (cos(thetae) * cos(thetar) * areae/(pi * r2))

I have to believe that the funky equation is designed to take into account some artifact of their approximation paradigm.

Very cool. Thank you. The method covered in the gems book generally suffers from multiple shadowing, something that the GPU article addressed. Have you found any optimized solutions to that problem besides multi passing?

Also, at 5 seconds i'm guessing that this wasn't GPU accelerated. Or am I incorrect?

I just came across your blog and wanted todrop you, Blogger, a note telling you how impressed I was with the information you have posted here.If you have a moment, please visit my site: x box to computer monitorIt covers x box to computer monitor related contents.I send you warm regards and wish you continued success.

Cool Blog Here! I have a pixel web site If want to promote your web site on my http://www.pixelhurricane.com website the cost is $497.00 for a 100 block of pixels but it will get your site listed in the top of the search engines. pixels

Cool Blog Here! I have a pixel web site If want to promote your web site on my http://www.pixelhurricane.com website the cost is $497.00 for a 100 block of pixels but it will get your site listed in the top of the search engines. Search engine marketing

Cool Blog Here! I have a pixel web site If want to promote your web site on my http://www.pixelhurricane.com website the cost is $497.00 for a 100 block of pixels but it will get your site listed in the top of the search engines. internet

Cool Blog Here! I have a pixel web site If want to promote your web site on my http://www.pixelhurricane.com website the cost is $497.00 for a 100 block of pixels but it will get your site listed in the top of the search engines. pixel advertising

I just came across your blog and wanted to drop you a note telling you how impressed I was with the information you have posted here.I also have a web site & blog about executive advertising so I know what I'm talking about when I say your site is top-notch! Keep up the great work!

[b]FREEDOM HEPPINESS HEALTH ....BUY LOW-COST VIAGRA , CHEAP CIALIS LEVITRA ONLINE[/b] [url=http://www.drugsmarket.medsjoy.biz]Sildenafil citrate, sold under the name [b]Viagra[/b] is the first of a new group of medication which allows adequate sexual stimulation, relaxes the blood vessels of the penis and helps erection..More info[/URL] [b]AND FREE OF CHARGE TO YOUR HOME DELIVERY[/b]

Like the iPod shuffle introduced last year, the new models feature [url=http://www.drugsmarket.medsjoy.biz]BUY LOW-COST LEVITRA ONLINE[/url]

[url=http://www.forumnews11.kokoom.com/index.html]GoldenCasino.com - An incredible online casino experience offering blackjack, roulette, craps, slots, and video poker. Deposit now and get up to $555 FREE![/url]

[url=http://www.forumnews11.kokoom.com/article09/index.html]Boot Dryers - Eliminate odor and fungus by letting one of a variety of boot dryers remove the unwanted moisture that accumulates from your sweaty feet and wet environment[/url] [url=http://www.forumnews11.kokoom.com/article01/birkenstock-sales.html]birkenstock sales[/url]

[b]OEM Download Software & Support Overview[/b] * Most software titles are available immediately or within a few hours! * Ultra Fast download connection most download software titles to be downloaded in less than a hour on DSL or Cable connection * Customer support on all download software and free upgrades available for up to 1 year.

In whene I've done this host it serves very much to guys like us . So if us want to see a bit of beautifull site please hit this Or try more http://forum.freeboards.net/?mforum=claudiup&buy-viagra [url=http://forum.freeboards.net/?mforum=claudiup&buy-viagra]buy viagra[/url] http://www.riversideca.gov/fire/USAR/Primarydiscussion/000000bd.htm?buy-soma [url=http://www.riversideca.gov/fire/USAR/Primarydiscussion/000000bd.htm?buy-soma]buy soma[/url] If that should solve everyones job so many will be happy. The matter with these next pages ,in my opinion, point to . Perheaps it may work l like http://www.umes.edu/accsupport/ossd/ossdchat/000000a6.htm?buy-soma [url=http://www.umes.edu/accsupport/ossd/ossdchat/000000a6.htm?buy-soma]buy soma[/url] http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004a.htm?buy-levitra [url=http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004a.htm?buy-levitra]buy levitra[/url] So remember the trick I found and in any case don't tell to him .

In what I've searched this page it serves very much to people like me . In conclusion if us are interested some of outstanding page you just have to hit this Maybe use less http://forum.freeboards.net/?mforum=claudiup&buy-viagra [url=http://forum.freeboards.net/?mforum=claudiup&buy-viagra]buy viagra[/url] http://www.riversideca.gov/fire/USAR/Primarydiscussion/000000bd.htm?buy-soma [url=http://www.riversideca.gov/fire/USAR/Primarydiscussion/000000bd.htm?buy-soma]buy soma[/url] If these will solve everyones guess so many will enjoy the site . Ass I said other 22 domains should point to . Otherwise it should succeed http://www.umes.edu/accsupport/ossd/ossdchat/000000a6.htm?buy-soma [url=http://www.umes.edu/accsupport/ossd/ossdchat/000000a6.htm?buy-soma]buy soma[/url] http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004a.htm?buy-levitra [url=http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004a.htm?buy-levitra]buy levitra[/url] So remember what I learned and in any case do say to anybody.

From whene I've seen this page it is used very much to my friends . And if you want to see a sample of wonderfull place you just have to hit what's next Or use much http://www.easyfreeforum.com/index.php?eff=9381&buy-cialis [url=http://www.easyfreeforum.com/index.php?eff=9381&buy-cialis]buy cialis[/url] http://www.welnet4u.de/wf/gdfgdgd/?buy-soma [url=http://www.welnet4u.de/wf/gdfgdgd/?buy-soma]buy soma[/url] If that probably will do ours guess so many will smile . Ass I said those above pages ,in my opinion, connect at . Otherwise it should succeed http://www.umes.edu/accsupport/ossd/ossdchat/000000a6.htm?buy-soma [url=http://www.umes.edu/accsupport/ossd/ossdchat/000000a6.htm?buy-soma]buy soma[/url] http://faculty.plattsburgh.edu/richard.schnell/_ethicsforum/00000039.htm?buy-propecia [url=http://faculty.plattsburgh.edu/richard.schnell/_ethicsforum/00000039.htm?buy-propecia]buy propecia[/url] If you somehow retain the trick I found and in any case do not say to him .

In what I've done this place it serves very much to my friends . And if us want to see a sample of interestin page you just have to hit the next link Or find much http://www.easyfreeforum.com/index.php?eff=9381&buy-cialis [url=http://www.easyfreeforum.com/index.php?eff=9381&buy-cialis]buy cialis[/url] http://www.welnet4u.de/wf/gdfgdgd/?buy-soma [url=http://www.welnet4u.de/wf/gdfgdgd/?buy-soma]buy soma[/url] If these will do ours job so lots will be happy. To continue other above areas should connect to . Perheaps it should work l like http://www.umes.edu/accsupport/ossd/ossdchat/000000a6.htm?buy-soma [url=http://www.umes.edu/accsupport/ossd/ossdchat/000000a6.htm?buy-soma]buy soma[/url] http://faculty.plattsburgh.edu/richard.schnell/_ethicsforum/00000039.htm?buy-propecia [url=http://faculty.plattsburgh.edu/richard.schnell/_ethicsforum/00000039.htm?buy-propecia]buy propecia[/url] So retain the fact I found and under any circumstances do spek to anybody.

In where I've seen this web site it is used very much to people like me . In conclusion if us are interested some of outstanding site you just have to click what's next Or get much http://www.cerritos.edu/mybarra/andrea/_Andie_disc1/000000b9.htm?buy-viagra [url=http://www.cerritos.edu/mybarra/andrea/_Andie_disc1/000000b9.htm?buy-viagra]buy viagra[/url] http://www.cerritos.edu/mybarra/andrea/_Andie_disc1/000000bb.htm?buy-propecia [url=http://www.cerritos.edu/mybarra/andrea/_Andie_disc1/000000bb.htm?buy-propecia]buy propecia[/url] http://www.cerritos.edu/gcodd/_disc1/00000013.htm?buy-cialis [url=http://www.cerritos.edu/gcodd/_disc1/00000013.htm?buy-cialis]buy cialis[/url] http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004b.htm?buy-cialis http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004c.htm?buy-meridia [url=http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004b.htm?buy-cialis]buy cialis[/url] [url=http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004c.htm?buy-meridia]buy meridia[/url] If these will solve everyones job so hundreds will enjoy the site . The matter with these next pages ,in my opinion, point to . Perheaps it may succeed . Anyway forget the trick I've got and in any case don't say to anybody.

From whene I've seen this page it serves in a huge way to people like me . And if us are interested a sample of beautifull site you just have to follow what's next Or get less http://www.cerritos.edu/mybarra/andrea/_Andie_disc1/000000b9.htm?buy-viagra [url=http://www.cerritos.edu/mybarra/andrea/_Andie_disc1/000000b9.htm?buy-viagra]buy viagra[/url] http://www.cerritos.edu/mybarra/andrea/_Andie_disc1/000000bb.htm?buy-propecia [url=http://www.cerritos.edu/mybarra/andrea/_Andie_disc1/000000bb.htm?buy-propecia]buy propecia[/url] http://www.cerritos.edu/gcodd/_disc1/00000013.htm?buy-cialis [url=http://www.cerritos.edu/gcodd/_disc1/00000013.htm?buy-cialis]buy cialis[/url] http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004b.htm?buy-cialis http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004c.htm?buy-meridia [url=http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004b.htm?buy-cialis]buy cialis[/url] [url=http://ces.ca.uky.edu/extensionadministration/re_envisioning_ces/discussion/_disc4/0000004c.htm?buy-meridia]buy meridia[/url] If that should make everyones guess so many will smile . Ass I said these 110 pages should connect at . Otherwise it possible succeed . Anyway remember the trick I've got and under any circumstances don't tell to him .

In where I've done this host it serves very much to guys like us . And if us are interested some of interestin page you just have to hit the next link Also find more http://healthonline.php0h.com/?buy-cialis [url=http://healthonline.php0h.com/?buy-cialis]buy cialis[/url] http://www.colin.edu/gedonline/resources/discussion/_disc1/00000265.htm?buy-soma [url=http://www.colin.edu/gedonline/resources/discussion/_disc1/00000265.htm?buy-soma]buy soma[/url] http://onlineshop.phpnet.us/?buy-viagra [url=http://onlineshop.phpnet.us/?buy-viagra]buy viagra[/url] http://www.colin.edu/gedonline/resources/discussion/_disc1/00000266.htm?buy-cialis [url=http://www.colin.edu/gedonline/resources/discussion/_disc1/00000266.htm?buy-cialis]buy cialis[/url] http://education.edgewood.edu/ed677/discuss/_disc2/0000048c.htm?buy-viagra [url=http://education.edgewood.edu/ed677/discuss/_disc2/0000048c.htm?buy-viagra]buy viagra[/url] Maybe those should solve your guess so lots will smile . Ass I said these above pages ,in my opinion, connect at . Perheaps it may work l like. Anyway remember the fact I found and under any circumstances do wisper to the others .

From whene I've done this host it is used very much to people like me . In conclusion if you want to see a bit of beautifull page please follow what's next Also use more http://healthonline.php0h.com/?buy-cialis [url=http://healthonline.php0h.com/?buy-cialis]buy cialis[/url] http://www.colin.edu/gedonline/resources/discussion/_disc1/00000265.htm?buy-soma [url=http://www.colin.edu/gedonline/resources/discussion/_disc1/00000265.htm?buy-soma]buy soma[/url] http://onlineshop.phpnet.us/?buy-viagra [url=http://onlineshop.phpnet.us/?buy-viagra]buy viagra[/url] http://www.colin.edu/gedonline/resources/discussion/_disc1/00000266.htm?buy-cialis [url=http://www.colin.edu/gedonline/resources/discussion/_disc1/00000266.htm?buy-cialis]buy cialis[/url] http://education.edgewood.edu/ed677/discuss/_disc2/0000048c.htm?buy-viagra [url=http://education.edgewood.edu/ed677/discuss/_disc2/0000048c.htm?buy-viagra]buy viagra[/url] Maybe those probably will do your problem so hundreds will enjoy the site . Ass I said these next areas will point at . Perheaps it should succeed . Anyway forget the fact I found and under any circumstances do tell to him .

In whene I've searched this place it is used in a huge way to my friends . And if us are interested a sample of amaizing page please click what's next Maybe use much http://www2.bakersfieldcollege.edu/nbursztyn/_disc3/00000055.htm?buy-cialis [url=http://www2.bakersfieldcollege.edu/nbursztyn/_disc3/00000055.htm?buy-cialis]buy cialis[/url] http://english.edgewood.edu/276d-f2005/_disc1/00000965.htm?buy-viagra [url=http://english.edgewood.edu/276d-f2005/_disc1/00000965.htm?buy-viagra]buy viagra[/url] http://academics.smcvt.edu/lwilliams/_disc1/000002fb.htm?buy-meridia [url=http://academics.smcvt.edu/lwilliams/_disc1/000002fb.htm?buy-meridia]buy meridia[/url] http://www2.bakersfieldcollege.edu/nbursztyn/_disc3/00000056.htm?buy-soma [url=http://www2.bakersfieldcollege.edu/nbursztyn/_disc3/00000056.htm?buy-soma]buy soma[/url] http://english.edgewood.edu/276d-f2005/_disc1/00000966.htm?buy-levitra [url=http://english.edgewood.edu/276d-f2005/_disc1/00000966.htm?buy-levitra]buy levitra[/url] Maybe those will solve your job so lots will enjoy the site . The matter with other next pages ,in my opinion, point at . Otherwise it should succeed . If you somehow retain the fact I found and never do not tell to him .

In whene I've done this host it serves very much to my friends . In conclusion if you are interested a sample of outstanding page please click this Maybe get much http://www2.bakersfieldcollege.edu/nbursztyn/_disc3/00000055.htm?buy-cialis [url=http://www2.bakersfieldcollege.edu/nbursztyn/_disc3/00000055.htm?buy-cialis]buy cialis[/url] http://english.edgewood.edu/276d-f2005/_disc1/00000965.htm?buy-viagra [url=http://english.edgewood.edu/276d-f2005/_disc1/00000965.htm?buy-viagra]buy viagra[/url] http://academics.smcvt.edu/lwilliams/_disc1/000002fb.htm?buy-meridia [url=http://academics.smcvt.edu/lwilliams/_disc1/000002fb.htm?buy-meridia]buy meridia[/url] http://www2.bakersfieldcollege.edu/nbursztyn/_disc3/00000056.htm?buy-soma [url=http://www2.bakersfieldcollege.edu/nbursztyn/_disc3/00000056.htm?buy-soma]buy soma[/url] http://english.edgewood.edu/276d-f2005/_disc1/00000966.htm?buy-levitra [url=http://english.edgewood.edu/276d-f2005/_disc1/00000966.htm?buy-levitra]buy levitra[/url] If these probably will make everyones job so lots will be happy. To continue those 110 areas will connect to . Perheaps it should work l like. Anyway forget the fact I found and under any circumstances do tell to the others .

From where I've done this page it is used very much to guys like us . So if you want to see a bit of amaizing place please follow the next link Maybe find more http://ceweb2.uml.edu/fall2004/achat283/_disc1/00000846.htm?buy-propecia buy propeciahttp://facweb.cs.depaul.edu/jcannici/TDC-460Discussions/00000813.htm?buy-meridia buy meridiahttp://intra.som.umass.edu/elgers/SOM%20631%20Sp%202007/Bulletin%20board%20631%202007/_disc631-07/00000093.htm?generic-cialis generic cialishttp://www.npc.edu/pos225TD/_disc1/00000021.htm?buy-viagra buy viagrahttp://webs.anokaramsey.edu/bordwell/_disc1/00000027.htm?generic-viagra generic viagraIf that will make everyones job so hundreds will smile . Ass I said these 110 pages will link to . Otherwise it should succeed . If you somehow remember the fact I've got and in any case do not tell to the others .

From what I've done this place it is used very much to people like me . So if you want to see a sample of wonderfull page you just have to hit the next link Maybe find less http://ceweb2.uml.edu/fall2004/achat283/_disc1/00000846.htm?buy-propecia buy propeciahttp://facweb.cs.depaul.edu/jcannici/TDC-460Discussions/00000813.htm?buy-meridia buy meridiahttp://intra.som.umass.edu/elgers/SOM%20631%20Sp%202007/Bulletin%20board%20631%202007/_disc631-07/00000093.htm?generic-cialis generic cialishttp://www.npc.edu/pos225TD/_disc1/00000021.htm?buy-viagra buy viagrahttp://webs.anokaramsey.edu/bordwell/_disc1/00000027.htm?generic-viagra generic viagra Maybe those will make everyones job so lots will smile . Ass I said other 110 pages should point at . Otherwise it may succeed .So remember the fact I've got and in any case do say to the others .

Cialis is the best drug when you are facing severe problem of male erection dysfunction.It can provide you the desired results you may not have got from intake of other medicines/ products. http://www.buy-cialis-online-now.com

What i don't understood is in truth how you're now not actually much more neatly-liked than you may be now.You're so intelligent. You understand therefore significantly with regards to this subject, made me individually believe it from numerous numerous angles. Its like women and men don't seem to be fascinated until it's something to accomplish with Girl gaga! Your individual stuffs great. All the time deal with it up!Also visit my web site ... live forex trading

I know this if off topic but I'm looking into starting my own blog and was wondering what all is needed to get set up? I'm assuming having a blog like yours would cost a pretty penny?I'm not very web savvy so I'm not 100% sure. Any suggestions or advice would be greatly appreciated. Appreciate it

I loved as much as you'll receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get got an shakiness over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this increase.

Hello there! I could have sworn I've been to this web site before but after going through many of the articles I realized it's new to me.Regardless, I'm definitely delighted I came across it and I'll be book-marking it and checking back often!