Progressive Refinement Patch for POVRayThe PRT patch draws a progressively refining bilinearly interpolated preview and enables you to select regions to be traced by POVRay using the mouse. Patch against UNIX POVRay-3.6.1.
News
The idea...The idea behind PRT is quite simple: Those regions of an image which have a higher color variation are normally the more interesting parts while the ones with little color variation can easily be interpolated. This sounds a bit like the IPT patch written by me, but in contrast to IPT, PRT will have traced all pixels in the end and thus deliver the same image as normal POVRay. So, PRT will first trace a grid of typically 12x12 pixels and display a bilinearly interpolated preview. It will now go on and sub-divide these 12x12 tiles and thus progressively refining the preview. The major trick is, that those tiles which have the largest color variation get refined first. Furthermore, the user may manually tell the PRT patch which parts to trace first by pressing (and possibly dragging) the mouse in the POVRay window. In the end, each pixel of the image was traced exactly once (and no additional pixels were traced). ...and the implementationPRT requires that the complete image is held in core memory. While this is also true for the standard POVRay X11 display, PRT needs to store the image in better quality than 24 bit RGB. Currently, the image is stored using 6.25 bytes per pixel which includes 16 bit per color channel and a 2 bit (not byte) trace flag. Furthermore, the tile heap must be stored; each tile normally occupies 16 bytes on a 32-bit box. It is clear that PRT cannot write the image data to file before the image is completely rendered. As a consequence, I decided that PRT should save the current image (i.e. with interpolation) in case it is aborted (using e.g. Control-C). Consequently, you cannot continue aborted traces. Detailed descriptionThe image is divided into tiles, initially normally of size 12x12. Each tile has the egde pixels traced (3 of the 4 traces egde pixels actually belong to neighbouring tiles unless the tile hits the viewport border). Using the color values of these 4 pixels, the complete tile can be be bilinearly interpolated. The standard deviation of the color of these 4 pixels (summed up over all color channels) together with a tile size factor make up the interest value. All tiles get pushed on a heap.
The main rendering loop (after the initial pass) takes the most
interesting tile from the heap and divides it along the
longer border into two sub-tiles. Each sub-tile has the 4 border pixels
rendered (3 of these are again actually outside the tile...), is
re-displayed with updated interpolation and then inserted into the heap
again. In case the tile is too small (less than
4x4 normally), it is not divided but instead traced completely and
removed from the heap. Tracing is over when no tile is left in the heap.
You may click on some position in the window and thus have a region
around the mouse position traced. The size of the region depends on
the mouse button (normally 16,32,64 for buttons 1,2,3). What internally
happens is that the tile gets added to a list of manually generated tiles. What is it good for?
PRT should enable you to see the interesting parts of the image more quickly.
Bugs: Download and Install
Download:
PRT can only be obtained as patch against UNIX POVRay-3.6.1.
Install:
First, patch your POVRay-3.6.1 using patch(1). Activate: The PRT-patched POVRay will behave exactly like the non-patched. To enable PRT, pass +AM4 on the command line. Usage (important)PRT is easy to use. In ordet to enable it, you have to pass +AM4 on the command line. During rendering, it knows the following keys and buttons:
Performance and overheadConcerning performance (rendering speed), the patch has little impact. Of course, all the intepolation and constant screen updating does introduce overhead but PRT does never trace pixels more than once so that in the end you're better off with PRT than with mosaic preview, even if you stop mosaic preview before the 2x2 pixel size. As an example, these are the timings of a 320x320 trace of an isosurface (actually Alex Kluchikov's "favourite isosurface" which can also be seen on the bottom of this page). The timings were done with POVRay-3.6 compiled with gcc-3.4.1 on AthlonXP 1.47GHz running Linux. The displayed time is the elapsed (real) time on an idle system.
The other main point is memory consumption. Keep in mind that PRT needs to save the complete image in memory which is currently 6.25 bytes per pixel and additionally needs the tile heap to store all the not-yet-rendered regions of the image. These are values for two typical scenes ("spy probe robot" and "architecture"; both can be seen in the examples section) at different resolutions:
Given the amount of memory in current computers, <1Mb for a 400x300 image and <4Mb for 800x600 used by PRT is still acceptable. Note that memory consumption scales linearly with image size (i.e. number of pixels), so for larger images quite a lot of memory will be consumed. But since PRT is thougt for the design and not for final renderings, this should not be a problem. Example scenesNow after having talked such long it's time to have a look at some real results and images. Note: These images are examples of the POVRay-3.5 version of the patch. The current version only differs in the images by using a checkered background instead a plain black one. The images below show an object I call "spy probe robot", after tracing only 3% (top), 20% (center) and the complete image (bottom). The right column shows traced pixels and the left one the bilinearly interpolated image based on these pixels. (You can switch between these using the 't' key.) Of course, no manual refinement using the mouse was done.
Another scene of a tower-like architecture. This is a typical modelling
scene where the background objects have plain colors for better visibility of
CSG operations and where I am currently adjusting the texture on the the
foreground tower and passway.
When using the mouse, you can manually select regions to be traced. Just to give you a clue, I "painted" some part of the scene below and saved two incomplete snapshots: one with traced pixels only and one with interpolation (note that I marked slightly different regions in these images). The images show Alex Kluchikov's "favourite isosurface".
|