Menu

Home

Patrik Andersson

SPherical Image Library (SPI)

SPherical Image Library (SPI) provide render-engines with a more uniform quality environmental maps, by using the spherical coordinates. It also contain some simple function for blur between these spherical coordinates, to create soft shadows for eg. point-lights.

Original Blur Depth blur
(Original) (Blur) (Dist blur)

Development status

The library can read and write to 8-bit grey TIFF files. It can blur a pixel on the sphere depending by a given angle. It is possible to fill a neighborhood to a pixel with a certain value. Currently the spherical neighborhood is defined by a geometric approach by using linear algebra.

It is possible to blur the picture depending on the spherical neighborhood. There is also an advanced option which shall blur depending on the variance of the neighborhood.

Further things to improve is to use multiple layers (RGBA+...), create its own file-format and of course optimizing the code.

There is an idea of writing a simple raytracer to evaluate this approach since it appears not to be as so fast as wanted.

Source code is available in the src-folder under the file tab.

Background

Cubic and longitudinal maps do contain uneven quality and stretched pixels depending on where in the quadrant or how close you are to the poles when evaluating the coordinate. To get around that, so every pixel does have a more even quality, one could consider a sphere and evaluate all directions evenly over the surface, and just store them.

So in the library the resolution is defined as the radius of the sphere,

Width = (int) round(2*PI*res);
Height = PI*res;
for (i =0;i<2*res;i++)
{
n = (int) round(2*PI*res*sin(i*PI/(PI*res-1)))+1;
layer->image[i] = (uint8 *) calloc(n,sizeof(uint8));
}

When computing an environmental map or depth of field map, one might use it as shadow map with a point-light. Often shadows become very sharp with shadow and it might not be the as the artist want. Therefor SPI have built in functions for smoothing with and without regarding to the change of depth. The example below shows three SPI images which were exported to TIFF and then saved as PNG. The first one is the original, the second one is an example of blur/smoothing and the third one is an example of blur/smoothing depending on variance of the depth in the neighbourhood.


MongoDB Logo MongoDB