Implementation of Irradiance Caching in Radiance

Implementation of Irradiance Caching in Radiance Implementation of Irradiance Caching in Radiance

cgg.mff.cuni.cz
from cgg.mff.cuni.cz More from this publisher

<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

<strong>Implementation</strong> <strong>of</strong> <strong>Irradiance</strong><br />

<strong>Cach<strong>in</strong>g</strong> <strong>in</strong> <strong>Radiance</strong><br />

Greg Ward<br />

Dolby Canada


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

<strong>Irradiance</strong> Cache<br />

Enhancements <strong>in</strong> <strong>Radiance</strong><br />

1. Computation <strong>of</strong> ambient “constant”<br />

2. Adaptive super-sampl<strong>in</strong>g on hemisphere<br />

3. Maximum and m<strong>in</strong>imum record spac<strong>in</strong>g<br />

4. Gradient limit on record spac<strong>in</strong>g<br />

5. Bump maps us<strong>in</strong>g rotation gradient<br />

6. Options for exclud<strong>in</strong>g surfaces/materials<br />

7. Record shar<strong>in</strong>g for multiprocessors<br />

8. Record sort<strong>in</strong>g for cache coherency


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Computation <strong>of</strong> Ambient<br />

“Constant”<br />

• So-called “ambient term” approximates<br />

the rema<strong>in</strong>der <strong>of</strong> an <strong>in</strong>f<strong>in</strong>ite series<br />

• An average <strong>of</strong> top-level <strong>in</strong>direct<br />

irradiances is a good approximation<br />

• A mov<strong>in</strong>g average may be used as the<br />

irradiance cache is filled over time<br />

• Over-estimat<strong>in</strong>g ambient term is worse<br />

than under-estimat<strong>in</strong>g<br />

The -aw option <strong>in</strong> <strong>Radiance</strong> controls this function. As <strong>in</strong>direct values<br />

are collected, they overtake the <strong>in</strong>itial, user-specified ambient term. It’s<br />

one <strong>of</strong> those features that seemed like a good idea at the time, but <strong>in</strong><br />

practice it doesn’t get much use.


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Adaptive Super-Sampl<strong>in</strong>g<br />

• To maximize accuracy <strong>of</strong><br />

<strong>in</strong>direct irradiance <strong>in</strong>tegral,<br />

super-sample high variance<br />

regions<br />

– Detect variance based on<br />

neighborhood<br />

• Sample until error is uniform<br />

over projected hemisphere or<br />

sampl<strong>in</strong>g limit is reached<br />

Controlled by the -as option <strong>in</strong> <strong>Radiance</strong>, this <strong>of</strong>ten-used optimization is<br />

especially effective <strong>in</strong> bright, daylighted <strong>in</strong>teriors.


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Maximum and M<strong>in</strong>imum<br />

Record Spac<strong>in</strong>g<br />

• Without a m<strong>in</strong>imum record spac<strong>in</strong>g,<br />

<strong>in</strong>side corners get resolved to a pixel<br />

level<br />

• Apply<strong>in</strong>g a m<strong>in</strong>imum spac<strong>in</strong>g, accuracy<br />

gradually rolls <strong>of</strong>f at a certa<strong>in</strong> scene<br />

scale<br />

• A maximum value spac<strong>in</strong>g <strong>of</strong> 64 times<br />

the m<strong>in</strong>imum spac<strong>in</strong>g seems about right<br />

If available, ray pixel size may also be used to adjust record spac<strong>in</strong>g,<br />

though this would tend to underm<strong>in</strong>e view <strong>in</strong>dependence.


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Gradient Limit on Record<br />

Spac<strong>in</strong>g<br />

• The gradient does not control spac<strong>in</strong>g<br />

unless ||gradient||*radius > 1<br />

• Then, to avoid negative values and<br />

improve accuracy, we reduce radius to<br />

1/||gradient||<br />

• If we have reached the m<strong>in</strong>imum<br />

spac<strong>in</strong>g, then reduce the gradient,<br />

<strong>in</strong>stead<br />

It is important *not* to use the gradient to determ<strong>in</strong>e record spac<strong>in</strong>g <strong>in</strong><br />

general, as we cannot know what the gradient is before sampl<strong>in</strong>g, and<br />

