Maintained by Ray Gardener, Daylon Graphics Ltd. | Download | Latest News | Home



What patches are there?
Latest News
Downloading

What's the OpenGL patch?
How does it work?
How well does it work?
Can I preview any POV-Ray scene?
But why? For God's sake man, why??
The Possibilities
Is this going to be a Daylon Graphics product?
How do I output the OpenGL preview to a disk file?
The OpenGL preview doesn't seem all that fast
The OpenGL preview doesn't quite line up with the raytraced image
What about solid OpenGL drawing?
What about CSG?

The Usual Disclaimer





What patches are there?

So far, there are two: an OpenGL wireframe previewing patch, and a TER format support patch, which lets you directly use TER files (Leveller documents and Terragen terrains) in POV-Ray scenes.
 

What's the OpenGL patch?

The OpenGL patch modifies the Windows version of POV-Ray to use OpenGL rendering. So far, the implemented use is to preview renderings as wireframe representations during parsing. OpenGL is a platform-independant 3D rendering API originally developed by Silicon Graphics.

An interesting and informative comparison between OpenGL and POV-Ray is available here. Instead of taking a one-verus-the-other position, however, the OpenGL patch is meant to bring the two approaches together to gain the benefits of both.
 

How does it work?

In terms of using it, just load up a .pov file in the WinPOV editor like usual, and render it (press Alt-G). The wireframe preview occurs automatically before the raytracer kicks in. Instead of the preview window showing the normal gray-and-white checkboard pattern, the window will clear to solid white and then black wireframe lines will appear as each object is parsed.

Internally, the WinPOV render window allocates an OpenGL render context just before parsing. The parser, when it adds a scene object to the raytracer's bounding slabs tree, tells the object to render itself using a wireframe representation. The methods list for all the primitives has been extended with a wireframe output method, with the default method just drawing the object's bounding box. After parsing, the render context is destroyed. By placing a camera statement before any other scene objects, the OpenGL render context knows where to project scene objects so that they appear correctly.
 

Can I preview any POV-Ray scene?

You can use any scene file, but some will preview better than others. In particular, non-union CSG operations do not preview well. You must also be sure to make the camera object precede all other objects, and to use only perspective cameras.
 

But why? For God's sake man, why??

I was investigating how to mix scanline rendering with POV-Ray to gain the benefits of a hybrid renderer, since POV-Ray currently only uses raytracing. Since OpenGL is readily available under most systems as a reasonably quick (especially when hardware accelerated) scanline renderer, using OpenGL was a logical consequence of saving development time, especially in the early proof-of-concept stages.

One immediate benefit (which has been implemented) is wireframe previewing. This lets us get an idea of what the final scene will look like while adding only a few seconds of time during the scene's parsing stage. If one has misplaced a camera or made some other detectable error, the relatively slower raytracing stage can be immediately aborted.

The pictures below show some examples of what the previewing effect looks like:

It's also nice to be able to use the POV-Ray SDL as a means of generating OpenGL images. It beats firing up a compiler and doing builds every time I want to use the OpenGL API programatically. Modelers are normally used to get scanline benefits, but there are times when I want to use POV-Ray as the modeler (i.e., to generate objects procedurally), and then having OpenGL integrated is useful.
 

The Possibilities

Other possible uses include (but are not limited to):

 

Is this going to be a Daylon Graphics product?

No. I'm just one person with his plate already very full with existing responsibilities, and rendering is too large a problem domain. Since the possibilities are also potentially large but different people want different things, this project is ideally suited to open source development.

 

