PATCH: improved anti-aliased rendering
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
The current anti-aliased rendering in VTK implemented in vtkRenderWindow::DoAARender() leads to unwanted jittering of the whole rendered scene. This is a result of the random camera offsets used, which are not guaranteed to be equally distributed over all possible offset directions. The end-result of this is that entire scene can end up "jumping around" in random directions over a 1 pixel distance per frame, even in the case of an unchanging dataset being rendered from the same viewpoint. This is especially noticeable at lower frame resolutions.
At http://staff.science.uva.nl/~paul/vtk_aa/ I have added some examples of different numbers of AA frames for the same scene. Each shows sequential frames for a static dataset rendered from a fixed viewpoint, i.e. any jitter in the frames comes from either VTK's rendering or from video compression of the resulting AVI's (DivX). With 0 AA frames, the model stays completely still, as expected. This also shows that any jittering doesn't come from the video encoding. With 5 AA frames using VTK's current sampling the model jumps noticeably around in the image. With 4 AA frames using the improved sampling the model is already more stable. At 10 AA frames using the current sampling the model is still jumping around, with 9 AA frames using the improved sampling the model stays almost completely still (which can also be seen by the size of the encoded AVI's, as less jittering leads to less inter-frame pixel differences and therefore less bits needed per encoded frame). At 15 AA frames using the current sampling the model is still not completely visually stable, at 16 improved AA samples the jumping around is almost not noticeable.
This patch improves on that by guaranteeing that camera offsets used for the different AA subframes are distributed more equally over the set of possible directions. A regular grid of camera offsets is generated, spanning the set of offsets of [-1/2,1/2] for both X and Y direction. The regularly spaced offsets are then jittered by a small amount.
The patch only uses this different sampling strategy when the number of AA frames is a square number (e.g. 9 samples, resulting in a 3x3 grid) for which a regularly grid can easily be constructed. For other values of the number of AA frames, the currently present sampling is used.