changelog:
1.0.4
* added some more checks for XML parsing.
* changed texturing code a bit (faster)
* added aperture_diffraction toggle in infile.
* added aperture_shape camera XML element
* added obstacle_map camera XML element
* fixed error handling when parsing camera response functions.
The main new thing in v1.0.4 is new aperture code, and the related aperture diffraction code.
Aperture shape
The camera XML element now takes an element called 'aperture_shape', that defines the shape of the camera aperture.
The first type of aperture shape is the circular (disc) aperture. If the aperture_shape element is missing, this is assumed as the default.
Code: Select all
<aperture_shape>
<circular></circular>
</aperture_shape>
Code: Select all
<aperture_shape>
<generated>
<num_blades>6</num_blades>
<blade_offset>0.4</blade_offset>
<blade_curvature_radius>3.0</blade_curvature_radius>
<start_angle>0.2</start_angle>
</generated>
</aperture_shape>
The third type of aperture shape just reads a .png image from disk to use as the aperture visibility map. White = light can pass thru, black = blocked.
the image must be square, power of 2 width and height, and be at least 512*512.
The path is absolute or relative to scene file dir.
Code: Select all
<aperture_shape>
<image>
<path>indigo_aperture.png</path>
</image>
</aperture_shape>
The final aperture size is determined by two factors - the shape defined by the aperture_shape element, and the aperture_radius camera parameter.
In effect, the overall aperture size is multiplied by aperture_radius.
Aperture_radius should really be called 'aperture half width', because it affects the overall scale of the square aperture visibility map.
When creating an aperture map, try and make the white area as similar in area to a disc touching the edges as possible. This will mean that the overall image intensity won't change too much when changing aperture shapes. Use the aperture_radius camera parameter as before, to let more or less light in.
Aperture diffraction
When light (or any wave) passes through a small gap, such as a camera aperture, it spreads out or 'diffracts'. The pattern in which it spreads out depends on factors such as the shape of the aperture and the wavelength of the light. This is a fundamental physical effect which gives a limit on the resolution of optical devices that use apertures (cameras, telescopes etc..)
Such diffraction is also responsible for the glare around bright light sources in photos. Depending on the shape and symmetries of the aperture, different patterns of glare will be apparent.
The new glare stuff in Indigo is based on the paper 'Glare Generation Based on Wave Optics' http://nis-lab.is.s.u-tokyo.ac.jp/nis/abs_cgi.html
which points out that such a diffraction pattern can be calculated using the 2d Fourier transform of the aperture map.
Aperture diffraction is simulated by perturbing rays as they pass through the camera aperture, thanks to Robin Davies for articulating this idea.
An alternative implementation of physically-based diffraction glare could convolve the frame buffer with the diffraction filter as a post-process; I have implemented this, but I currently prefer the non-post-process technique, because you don't have to wait for the convolution, and the results are more realistic because full spectral sampling can be used, whereas a post-process has to work on a 3-component image buffer.
To enable aperture diffraction, set
"aperture_diffraction" "true"
in the inifile.
There is something like a 10% performance penalty (depending on scene) for enabling diffraction, as some non-trivial code has to be executed for each light path.
As per the paper 'Glare Generation Based on Wave Optics', you can specify an (optional) obstacle map in the camera XML. The obstacle map will affect the diffraction pattern.
Use like this:
Code: Select all
<obstacle_map>
<path>diag_obstacle.png</path>
</obstacle_map>
The path is absolute or relative to scene file dir.
When Indigo executes, it will save a couple of files to the indigo dir: aperture_preview.png and diffraction_preview.png, which help you to get an idea of the shape of the aperture and of the diffraction pattern.
Attached are a couple of demonstration images.
The airy_disc image demonstrates diffraction from a circular aperture for monochromatic light.
If you do the maths for the pixel radius of the first Airy disc zero, based on the camera geometry, it should come out as 8.47 pixels, which you can confirm in the image.
See airy_disc_test.igs.
The second image demonstates diffraction from a curved hexagonal aperture, with a regular obstacle map.
See diffraction_test.igs.
Phew, think that about sums it up