RTDEPTH(1)
π
RTDEPTH(1) β the rtdepth page, bestie edition β¨
okay so real quick: this is the rtdepth(1) manual page from BRL-CAD, and it's genuinely one of the most useful little gremlins in the whole toolkit. let's get into it π«Ά
β¨ NAME β¨
rtdepth β ray trace a model and produce a grayscale depth image π
β¨ SYNOPSIS β¨
rtdepth [options] model.g [objects...]
β¨ DESCRIPTION β¨
so rtdepth uses librt(3) to ray trace the objects you list in the database model.g, from one single view direction, and it spits out a grayscale depth map. iconic behavior honestly.
here's the whole vibe of how each pixel gets its value: for every pixel, it takes the distance from the eye plane to the first object surface it hits, divides that by the viewsize β and bestie, viewsize is the diagonal of the model bounding box, aka the longest possible path β and then it maps that relative distance onto an 8-bit gray value. near surfaces come out bright (toward 255), far surfaces come out dark (toward 1). and the value 0? that's reserved for rays that hit literally nothing π so the background can be keyed out super easily and your object keeps good contrast. chef's kiss.
if you don't list any objects, rtdepth falls back to the same automatic default-object selection described in rt(1). but if no single usable default can be resolved, it aborts before rendering β no guesses, no drama, it just stops. π
you pick the view with the -a (azimuth) and -e (elevation) options β in that case the model gets auto-sized and the grid is centered on the model so the rays span the selected object set. or, alternatively, with -M a model-to-view matrix gets read from standard input (with the grid covering -1.0 <= X,Y <= +1.0 in view space). that form is so convenient when rtdepth is being driven by a script produced by the mged(1) saveview command. iykyk πΈ
by default the image goes to a framebuffer. use -o to write a pix(5) or png(5) image instead (and heads up: a .bw extension gets you an 8-bit grayscale bw(5) file π€). and because the output pixels must be emitted in order, rtdepth always runs on a single CPU no matter what -P says. that's just the rules. β
most of the camera, grid, and debugging options that rt(1) accepts are also honored here β go read that manual page for the complete list, bestie.
β¨ OPTIONS β¨
-aazimuth β sets the view azimuth in degrees and turns on auto-sizing. use it with-e; it conflicts with-M.-eelevation β sets the view elevation in degrees and turns on auto-sizing. use it with-a; it conflicts with-M.-Mβ reads a model-to-view transformation matrix (plus an optional animation script) from standard input instead of using-a/-e.-s# β sets the square grid size to # rays on a side (default512, i.e. a512x512image).-w# β sets the image width in pixels.-n# β sets the image height in scanlines.-gmm β sets the grid cell width in millimeters. if you set it without-G, the cell height defaults to the same value. π-Gmm β sets the grid cell height in millimeters.-pdeg β sets the perspective angle in degrees (0 <= deg < 180;0is orthographic, and that's the default).-V#[:#] β sets the view aspect ratio width/height (e.g.1.33or4:3).-ofile β writes the depth image to file instead of a framebuffer. the format follows the extension (e.g..pix,.png, or.bwfor grayscale).-Ofile β writes a double-precision.dpixfile for full-resolution post-processing. π₯-Fframebuffer β renders to the named framebuffer (peep theFB_FILEenvironment variable).-iβ uses incremental (progressive-style) rendering.-tβ renders top-to-bottom (the default is bottom-up).-uunits β sets the display units;-u modeluses the database's local units.-P# β requested processor count. accepted for compatibility, butrtdepthalways renders with a single CPU (said it once, saying it again π ).-x# β setslibrtdebug flags as a hexadecimal bit vector (seeraytrace.h).-X# β setsrtprogram/optical debug flags as a hexadecimal bit vector.-?or-hβ prints a usage summary and exits.
see rt(1) for the remaining shared options (e.g. -g/-G grid cell sizing, -T tolerances, -c script commands).
π¨ real talk: the-Cand-Wbackground options ofrt(1)are disabled inrtdepth. don't come for me, it's just how it is.
β¨ EXAMPLES β¨
Example 1 β depth image from a three-quarter view π
rtdepth -a 35 -e 25 -s 1024 -o depth.png model.g all
this 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), which makes it trivial to composite the object over a new background. main character energy fr fr π
Example 2 β depth pass matching a saved MGED view π¦
rtdepth -M -o depth.bw model.g component < component.rt
this 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 you set up interactively β writing an 8-bit bw(5) file that can be fed to bw-fb(1) or pixhist(1). literally so satisfying.
β¨ 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 π¬
and that's the whole page, bestie!! brought to you by BRL-CAD β the rtdepth(1) manual, now with 100% more sparkle β¨ππ go make some gorgeous depth maps, you got this π«Ά
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms