rtdepth [options] model.g [objects...]
RTDEPTH(1)
NAME
rtdepth - ray trace a model and produce a grayscale depth image
On this page
SYNOPSIS
DESCRIPTION
rtdepth uses librt(3) to ray trace the listed objects in the database model.g from a single view direction and produces a grayscale depth map. For each pixel the distance from the eye plane to the first object surface struck is divided by the viewsize (the diagonal of the model bounding box, i.e. the longest possible path) and the relative distance is mapped to an 8-bit gray value. Near surfaces are bright (toward 255) and far surfaces are dark (toward 1). The value 0 is reserved for rays that strike nothing, so the background can be keyed out easily and the object retains good contrast.
If no objects are listed, rtdepth uses the same automatic default-object selection described in rt(1). If no single usable default can be resolved, it aborts before rendering.
The view is selected with the -a (azimuth) and -e (elevation) options, in which case the model is auto-sized and the grid is centered on the model so the rays span the selected object set. Alternatively, with -M a model-to-view matrix is read from standard input (with the grid covering -1.0 ⇐ X,Y ⇐ +1.0 in view space); this form is convenient when rtdepth is driven by a script produced by the mged(1) saveview command.
By default the image is written to a framebuffer. Use -o to write a pix(5) or png(5) image (a .bw extension yields an 8-bit grayscale bw(5) file). Because the output pixels must be emitted in order, rtdepth always runs on a single CPU regardless of -P.
Most of the camera, grid, and debugging options accepted by rt(1) are also honored; see that manual page for the complete list.
OPTIONS
- -a azimuth
-
Set the view azimuth in degrees and enable auto-sizing. Use with -e; conflicts with -M.
- -e elevation
-
Set the view elevation in degrees and enable auto-sizing. Use with -a; conflicts with -M.
- -M
-
Read a model-to-view transformation matrix (and optional animation script) from standard input instead of using -a/-e.
- -s #
-
Set the square grid size to # rays on a side (default 512, i.e. a 512x512 image).
- -w #
-
Set the image width in pixels.
- -n #
-
Set the image height in scanlines.
- -g mm
-
Set the grid cell width in millimeters. If set without -G, cell height defaults to the same value.
- -G mm
-
Set the grid cell height in millimeters.
- -p deg
-
Set the perspective angle in degrees (0 ⇐ deg < 180; 0 is orthographic, the default).
- -V [:]
-
Set the view aspect ratio width/height (e.g. 1.33 or 4:3).
- -o file
-
Write the depth image to file instead of a framebuffer. The format follows the extension (e.g. .pix, .png, or .bw for grayscale).
- -O file
-
Write a double-precision .dpix file for full-resolution post-processing.
- -F framebuffer
-
Render to the named framebuffer (see the FB_FILE environment variable).
- -i
-
Use incremental (progressive-style) rendering.
- -t
-
Render top-to-bottom (the default is bottom-up).
- -u units
-
Set the display units; -u model uses the database’s local units.
- -P #
-
Requested processor count. Accepted for compatibility, but rtdepth always renders with a single CPU.
- -x #
-
Set librt debug flags as a hexadecimal bit vector (see raytrace.h).
- -X #
-
Set rt program/optical debug flags as a hexadecimal bit vector.
- -? or -h
-
Print a usage summary and exit.
See rt(1) for the remaining shared options (e.g. -g/-G grid cell sizing, -T tolerances, -c script commands). The -C and -W background options of rt(1) are disabled in rtdepth.
EXAMPLES
rtdepth -a 35 -e 25 -s 1024 -o depth.png model.g all
Ray traces the group all in model.g from azimuth 35, elevation 25 degrees on a 1024x1024 grid and writes a grayscale PNG. Nearer surfaces appear brighter and the empty background is pure black (value 0), making it trivial to composite the object over a new background.
rtdepth -M -o depth.bw model.g component < component.rt
Reuses the camera from an mged(1) saveview script (the matrix is read from standard input via -M) so the depth map of component is rendered from exactly the view set up interactively, writing an 8-bit bw(5) file that can be fed to bw-fb(1) or pixhist(1).
SEE ALSO
brlcad(1), mged(1), rt(1), rthide(1), rtxray(1), bw-fb(1), bw(5), librt(3)
AUTHOR
BRL-CAD Team
COPYRIGHT
This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.
BUG REPORTS
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org