DSP

From BRL-CAD
Revision as of 13:01, 6 June 2012 by Tbrowder (talk | contribs) (Preparing your height field data: adding examples)


Displacement (DSP) map primitive

Creating a DSP object

Preparing your height field data

A DSP primitive is an array of rpp cells initially defined by points in the XY plane as positive heights from Z = 0. The DSP can then be transformed to other orientations and positions. The number of cells is (numX - 1) * (numY - 1).

The data format for the DSP primitive is network-ordered unsigned short integers. BRL-CAD has a couple of dozen tools that you can use for converting existing data into that raw format, such as the 'cv' command or the 'bw-d' and 'd-u' commands among other similar tool chains. If you use the cv command, the output format is "nus" for network unsigned shorts.

An example black and white (gray scale) image (png format):

File:Class65-150h.png

Run the 'file' command on it:

$ file Class65-150h.png
Class65-150h.png: PNG image, 142 x 150, 8-bit gray+alpha, non-interlaced

Convert it to a bw file (one pixel is one unsigned char):

$ png-bw Class65-150h.png > Class65-150h.bw

Convert it to the format required for a dsp file:

$ cv huc nus Class65-150h.bw Class65-150h.dsp

And use it to create a dsp object:

mged> in dsp.s dsp f Class65-150h.dsp 142 150 0 ad 1 0.005

You can play around with the scaling factors to improve the looks of the image.

Now use a color png file:



The DSP takes unsigned short (16-bit) integer data. Our various command-line data converters can help bring data in from pretty much any existing format, including image data, via various processing commands. If the data was in png image format, for example (which is basically 3-channel 8-bit integer data), the data could be prepared with a combination of 'png-pix', 'pix-bw', and 'cv'.

If you type the 'in' command, it will prompt you for each parameter individually and that should help some. For the DSP, the main parameters are: the source of the height data, the width (number of points in the Y direction) and length (number of points in the X direction) of the input data, width/length/height scaling factors, and whether to smoothly interpolate between cells (0 = do not interpolate, 1 = interpolate).

See the 'dsp_add' tool for combining two existing DSP data files into one.

Importing DSP data into a .g file

Rendering your DSP