EfficientlyCachingIrradiance

From PixieWiki

Jump to: navigation, search

This tutorial shows you how constructing an irradianche cache in order to use less memory ressource without the detriment of the rendering quality.

Because you use a two-pass approach for rendering some GI scenes out, the idea is to offer more control in terms of construction of a cache using a smaller resolution, and a higher resolution that reads it in.

[edit] Shading Rate

A shading rate of 0.2 is pretty low. Pixie will have to dice objects up very small to meet this shading rate requirement. Also, each shading point may introduce a new cache sample, which (depending on the other settings) will make the cache fill up quicker. Edge antialiasing will still occur.

If possible, try a default shading rate of 1 or higher.

"ShadingRate" is effectively an attribute - so it can be set per object. It is usually worth setting it higher for large objects which have slowly changing shading values.

[edit] Irradiance Attributes

Also the irradiance atributes can be set per object, so you can have multiple caches per scene (which can help manage the cost), or altering the maxerror (which allows you to tweak the irradiance sampling rate per object).

[edit] Arguments to the irradiancecache shadeop

The number of samples passed to occlusion or indirectdiffuse control how accurately the hemisphere above the shading point is sampled - and hence how accurately the angular and positional gradients over the hemisphere will be calculated. This should be something like 256. Pixie will not necessarily go and sample a hemisphere if it can interpolate accurate enough information from the existing cache samples. That is what maxError controls.

The minR and maxR paramaters to the GI shadeops control minimum and maximum spacings between cache samples - values inbetween will still be interpolated but not necesarily stored.

I found values of minR=4 maxR=10 kept the samples spaced more evenly - though perhaps you may be able to have maxR higher or even leave it at it's (infinite) default. Increasing minR will also prevent samples getting too close. In other words, these two bound the distance between cache samples and help guide Pixie in choosing which samples should go in the cache.

Sometimes the render may have minor artifacts, then the bias needs altering too.

In conclusion, with a two pass approach I'd advise a low-res render to bake the GI then a pass that uses filemode "R" for the fastest render at high-res using the cache. If needed, filemode "r" will allow improvements over the cache contents, but is slower.



On minR and maxR- these are now gone. The parameter maxR is approximately replaced with maxpixeldist (there's an attribute and you can pass the argument to occlusion() and indirectdiffuse() directly). This is approximately the maximum screen space distance between cache samples.

The minR parameter is somewhat useless now that we have better regulation of the cache density, it used to control the maximum density (via the minimum radii between samples) of the cache. It is now indirectly controlled by setting the bias. You can also send "bias",<value> to occlusion() and indirectdiffuse() directly.

Decreasing maxpixeldist will increase the sample density. Decreasing maxError (typically ~0.1) will also improve the accuracy of the cache - but this is not the same as making it more dense everywhere - for that use maxpixeldist. Most of the time where occlusion / irradiance changes slowly there is no need to make the samples more dense. It's only in rapidly changing areas (eg corners) that you need more samples - which is what maxError controls.

MaxError will increase the quality the result, by limiting the frequency at which existing samples are reused and interpolated from. Where interpolation is not done, a new sample will be created. So importantly, it controls the density of the samples near rapidly changing areas. The results of sampling are interpolated from a sampled hemisphere - each sample is a ray which are used to determine the color / visibility in that direction. The number of samples is the argument you pass to indirectdiffuse() or occlusion(). So it's important that these samples themselves are accurate. Increasing the number of samples / rays will give more accurate estimates of the occlusion / irradiance and will help improve your image quality.

Prefer firing more samples to decreasing maxError. Once you start to get better results with increased samples, then decrease maxError. You can tune flat areas with maxpixeldist.

The trace bias is important because it specifies how small a nearby feature a rays can get into. With too large values, you may see white lines / patches in the corners. There are fundamentally two reasons why these types of artifacts occur.

Imagine a T shape


-------------------- 
          |* 
          |  
          | 
          | 
          | 

And trying to sample the hemisphere at the point marked *. One problem can be caused by larger ray biases preventing rays 'getting into' the area in the corner. These rays will count as if they hit nothing (or something far away) and will result in occlusion values that are way too low. Reducing the bias forces the rays into these areas / allows them to intersect at shorter distances.

Another issue is this type of thing:


-------------------- 
            * 
          | 
          | 
          | 
          | 
          | 

Where two surfaces do not fully meet. The rays will 'leak'. This cannot be fixed with the bias.

One thing that seriously reduces these kind of artifacts is to ensure that ground planes etc are solid geometry rather than single planes. Make your geometry two sided, and leaked rays will no longer matter so much.

One more thing that you should avoid where possible is using faceforward to generate the normal for occlusion() this leads (by design) to a discontinuity in the normal which can cause some artifacts with the occlusion caching.

Personal tools