Meshwork and POV-Ray

Using Meshwork and POV-Ray for photorealistic rendering

POV-Ray is an extremely powerful and (amazingly enough) free ray-tracing application that runs on many platforms. It generates very high-quality output and supports advanced features like transparency, refraction, non-uniform fog, atmosphere effects, and much more. Most POV-Ray users generate their scenes by writing code directly in POV-Ray's scene description language, which works well for relatively simple shapes like boxes, ellipses, and planes. But for more complex shapes, a 3D modeling program is indispensable.

That's where Meshwork comes in. Meshwork allows you to build complex shapes graphically, with a simple blueprint-like interface and a 3D preview that allows you to see your model from any angle as you work on it. Once satisfied with the model, you can export it to a POV-Ray file, include it in your POV-Ray scene, and generate a high-quality rendering.


What You'll Need

  1. POV-Ray, and a little knowledge of how to use it (it comes with great documentation and tutorials). Also see the Official POV-Ray for Mac OS site.

  2. Meshwork (of course!).

  3. (optional)a text editor such as BBEdit Lite.

  4. (optional) a graphics utility such as Graphic Converter.


Creating the Model

Create (or import) your model in Meshwork, such as the example shown in Figure 1. For this example, I'm using a rose which was imported from 3DMF and cut down to just the flower.

Then, choose Export > POV-Ray. The result is a POV-Ray include file -- just a text file containing POV-Ray code. My example was exported to a file called rose.inc.


Attaching the Textures

Open your POV-Ray include file with a text editor, and do a search on the word "texture". If your model uses any textures, you'll find some code that looks something like this:
	pigment { image_map {png "texture2.png" map_type 1}
When Meshwork exports to POV-Ray, it doesn't know how you'll want to name your texture files. So it uses a simple pattern: the first material (colored white by default) is called "texture0.png". The next one is called "texture1.png" and so on. In other words, Meshwork assumes you have texture files, stored in PNG format, with numbers that correspond to the Meshwork material used.

To finish the POV-Ray model, you have two choices:

  1. Supply textures with the names used by Meshwork, or
  2. Change the filenames in the include file to match texture files that actually exist.

(In a future version of Meshwork, you'll be able to specify "material names" to be used as texture names in the POV-Ray export, making this step unnecessary.)

For this example, I chose to take the second approach. I changed the line of code above so that it now reads

	pigment { image_map {png "texture-green.png" map_type 1}
...and I made sure that, in the same folder as the include file, I had texture-green.png ready. (The Mac version of POV-Ray can read PICT files, but PNG is more standard in the POV community, so I used GraphicConverter to save my textures in that format. This way, the whole model could be zipped up and sent to someone using POV on some other platform if desired.) I then found the next occurrance of the work "texture", and made it refer to "texture-red.png".

Save the include file after making any changes, and launch POV-Ray.


Building the POV-Ray Scene

Next, you need to create a POV-Ray scene file. This is where you lay out the various objects in your scene, including the camera, lights, background, and so on. The Mac version of POV-Ray has a Templates menu to help you get started; I used the "Basic Scene" template as the basis for my example. After some tweaking and experimenting, rose.pov was ready to go.

There are several things worth noting in this file. First, the include file is loaded and made into an object as follows:

#declare Rose = union {	
	#include "Rose.inc"
}
The "union" is needed if you're using Meshwork 1.4.1 or earlier; as of Meshwork 1.5, it can be omitted. Second, Meshwork models tend to be hundreds of units tall, whereas the standard POV objects are about 1 unit high. So you'll probably want to scale your object down by a factor of 0.01 or so.


Render

First, check your rendering preferences (command-Y in POV-Ray). This is where you set the output dimensions, rendering quality, output format, and so on.

After setting up the scene and the rendering preferences, hit command-R in POV-Ray to render. My example came out like this:

The textures are subtle, but they are clearly there; they give the image a realism that could not be obtained with solid color.

There is still a lot that could be done to improve this image in terms of composition, background, and so on. But as a demonstration of using a Meshwork model in POV-Ray, our rose has done its job beautifully.


If you have any difficulties, write to me or the Meshwork Discussion List.


http://www.strout.net/macsoft/meshwork/povray.html
Last Updated: 2/24/00 . . . . . . webmaster@strout.net