we don’t know how <strong>of</strong>ten to sample if the gradient dictates spac<strong>in</strong>g. It is<br />

better to use a conservative metric that doesn’t depend on actual scene<br />

radiances, which may or may not behave as expected.


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Bump Maps Us<strong>in</strong>g Rotation<br />

Gradient<br />

• Bumpy surfaces reduce record shar<strong>in</strong>g<br />

• Ignor<strong>in</strong>g bump map, we can apply rotation<br />

gradient for irradiance just calculated<br />

• This promotes optimal reuse and spac<strong>in</strong>g<br />

It also avoids the problem<br />

<strong>of</strong> sample leaks<br />

No-cost addition to irradiance gradient calculation -- just apply the<br />

perturbed surface normals on the f<strong>in</strong>al <strong>in</strong>terpolation.


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Options for Exclud<strong>in</strong>g<br />

Materials<br />

• User-selected materials (and the surfaces<br />

they modify) may be excluded from <strong>in</strong>direct<br />

• This saves hours <strong>of</strong> po<strong>in</strong>tless <strong>in</strong>terreflection<br />

calculations <strong>in</strong> fields <strong>of</strong> grass, etc.<br />

• If only a few materials are to be <strong>in</strong>cluded, an<br />

<strong>in</strong>clude list may be specified, <strong>in</strong>stead<br />

• It would be better to have a second type <strong>of</strong><br />

<strong>in</strong>terreflection calculation available<br />

The -ae option excludes a s<strong>in</strong>gle material (and its assigns), whereas -<br />

aE excludes all materials listed <strong>in</strong> a file. The -ai and -aI options may be<br />

used to specify <strong>in</strong>cluded materials, <strong>in</strong>stead.


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Record Shar<strong>in</strong>g for<br />

Multiprocessors<br />

• In addition to reus<strong>in</strong>g records for subsequent<br />

views, irradiance cache files are used to<br />

share records between multiple processes<br />

• Synchronize: lock→read→write→unlock<br />

• Records from other processes are read <strong>in</strong>,<br />

then this process’ new records written out<br />

• NFS lock manager not always reliable<br />

This technique works with a fixed buffer size <strong>of</strong> about 13 records up to<br />

10 processors or so, then a larger buffer works better. At some po<strong>in</strong>t, I<br />

would like to implement a client-server or broadcast model to reduce<br />

overhead and avoid problems with NFS.


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Record Sort<strong>in</strong>g for Cache<br />

Coherency<br />

• Indirect records storage and access may be<br />

poorly correlated<br />

– Causes poor VM coherency and performance<br />

• Sort<strong>in</strong>g records from most- to least-recently<br />

used improves access coherency<br />

• <strong>Radiance</strong> does this at <strong>in</strong>creas<strong>in</strong>g <strong>in</strong>tervals<br />

dur<strong>in</strong>g <strong>in</strong>direct record accumulation<br />

There are additional caveats <strong>in</strong> cases where <strong>in</strong>direct values are be<strong>in</strong>g shared.<br />

S<strong>in</strong>ce a field is stored <strong>in</strong> each record for when it was last used, and chang<strong>in</strong>g<br />

this would underm<strong>in</strong>e value shar<strong>in</strong>g, we turn this optimization <strong>of</strong>f when more<br />

than a third <strong>of</strong> the records are be<strong>in</strong>g shared across processes. The biggest<br />

sav<strong>in</strong>gs occur <strong>in</strong> processes that exceed physical memory, which causes VM<br />

thrash<strong>in</strong>g.


<strong>Irradiance</strong> <strong>Cach<strong>in</strong>g</strong> Class August 2008<br />

G. Ward<br />

Conclusions<br />

• <strong>Irradiance</strong> cache was implemented <strong>in</strong><br />

<strong>Radiance</strong> around 1986<br />

• First SIGGRAPH submission was<br />

rejected, and paper was completely<br />

rewritten (twice)<br />

• Ref<strong>in</strong>ements have been few and subtle<br />

• C code is about 1500 l<strong>in</strong>es <strong>of</strong> 30,000 <strong>in</strong><br />

<strong>Radiance</strong> render<strong>in</strong>g eng<strong>in</strong>e

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!