--------------------------------------------------------------------
PARTMAN - Your source for rendering LOTS of particles
usage:
partman -p -e [-g ] [-v]
[-f -l -i ] [-s ] [-T -t ]
= name of file containing rendering parameters
= name of cinesite file with geometry data
= parameters passed to the PDB editor
OPTIONAL PARAMETERS
= first frame number
= last frame number
= frame number increment
= Divide up image plane into this many tiles
= Render this tile
= Filename of surface shader
-v Turns on image statistics after render completes.
--------------------------------------------------------------------
An example of its usage is:
partman -f 3 -l 100 -i 2 -p example2.jpa -g water_test2.cig -e"-i /data/3d/IB/9999/CG/water_test/pdb/particleShape1 -p ibemit2 -V rgbPP -R radiusPP -A "
This example illustrates most of the command line options in partman. There are options for controling the frame range, the camera and scene data, the particle "editing" process, and finally an option for shading the surfaces of the particles. the options related to tiling are not guaranteed to work.
The first command line options are just the standard frame range specifiers -f, -l, and -i. These limit the range of frames rendered between the first (-f), the last (-l), and increment in steps (-i). If the -l option is omitted, only one frame (the -f frame) is rendered.
Although not really supported, the tiling options allow you to break up the image plane into virtical strips, the total number of which is fixed by the -T option. The purpose of dividing up the image plane this way is to allow partman to render only one of these tiles, the one designated in the -t option.
The -p option on the command line designates the .jpa file that partman is to use. The jpa file controls the overall rendering characteristics that are specific to partman, and which are not provided in other input files. Primarily, the jpa contains information on some aspect of rendering surfaces, shadow maps, image size in pixels, image file format, the channels to be rendered, and the channels to be output to a hdf file. More detail is provided in a later section below.
The -g option designates the .cig file that partman is to use. These files are generated from Maya using mayaMonkey, and contained multiple frames of ascii data for cameras, lights, and nurbs surfaces and curves. So when rendering the particles from a maya scene, you should use dynExport to extract the particle data into pdb files, and mayaMonkey to extract the remaining relevant information into cig files. More detail is provided in a later section below.
The -s option allows you to provide a file containing a surface shader which partman will use to render the particles. If the -s option is not used, there is a simple default shading applied. The contents of the shader file are defined in more detail in later section.
The -e option provides a double-quoted string, the contents of which are a command-line-like set of options for the pdbEditor to apply in order to read pdb files and spawn child particles for rendering. The meaning of these input options are discussed in a later section.
// Part (1) the INCLUDE info
#include "partmanInputTypes.h"
// ----------------------------------------------
// Part (2) the CONTROL info
ControlInfo control;
control . RenderSurface = 5;
control . UseGeometryLights = 1;
control . UseGeometryCamera = 1;
control . DoMotionBlur3D = 0;
control . DoMatteErosion = 0;
// ----------------------------------------------
// Part (3) the CAMERA info
CameraInfo cameraInfo1;
cameraInfo1 . ApplyPSF = 0; // 1=boxcar, 2= bartlett, 3=gaussian
cameraInfo1 . ImageFile = "water_test3";
cameraInfo1 . NX = 512;
cameraInfo1 . NY = 289;
cameraInfo1 . RenderImage = 1; // rgb channels
cameraInfo1 . RenderABuffer = 1;
cameraInfo1 . RenderZBuffer = 1;
cameraInfo1 . RenderTransparency = 0;
cameraInfo1 . RenderUnknown = 1; // effective alpha channel for particles
cameraInfo1 . FarPlane = 1000;
cameraInfo1 . NearPlane = 0;
cameraInfo1 . OutputImage = 1;
cameraInfo1 . OutputABuffer = 0;
cameraInfo1 . OutputZBuffer = 0;
cameraInfo1 . OutputTransparency = 0;
cameraInfo1 . OutputUnknown = 1;
cameraInfo1 . ZDepthTexture . FileName = "";
cameraInfo1 . ABufferTexture . FileName = "";
// ------------------------------------------------
// Part (4) the LIGHTS info
LightingInfo light1;
light1 . RenderShadow = 0;
light1 . ShadowNx = 1024;
light1 . ShadowNy = 1024;
light1 . ShadowTransparency = .0;
light1 . ZDepthTexture . FileName = "";
light1 . ABufferTexture . FileName = "";
//-----------------------------------------------------------
// Part (5) the garbage info
GodRayInfo godray;
WaterSurfaceInfo water;
PartyKullInfo partykull;
StrandPatchInfo patch1;
patch1 . geometryInfo . FileName = "curlyball.cig";
patch1 . geometryInfo . ObjectNames = "nurb";
A jpa file can have much more infomation and structures, but these are all that is necessary
for partman to work.
As you can see from the structure of the jpa file, commenting is accomplished with C++ style double slash. Also, all non-commented information must end in a semicolon.
We will now discuss each part of the jpa file, as it relates to partman.
/proj/CSapps/volume/renderV2/jahasaInputTypes.h
The two parameters UseGeometryLights and UseGeometryCamera simply tell partman to use the data in the cig file to specifiy the camera(s) and the light(s) in the scene. Always set their values to 1, because we are not telling you here how to use the jpa file to set the camera and light details (although it can be done).
The parameter DoMotionBlur3D is a switch to turn on (= 1) or off (= 0) camera-based motion blur. When the faster streak motion blur is used (see below), the parameter DoMatteErosion is a switch for whether to do careful depth-checking along the length of the streak. DoMatteErosion = 1 allows blur streaks that begin outside of geometry to penetrate the geometry in the render, whereas DoMatteErosion = 0 does careful checking and preserves the boundaries of objects that may be in the scene.
The set of parameters RenderImage, RenderABuffer, RenderZBuffer, RenderTransparency, and RenderUnknown optionally turn on a sequence of different types of channels built into partman. All except the Transparency channel should be on. The ABuffer channel contains the alpha channel information for the combination of the particles and the surface geometry (if rendered), while in all circumstances, the Unknown channel contains the alpha channel of just the visible particles, and is the channel that is used when converting to rgba. The OutputImage, OutputABuffer, OutputZBuffer, OutputTransparency, and OutputUnknown parameters turn on/off which channels are actually written to the hdf data file after rendering.
The two parameters ZDepthTexture.FileName and ABufferTexture.FileName are optional strings for hold-out mattes for the A Buffer and Z Buffer. In practice, if either one is used, then both are needed. The ZDepthTexture file is a "zfile" render from prman, and the ABuffer texture should be a tiff file with the alpha data in the red channel. The actual filenames for the files shoudl be
so these parameters should have only the root part of the file names, and partman uses the frame number (####) to create the full name. If these files are specified, then their values are loaded into the camera data when the camera is initialized. Afterward, any geometry found in the cig file (assuming the RenderSurface parameter is on) is rendered, followed by particles. If these files are not found, the render continues on without them.
For those lights that generate shadows, the shadows are accomplished by building a shadow map independently for each light. The shadowmap is an image of the scene as viewed by the light, but only contains abuffer and zbuffer channels. The jpa file LightingInfo structure fixes the dimensions of the image. These dimensions are global to all lights that have shadows. When sampling the shadow, interpolation is used, so having a low dimension for the shadowmap can produced soft shadows in some situations.
The ShadowTransparency parameter allows a global scaling of the intensity of the color of the shadow light that is set for each light in the cig file.
As with the camera, files containing A and Z buffers can be imported to the shadowmap cameras. The ZDepthTexture.FileName and ABufferTexture.FileName strings specify the root portion of the file names. Because the light info data is used for all of the lights, the actual names of the data files must have a tag identifying which light they belong to. The protocol is for the file names to be
where XX is a two digit number for the light, with the first light being 00. If these files are not found or properly read, the render continues without them.
mayaMonkey -all -geom -light -cam -o
This generates a file with name The basic form that partman uses is the following:
For details on the syntax and techniques for pdb editing, see the document TRICKS FOR PDB PARTICLE SHADING AND EMISSION.
To assist in building complex particle emission shaders, a small library of functions and global variables has been built with predefined techniques such as child-particle counting, random fills, random walks, implicit surfaces, lightening bolts, and pseudo-temporal methods. Check them out.
There are of course, two components to motion blur: blur due to camera motion, and blur due to particle motion. Camera motion blur is turned on/off from the jpa file, as described in the section on the jpa file. Blur based on the particle motion is controled by the velocity attribute of the particle. To render WITHOUT motion blur, the magnitude of the velocity attribute must be zero when emit() is called.
If a particle has a non-zero velocity or acceleration, and none of the special options described later on set, then the motion blur is based on a streak drawn across the image plane. You can create funky effects such as paint-like strokes by varying the direction and magnitude of the velocity and/or acceleration in the pdbEditor shading file. The rendering of the streak is a relatively fast operation, so this kind of motion blur is not a burden on the total render time or memory usage.
When it is desirable to have a true 3D motion blur, this can be accomplished by using a pdb attribute called "do3Dblur". Setting this attribute to a nonzero value (the default value is zero) will cause the motion blur to be generated by rendering a sequence of identical particles along the motion path. This method is more time consuming than the default streak method, but in many cases can be necessary in order to get a good looking blur.
For both methods of bluring, the extend and shape of the blur path is controled via the particle's attributes "velocity" and "acceleration". A zero magnitude acceleration produces a straight-line blur, whereas for non-zero acceleration, the blur-path is curved accordingly.
The attribute "do3Dblur" is a particle attribute, but it is not necessary to have it prebuilt into the pdb file. Using the command-line syntax for the pdb processing, you can add this attribute with the addition of "-R do3Dblur -A" to the pdb command-line. See the appendix on how to do this.
There is an additional attribute which partman recognizes for controlling the content of motion blur. The particle attribute "blursample" allows you to increase or decrease the number of sample points for both the streak and 3D blur methods. As with do3Dblur, you must add this attribute to the attribute list with "-R blursample" on the pdbEditor command line.
One of the benefits of having do3Dblur and blursample as particle attributes is that their values can be set independently for every particle rendered. This allows complete freedom to decide what the best method is for any step of the render.
When the faster blur streak is used, the parameter DoMatteErosion in the CONTROL section of the jpa file acts as a switch for whether to do careful depth-checking along the length of the streak. DoMatteErosion = 1 allows blur streaks that begin outside of geometry to penetrate the geometry in the render, whereas DoMatteErosion = 0 does careful checking and preserves the boundaries of objects that may be in the scene.
The object
The pdbEditor shader file
The third file needed to run partman is the pdbEditor shader file. This file used to spawn any number of child particles from each one of the particles contained in the pdb file. The shader language is flexible enough to allow almost unlimited variety of characteristics to be obtained.
Control of motion blur
Partman can render motion blurred particles with two different techniques. The fast method is to render the particle once and streak the rendered image across a blur path on the image plane. The second method is more time consuming but precise: the sphere is rendered multiple times along a 3D motion path. In both cases there is control over the fineness of the sampling. Switching from one method to the other is accomplished in the pdbeditor shader, and so can both methods can be used in a frame, on a particle-by-particle basis.
The surface shader file
The fourth file which can be included on the partman command line is the surface shading file for the -s option. This file is purley optional however. If no -s option is giving, a default shading of just the intrinsic color of the particles is used. Choosing to employ surface shading however, give you complete control over how to apply lighting (if any), procedural texturing (if any), and even whether to render the particle at all. This shader is applied on a point-by-point basis on the surface of the sphere that makes of each particle that is rendered. If the shader does nothing, then the default particle-color-only shading is applied. The description of the shading process for the pdbEditor applied for this surface shader as well, except for the following differences:
All of the c-like syntax and math routines available in the pdbEditor are also available here.
Postprocessing: converting hdf files to tiff
After rendering, partman writes the channel data to a hdf file. To retrieve an rgb image in tiff format, try
This converts files <filerootname>XXXX.img to XXXX.tif for frames XXXX in the range 5 to 10, increment 3. To convert from floating point to integers, the gamma was set to 1 (-G1), and the floating point value corresponding to the black point is 0 (-m0), and the white point floating point value is 1 (-M1). If you chose to output the Unknown channel in the jpa file, then you may also retrieve an alpha channel in the tiff file, via
which sets the floating point values for the white and black points of the alpha channel, which is always converted with linear gamma.
Appendix: the pdbEditor man page
Below is the man page for the pdbEditor, with a little modification. Since the pdbEditor is more general than just partman, it has some options with do not apply, or only apply to portions of partman. We have therefore edited the man page to reflect these differences.
Appendix: the partmanInputTypes.h file