rt [options]... model.g [objects...]
RT(1)
NAME
rt - raytrace an mged model, giving a shaded picture
On this page
SYNOPSIS
DESCRIPTION
The rt program is a simple front-end to librt(3) which can be invoked directly, or via the rt command in mged(1).
rt operates on the indicated objects in the input model.g and produces a color-shaded image as the output. By default, the output is placed on the current framebuffer as it is computed. The environment variable FB_FILE specifies the current framebuffer, see brlcad(1). Alternatively, the output can be stored in a pixel file (pix(5) format) by specifying -o output.pix or in a PNG image file by specifying -o output.png in the option list. The orientation of the rays to be fired may be specified by the -a and -e options, in which case the model will be autosized, and the grid will be centered on the centroid of the model, with ray spacing chosen to span the selected object set. Alternatively, with the -M option, a transformation matrix may be provided on standard input which maps model-space to view-space. In this case, the grid ranges from -1.0 = X,Y = +1.0 in view space, with the size of the grid (number of rays fired) specified with -s. The -M option is most useful when rt is being invoked from a shell script created by an mged(1) saveview command.
If no object names are supplied on the command line, by
--objects-file, or by an input command stream, rt will use a
deterministic database default object. The selection succeeds only
when a single usable geometry object can be resolved, such as a valid
_GLOBAL default_object attribute, exactly one top-level geometry
object, exactly one combination, exactly one combination matching the
database filename, or exactly one top-level combination whose name
begins with all or scene. If default selection is disabled, names
an unusable geometry object, is ambiguous, or has no deterministic
match, rt prints the explanation from the default-object resolver, a
list of available top-level objects, and aborts without rendering.
The following options are recognized:
- -a #, --azimuth #
-
selects auto-sizing, and gives the view azimuth in degrees. Used with -e and conflicts with -M .
- -b , -b " ", --single-pixel #, --single-pixel " #"
-
is sometimes useful for debugging. A single ray is fired at the specified linear pixel index or X and Y pixel coordinates. This is best when accompanied by debugging options. Because getopt(3) only allows one option parameter, coordinate pairs must be enclosed in double quotes. This option must follow any viewing parameters.
- -c "script_command", --command "script_command"
-
is for specifying commands for rt to run prior to ray tracing. The "script_command" can be a single command or a semi-colon separated list of commands. The commands available are the same commands that may appear in a -M command script.
Some common script commands include start, viewsize, eye_pt, lookat_pt, viewrot, orientation, multiview, autoview, anim, tree, draw, erase, prep, clean, set, ae, start, and end. Running the saveview in MGED will produce an rt script for the current view.
Some common set variables include ambSamples, overlay, a_onehit, a_no_booleans. Running -c "set" will print values for all settable variables.
- -e #, --elevation #
-
selects auto-sizing, and gives the view elevation in degrees. Used with -a and conflicts with -M .
- -g #, --cell-width #
-
sets the grid cell width, in millimeters. Ordinarily, the cell width is computed by dividing the view size by the number of pixels of width, so this option need not be used. To obtain exactly 1 inch ray spacing, specify -g25.4 . If the grid cell width is specified and the grid cell height (which would be set using -G) is not specified, the grid cell height defaults to be the same as the width.
- -m density,r,g,b, --haze density,r,g,b
-
enables an exponential shading of the void between the eye and the first hit location. This allows a cheap simulation of atmospheric haze with lower performance impact than explicit modeling of the air volume. The haze is computed using the form:
f = e^(-distance * density)
g = 1.0 - f
color = color * f + hazeRGB * g
The color values are optional. If not specified, they will have the passable values 0.8 .9 .99 .
Example usage: -m '2.5e-8,.75,.95,.99'
- -i, --incremental
-
enables incremental mode processing. (First, a single ray is fired. Then, the screen is subdivided into four parts by evenly subdividing in the vertical and horizontal directions. The previously fired ray was the lower left corner; three more rays are fired. This process recurses until full resolution has been reached. Assumes square image. Also assumes fast path between CPU and display hardware.)
- -j xmin,ymin,xmax,ymax, --subgrid xmin,ymin,xmax,ymax
-
enables processing of just a sub-rectangle, located within the rectangle (0,0) (width-1,height-1), and whose screen coordinates (lower left and upper right corners) are provided in the argument. Ray-tracing will be limited to just those pixels within the sub-rectangle, and only those pixels will be transmitted to the framebuffer. The corner pixels (xmin,ymin) and (xmax,ymax) are included in the sub-rectangle. This option exists primarily for mged(1) to allow sweeping out a rectangular portion of the view for ray-tracing.
- -k xdir,ydir,zdir,dist, --cut-plane xdir,ydir,zdir,dist or -k x,y,z,nx,ny,nz, --cut-plane x,y,z,nx,ny,nz or -k x,y,z, --cut-plane x,y,z
-
enables the use of a cutting plane. The xdir, ydir, zdir, and dist define a plane (equivalent to a halfspace primitive with the same parameters). The vector (xdir, ydir, zdir) is normal to the plane and points away from the space to be subtracted. The dist parameter specifies the distance from the origin to the plane in the normal direction. The resulting image approximates subtracting the halfspace from the objects being raytraced. The x,y,z,nx,ny,nz specifies the same plane using a point and a normal rather than the halfspace style specifier. The x,y,z form is shorthand for a point-normal plane whose point and normal both use the supplied vector, with the normal unitized internally. Note that this is not exactly the same as actually subtracting the halfspace, but it is faster. If explicit lights are used, objects that are cut away by the cutting plane will still cast shadows.
- -l #[,args], --light-model #[,args]
-
selects lighting model. Default is 0. Model 0 is a full lighting model with the ability to implement Phong shading, transparent and reflective objects, shadow penumbras, texture maps, etc. In addition to ambient light, a small amount of light is supplied from eye position. All objects in the active model space with a material property string of "light" represent additional light sources (up to 16 are presently permitted), and shadow computations will be initiated automatically. (This mechanism is subject to further change.) Model 1 is a diffuse-lighting model only, and is intended for debugging. Model 2 displays the surface normals as colors, and is useful for examining curvature and surface orientation. Model 3 is a three-light brighter lighting model. Model 4 is a curvature debugging display, showing the inverse radius of curvature. Model 5 is a curvature debugging display, showing the principal direction vector. Model 6 is for debugging the UV parameterization used for surface texturing. It is exactly the same as applying the texture 'testmap' to every region. The U parameter is displayed in the red channel and the V parameter is displayed in the blue channel. Model 7 is for using photon mapping to simulate global illumination and caustics in a given scene. Model 8 is a heat-graph diagnostic mode that records the high-resolution current-thread CPU time needed by the rendering worker to render each fully shaded pixel and maps those timings to a grayscale image; brighter pixels took longer to render. If a current-thread CPU timer is not available, rt falls back to wall-clock timing. Timings include shader work such as light visibility and shadow rays, and the grayscale image is normalized for comparative display rather than absolute timing. Heat-graph output is written through the same output destinations as normal rt rendering, including -o image files and -F framebuffers. Options to photon mapping are passed through the -l parameter in the following format:
-l7,Num_Photons,Caustics_Percent,Irradiance_Rays,Angular_Tolerance, Random_Seed,Importance_Mapping_Toggle,Irradiance_Hypersampling_Toggle, Visual_Irradiance_Toggle,Scale_Lumens,Load_Save_File
Example: -l7,16384,0,10,60.0,0,0,0,0,1.0,scene.pm
Note: If just -l7 is used, then the default values above will be applied. Light sources must also be explicitly defined with lumens defined for each source, i.e., default light sources will not work.
- -n #, --height #
-
defines the height of the image as a number of scanlines.
- -o output, --output output
-
specifies the name of a file to store your output data file. For example, if you specify your output as image.pix, it will write out an image file in the pix(5) file format. If you specify an image.png file, it will write out an image file in the PNG file format. The pix-fb(1) and png-fb(1) utilities can be used to display ".pix" and ".png" files respectively.
- -p #, --perspective #
-
sets the perspective, in degrees, with 0 < = # < 180
- -r, --report-overlaps
-
requests that overlapping regions be reported (on by default); opposite of -R .
- -s #, --size #
-
specifies the number of rays to fire in the X and Y directions on a square grid. The default size is 512 (i.e., 512 x 512).
- -t, --top-down
-
causes reversal of the order of grid traversal (default is not to do that)
- -u units, --units units
-
specifies units, with "model" being used for the units of the local model
- -v [], --verbose []
-
sets the output verbosity level for rt. You can use -v 0 for no/minimal output or add -v repeatedly up through four levels (e.g., -vvvv) to see all available output. Default is all available output. The -v option will also take a specific hexadecimal value to turn on specific message categories (e.g., -v 0xFF010030) of output.
- -w #, --width #
-
defines the width of each scanline in pixels.
- -x #, --rt-debug #
-
sets the librt(3) debug flags to the given hexadecimal bit vector. See raytrace.h for the bit definitions. (Notice that -! # sets the libbu(3) debug flags to the given hexadecimal bit vector. See bu.h for the bit definitions.)
- -z #, --opencl #
-
enables (-z1) or disables (-z0) OpenCL accelerated raytracing. OpenCL must be enabled at compilation time for this option to have any effect.
- -d file, --density-file file
-
specifies a material density definitions file, used by analysis-oriented views (such as rtweight(1)) to map region material codes to densities.
- -q #, --rand-table-size #
-
sets the number of entries used from the random-number half-table. The value must be greater than 0 and no larger than the compiled-in maximum. This is primarily of interest when tuning reproducibility of dithering and sampling.
- -I file, --objects-file file
-
reads the list of objects (treetops) to raytrace from the named text file, one object name per line, instead of (or in addition to) naming them on the command line.
- -A #, --ambient #
-
sets the ambient light intensity, as a fraction of the total light in the scene in the range of 0.0 to 1.0 .
- -B, --benchmark
-
turns on the "benchmark" flag. This causes all intentional random effects such as ray dither, color dither, etc., to be turned off to allow benchmark timing comparison and benchmark result comparison.
- -C //, --background #//#/
-
sets the background color to the RGB value //#, where each # is in the range of 0 to 255 or 0.0 to 1.0. All non-background colors will be dithered away from this value.
- -D #, --start-frame #
-
This is the "desired frame" flag, specifying the frame number to start with. Used with animation scripts; specify the desired ending (kill-after) frame with -K # .
- -E #, --eye-backoff #
-
sets the distance from the eye point to the center of the model RPP; default is the square root of 2. Only useful with auto-sizing, and conflicts with -M .
- -F framebuffer, --framebuffer
-
indicates that the output should be sent to the indicated framebuffer. For remote framebuffer access, this may be a TCP-style specification (for example, host:port or port) or an IPC address using the form ipc:*addr. See *brlcad(1) for more details on framebuffer naming.
When using fbserv authentication, set FBSERV_TOKEN in the rt environment to the same token value used by the server. To request TLS for remote framebuffer connections (OpenSSL builds), set FBSERV_TLS to a non-empty value.
- -G #, --cell-height #
-
sets the grid cell height, in millimeters. If the grid cell height is specified and the grid cell width (which would be set using -g) is not specified, the grid cell width defaults to be the same as the height.
- -H #, --hypersample #
-
This is the "hypersample" flag, specifying number of extra rays to fire for each pixel to obtain more accurate results without needing to store the extra pixels. Automatically invokes -J 1. The final colors of all rays are averaged together. Better results can be obtained by simply increasing the resolution, and decimating the results with a filter such as pixhalve(1).
- -J #, --jitter #
-
This is the "jitter" flag, which is a bit vector. If one (-J 1), it randomizes the point from which each ray is fired by +/- one half of the pixel size. Useful if doing your own post-filtering for antialiasing, or to eliminate systematic errors. This has been useful in obtaining more accurate results in a volume-calculating raytrace as well. If two (-J 2), it shifts the origin of the output frame once for each frame. The shift is along a circular path in the plane of the frame, with a period of ten seconds, and a radius of +/- 1/4 pixel width. If three (-J 3), it performs both operations.
- -K #, --end-frame #
-
sets the final (kill-after) frame number. Used with animation scripts in conjunction with -D # .
- -M, --read-matrix
-
causes reading of animation (model2view) matrix or animation script from standard input. Conflicts with -a and -e options.
- -N #, --nmg-debug #
-
sets the NMG_debug flags to the given hexadecimalbit vector. See h/nmg.h for the bit definitions.
- -O output.dpix, --output-double output.dpix
-
specifies the name of a file in which to store a double-precision floating-point version of the image in dpix(5) format. dpix-pix(1) can be used to later convert the file to pix(5) format output.
- -P #, --cpus #
-
Specify the maximum number of processor cores to be used on multicore systems. The default is the maximum number of cores available for the machine. Negative numbers indicate using all except for the count specified.
- -Q x,y, --query-pixel x,y
-
selects pixel ray for query with debugging. The option is used to specify a single pixel for which the debug flags should be turned on. The computation of all other pixels will be performed without debugging. This is similar to the -b option, except that it does not limit rendering to the single ray. The entire image is computed. This option is useful in debugging problems which arise from specific computation sequences (such as the order of random numbers previously drawn).
- -R, --no-overlap-report
-
requests that overlapping regions not be reported; opposite of -r .
- -S, --stereo
-
turns on stereo viewing. The left-eye image is drawn in red, and the right-eye image is drawn in blue.
- -T [/], --tolerance [/] or -T [,], --tolerance [,]
-
sets the calculation tolerances used by librt(3). If only one number is given, it specifies the distance tolerance. Any two entities closer than this distance are considered to be the same. The default distance tolerance is 0.0005mm. If the second number is given, it specifies the value of the dot product below which two lines are to be considered perpendicular. This number should be near zero, but in any case should be less than 1. The default perpendicular tolerance is 1e-6. If both calculation tolerances are provided, they shall be separated by either a slash ("/") or a comma (","), with no white space between them. For example, the default tolerances would be specified as -T0.0005/1e-6 on the command line.
- -U #, *--use-air #
-
sets the Boolean variable use_air to the given value. The default is 0, which ignores regions that have non-zero aircode values.
- -V [:], --view-aspect [:]
-
sets the view aspect. This is the ratio of width over height and can be specified as either a fraction or a colon-separated ratio. For example, the NTSC aspect ratio can be specified by either -V1.33 or -V4:3 .
- -W, --white-background
-
specifies rendering on a white background. this option sets the image background color to pure white. This is equivalent to setting -c "set background=1.0/1.0/1.0".
- -X #, --optical-debug #
-
sets the liboptical program debugging flags to the given hexadecimal bit vector. See raytrace.h for the meaning of these bits.
- -! #, --bu-debug #
-
turns on the libbu(3) library debugging flags. See bu.h for the meaning of these bits. In particular, specifying -!1 will cause
bu_bomb()to dump core, rather than logging the error and exiting. This is useful with dbx(1) or gdb(1) for debugging. (Notice that -x # sets the librt(3) debug flags to the given hexadecimal bit vector. See raytrace.h for the bit definitions.) - -+ t, --text-output t
-
specifies (with the argument "t") that output is text rather than binary (the default is binary). No other argument value is accepted.
- -,, --space-partition
-
selects the space-partitioning algorithm. This option is temporarily disabled and currently causes rt to exit with an error if used.
- -h, -?, --help
-
prints a usage summary listing all options and exits.
SIGNALS
You can obtain progress information from a running rt process by sending it a SIGUSR1 or SIGINFO signal. The raytracer will report progress via details about the ray sample being processed at the time of the signal. The progress is reported to stderr in a form similar to: frame 0, xy=1516,2466 on cpu 0, samp=0
NTSC ANIMATION TIPS
When using rt to create an animation sequence destined for NTSC video, it is useful to give all these options at one time: -V4:3 -c "set gamma=2.2" -w1440 -n972 -J1 and then post-process the output using pixhalve(1) for final display. Performing the gamma correction inside rt instead of post-processing the pix(5) file with bwmod(1) avoids Mach-bands in dark regions of the image, and retains the maximum amount of image detail.
EXAMPLES
rt -A0.9 -c "set ambSamples=4" -s256 -o preview.png model.g object
Renders to a PNG image with minimal ambient occlusion (4 samples per ray) using the lighting-model default. The -A ambient-light value is raised to compensate for the darkening caused by the occlusion samples. View preview.png with png-fb(1) or any image viewer.
rt -M -o view.pix model.g component < saveview.rt
Feeds an animation/view script (such as one produced by the MGED saveview command) into rt on standard input via -M, which supplies the model-to-view matrix and camera settings. The resulting image is written in pix(5) format and can be displayed with pix-fb(1).
fbserv -S 512 0 /dev/mem &
rt -F 0 -s512 model.g object
The first command starts an fbserv(1) framebuffer server on port 0. The second command renders straight into that framebuffer via -F, displaying pixels as they are computed instead of writing a file.
set FBSERV_TOKEN=0123456789abcdef
set FBSERV_TLS=1
fbserv -T -A -p 0 -F /dev/wgl &
rt -F 0 model.g object
With FBSERV_TOKEN in both the fbserv and rt environments, fbserv will require authentication from connecting rt processes. If BRL-CAD was compiled with OpenSSL support, the connection attempts TLS.
rt -H8 -R -A1.3 -c "set ambSamples=512 gamma=2.2" \
-C234/245/255 -s4096 -o render_4k.png model.g object
Renders with 8 hypersamples each averaging 512 ambient-occlusion samples (a brute-force global-illumination approximation) to smooth edges and soften shadows, with overlap reporting suppressed (-R) and a near-white background (-C). Rendering at 2x the desired resolution (here 4096 for a 2048-pixel result) and decimating in post-processing with pixhalve(1) yields the cleanest output; the -A and gamma values can be tuned for overall brightness.
SEE ALSO
brlcad(1), mged(1), pix-fb(1), png-fb(1), librt(3), dpix(5), pix(5)
DIAGNOSTICS
Numerous error conditions are possible, usually due to errors in the geometry database. Descriptive messages are printed on stderr (file descriptor 2).
AUTHOR
BRL-CAD Team
COPYRIGHT
This software is Copyright (c) 1984-2026 United States Government as represented by the U.S. Army Research Laboratory.
BUG REPORTS
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org