Okay, it looks cool! I wanna try it (or at least look at the code to make sure you didn't heinously bungle something)

Alright. Depending on what you want to try, just grab:

Instructions and more detailed information are in the patch archives' README.TXT files.

 

How do I output the wireframe preview to a disk file?

The patch doesn't currently do this. It's just drawing directly into WinPOV's render window, not to any offscreen persistent pixel buffer, so the wireframe rendering is lost once the raytracer overwrites it. However, there is a two-second delay after the wireframe is finished, in which you can take a screenshot by hitting the PrintScreen key. The best time to do this is when the text "daylon_StopUsingRenderWnd" appears in WinPOV's message pane.

 

The wireframe preview doesn't seem all that fast.

True, but keep in mind that it is drawing while POV-Ray is parsing. The OpenGL drawing may be moved to occur after parsing (to better fit the POV-Ray rendering model so things like animation would be easier to support), in which case you would see it draw much faster. In fact, if the parsed object tree can be persisted across animation frames, you could render animations quickly, in some cases even in realtime.

 

The wireframe preview doesn't quite line up with the raytraced image.

I believe the problem is fixed now. The June 29/03 version of the patch simply uses a brute-force iteration algorithm to determine what OpenGL FOV angle best matches POV-Ray's apparent FOV. Raytracing the scenes from POV-Ray's $/scenes/advanced/newltpot folder gives an idea how accurate the match is.

Another problem is that some primitive tesselations are wrong (such as the one for cones and cylinders), so the match-up for those objects is botched no matter what.

Here's a "techno" wireframe overlay version of Gilles Tran's nice abyss.pov scene. Before the fix, this level of registration had to manually determined.

 

What about solid OpenGL drawing?

As of June 29/03, the OpenGL patch explicity supports solid rendering. However, it only has tesselators for the sphere primitive, and lights must be point lights and OpenGL materials are forced to specular reflectance with a constant gray color. If you want to do more, however, the hooks and the depth buffer are there.

 

What about CSG (constructive solid geometry)?

Fair is fair. No discussion of POV-Ray is complete without CSG.

CSG is by its very nature almost trivially easy for a raytracer to do, and consequently, almost impossible to get a mesh equivalent. It's just the nature of the beast. However, if we're only rendering, a scanline approach can be done easily through primitive dicing recursion. The following images were done with OpenGL, with a recursion depth of ten:


Cube with its corner subtracted by another cube


Cube with its corner subtracted by a small sphere


Cube with its corner subtracted by a large sphere.
One side has an error because only triangle vertices are considered by the inclusion test. Increasing the initial tesselation is one way to reduce the error.


Small sphere subtraction, with subtriangle surface normals generation corrected for proper lighting. Making the cube appear solid is simply a matter of tesselating the sphere and intersecting it with the cube, with surface normals inverted since the sphere's "inside" is on the cube's "outside".


Cube with spherical subtraction.
The wireframe view shows the recursive tesselation effect.

The caveat with this approach (like raytracing with high sampling) is that expensive interior determination calls will degrade performance significantly. For simple shapes, performance is quite good; the above pictures were rendered without hardware acceleration in only a second or two. Complex shapes such as noise-based isosurfaces would take much longer.

 

Latest News

July  1/2003: SOR and parametric object wireframe tesselation supported; 
              available later.

June 29/2003: Fixed the cone/cylinder misprojection; available later.
              If you need it sooner, use these lines in cones.cpp's wireframer:

                DBL br = Cone->base_radius / Cone->apex_radius;
                DBL ar = 1.0;

              Added allobjects.pov test suite comparison.


June 29/2003: OpenGL camera accuracy just about perfect; OpenGL output 
              registers with raytraced imagery almost pixel-for-pixel.
              Solid scanline rendering available too (spheres only for now).

June 28/2003: Web page spruced up with more info.

June 21/2003: Initial experiments with recursive CSG tesselation algorithm 
              (see the "What about CSG?" topic for details).

June 16/2003: OpenGL patch: box, bicubic/bezier patch, disc, and torus 
              primitives now have specific tesselators. Non-union CSG groups 
              are iterated/recursed, but this has not been tested.
              TER patch: will not function unless "#version unofficial 3.5"
              directive used.


June 15/2003: OpenGL patch: 

                Perspective camera emulated properly; error 
                reduced to just a few screen pixels.

                Bezier patch primitive includes missing default 
                wireframing method; fixes crashing when rendering
                scenes with bezier patches such as teapot.pov.

             
June 14/2003: OpenGL patch: Plane, mesh, and lathe primitives
              now have specific tesselators.

June 13/2003: TER format patch added; website reorganized.

June 11/2003: OpenGL patch: Triangles, cones, polygons, and heightfields 
              now have specific tesselators.

 

The Usual Disclaimer

The code is still under development and is not warranted nor supported by me or by Daylon Graphics Ltd. Don't bother the POV-Team about it either, they're not responsible in any way.