RIVA 1.0 TutorialTable of Contents1. Machine Requirement
1. Machine RequirementsRIVA 1.0 consists two major components, the parallel renderer and the GUI programs. The parallel renderer uses a combination of MPI calls and Unix System V shared memory library. It has been tested on the SGI Origin system, but it should work on other SMP machines supporting MPI and shared memory library. The GUI program, namely, flexible flyer, is built upon OpenGL and SGI's OpenInvertor. Therefore, it only supports SGI platforms. It runs properly on SGI machines with texture memory, such as O2 and Octane. It also runs on SGI machines without texture memory, but the performance is poor.The parallel renderer requires 64 bit address space in order to handle large datasets. The GUI programs are compiled with 32 bit address. 2. InstallationThe RIVA 1.0 distribution contains three compressed tar files: riva1.0_bin.tar.Z, riva1.0_src.tar.Z, and riva1.0_data.tar.Z. The riva1.0_bin.tar contains all the binaries and libraries for SGI IRIS 6.5. The riva1.0_src.tar contains the source code for RIVA renderer, GUI program and all the utility programs. Both tar files contain complete documents in html format, and sample scripts and scenerio files to run the examples documented in this tutorial. riva1.0_data.tar contains a small earth dataset for RIVA. The examples used in this tutorial are all based on this test dataset.Following are the steps to make the RIVA executables from the source distribution: 1. Untar riva1.0_src.tar in your home directory, say /home/yourname.
RIVA code will be untar'ed into /home/yourname/RIVA1.0
directory.
The following binaries will be made in $(RIVAHOME)/bin/ directory:
Router* render* rivglobe* rivresize*
libMessager_32.a libMessager_64.a libriva_32.a
libriva_64.a
3. RIVA ArchitectureThe RIVA System contains a set of programs. In general, they can be divided into three functional groups:
4. Prepare RIVA Input DatasetsBefore you run a RIVA program, you have to prepare your input dataset. RIVA takes at least two input files, one image file and one digital elevation map (DEM). RIVA has it own input format, call RivaFile format. RivaFile format is similar to Vicar format developed by JPL. It has a fixed sized header block followed by raw data. The header block consists <keyword=value> pairs in ASCII. In order to load RIVA data fast in parallel, RIVA files are pre-tiled and stored in tile order. Each tile is preceded by a fixed size tile header.A set of utility programs are included in this release to help users to prepare their input datasets. The man pages for these utilities can be found in the main document index file. To use RIVA utilities, you have to include $(RIVAHOME)/bin in your seach path. Following is a step-by-step instruction for you to prepare your input dataset. For a quick verification of your installation, we also included a small test data set in the tiled RivaFile format in data/ directory. If you want to use this test data set instead of your own dataset, you can skip to Section 5. The Raw DataWe will be using an Earth dataset. The files provided are already merged, pre-shrunk, and converted. However, these features will be described breifly for sake of completeness. The following files are provided:
4.1 Preparing Data for the RendererWe need to convert all terrain images and DEMs to RivaFile format for the Renderer.4.1.1 Conversion to RivaFile Format from Raw dataIf an image is stored in separate channels, they must first be merged into one Rivafile. The rivmerge utility can be used to merge the channels to make one Rivafile. rivmake can be used to attach a header to a raw file to make it a Rivafile. rivmerge and rivmake create a Rivafile header of 1024 bytes by default.After using rivmerge or rivmake, appropriate fields must be added to the Rivafile header one by one with rivadd. See the RivaFile Reference for more information about header fields. Notice the DEM has some fields (ZMETERS, ZDELTA, etc.) that the terrain image does not have. The rivdel utility can be used to delete unwanted fields; rivheader or rivinfo can be used to view the contents of a RivaFile header. Since the provided datasets are already pre-processed, check that the file properties are satisfactory with rivheader or rivinfo. rivheader gives fields as they are stored, rivinfo processes the header fields to see if it is a valid image or DEM.% rivheader earthdem_sm.riv RivaFile: earthdem_sm.riv LBLSIZE=1024 TYPE='DEM' NL=2160 NS=4320 BPP=2 PROJECTION='CYLINDRICAL' PIXMETERS=8000 ZMETERS=1 SUNFORMAT=1 LONG0=-180 LAT0=90 LONG1=180 LAT1=-90% rivinfo earthdem_sm.riv RivaFile: earthdem_sm.riv Type: DEM Projection: CYLINDRICAL Valid Image------------------------ Samples: 4320 Lines: 2160 Bytes per Pixel: 2 Not a Valid Terrain Image---------- BPP=2; should be at least 3 Valid DEM-------------------------- North: 90 deg North latitude South: -90 deg North latitude West: -180 deg East longitude East: 180 deg East longitude Pixel Size: 8000 meters Elevation Unit: 1 meters Elevation offset: 0 meters (Default; no ZDELTA field) Byte Order: Unix 4.1.2 Adjusting the File ResolutionRIVA expects that image file and the DEM file have matching geographical coverage. In other words, the following keywords should be identical in both files: LAT0, LONG0, LAT1, LONG1. The DEM and the image file usually have the same resolution. However, the image may have less resolution than the DEM. In that case, the pixel resolution of the image file has to be an integer multiple of that of the DEM. For instance, if DEM's resolution is 30 meter per pixel (PIXELMETER=30), the image can have resolution of 30 meter/pixel, 60 meter/pixel, 90 meter/pixel, etc.. When the image file and the DEM file have different resolutions, the tile size of each file has to be chosen to cover the same area. If a DEM file of 30 meter resolution is partitioned into 128x128 pixel tiles, the corresponding image file of 120 meter resolution has to be partitioned into 32x32 pixel tiles so that each tile covers the same geographical area of the surface.Since the image files and DEM files are often obtained from differenct sources and with different pixel resolutions, many times, we would need to crop or resample the dataset. RIVA provides rivshrink to shrink the dataset and rivresize to interpolate the dataset. 4.1.3 Convert global data to the sinusoidal projectionA Riva File can be in either cylindrical projection or in sinusoidal projection. For a global dataset, it is more efficient in both disk space and rendering time if you store the data set in a sinusodial projection. The rivglobe utility can be used to perform this conversion between the two projection systems.% rivglobe earth_sm.riv earthglo.riv rivglobe: reading RivaFile earth_sm.riv rivglobe: Writing sinusoidal image earthglo.riv% rivglobe earthdem_sm.riv earthdemglo.riv rivglobe: reading RivaFile earthdem_sm.riv rivglobe: Writing sinusoidal image earthdemglo.riv 4.1.4 TilingInternally, the input datasets are partitioned into small square tiles and distributed to each rendering processor's local memory. For the renderer to load terrain images and DEMs faster, we pretile them using rivtiler. Sparse tiling is often used to eliminate blank space. Here, the tiled images are provided: tiled_earth.vic and tiled_earthdem.vic.Grid widths should be chosen empirically; 64 is generally pretty good. Bigger files require bigger tiles. 4.1.5 Writing the renderer's configuration fileOnce all of the files have been tiled, a configuration file is written to tell the renderer which files to load and their relationship. The renderer's configuration file (usually with extention .set) is described in detail in the Renderer Reference.Here is an annotated copy of earth.set file used for the full set of Earth data: # earth.set # # Definition for Earth dataset # # FIRST, define symbolic names for files. The name chosen for the # terrain image is particular important, as the Flexible Flyer will # use it as the name for the surface formed by the terrain image and # its DEM. DATA earthdem tiled_earthdem.vic DATA Earth tiled_earth.vic # NEXT, combine the terrain images and DEMs into surfaces. Order is # important here, as the renderer will compose the surfaces in the # order given. Since we only have one surface, it doesn't really matter. DEM Earth earthdem # NEXT, state combination method. In general, COMBINE OPACITY is # always right. COMBINE OPACITY 4.2 Preparing data for the Flexible FlyerThe Flexible Flyer needs lower resolution data files for proper speedy execution.4.2.1 Shrinking the dataThe Flexible Flyer requires a terrain image (in SGI RGB format) and a DEM (in RIVA File format) for each surface, just as the renderer does. We will use the rivshrink utility to shrink the terrain image and DEM to the right size.NOTE: for the Flexible Flyer, all terrain images must be in cylindrical projection, not sinusiodal. In order to maintain reasonable interactive speed in Flexible Flyer, the optimal data file size for Flexible flyer is about 500,000 pixels for images and 5,000 pixels for DEMs. The Earth dataset is 4320x2160 pixels. To get it to the right size, we will shrink earth_sm.riv by a linear factor of 4 and earthdem_sm.riv by a linear factor of 40. The resulting sizes will be 1080x540 and 108x54, respectively. % rivshrink earth_sm.riv smallearth_sm.riv 4 rivshrink: shrinking RivaFile earth_sm.riv rivshrink: shrink by a factor of 4 rivshrink: creating RivaFile file smallearth_sm.riv Shrinking an Image. rivshrink: new size is 1080 x 540% rivshrink earthdem_sm.riv smallearthdem_sm.riv 40 rivshrink: shrinking RivaFile earthdem_sm.riv rivshrink: shrink by a factor of 40 rivshrink: creating RivaFile file smallearthdem_sm.riv Shrinking a DEM. rivshrink: new size is 108 x 54 4.2.2 Converting the terrain image to IRIS RGB formatThe Flexible Flyer uses OpenInventor to render the low-resolution surfaces, using the terrain image as a texture map onto a quadmesh produced from the DEM. OpenInventor likes its texture maps in SGI's IRIS RGB graphics format. Thus, the shrunken terrain images must be converted to that format. The easiest way to do this is to convert them first to PPM format using the riv2ppm utility. Then, any number of different packages (ImageMagick, XV, fromppm) can be used to convert the PPM image to IRIS RGB format.The following listing shows how to convert the small terrain images to PPM format: % riv2ppm smallearth_sm.riv smallearth_sm.ppm 4.2.3 Writing the Flexible Flyer's configuration fileThe configuration file tells the Flyer the names of the files making up each surface, and also allows the user to configure the Renderer Controls that are displayed. For complete information about the Flyer's configuration file, see the Flexible Flyer Reference or the Renderer Reference.The following is an annotated listing of 'earth_ff.set', which is used when interactively rendering the set of Earth data described above: # earth_ff.set -- Flexible Flyer Configuration File # # Earth dataset # Messager resources: the Flyer sends renderer commands under the # resource name RENDERER, and receives status messages from a resource # named RENDER_STATUS. At present, the renderer # always sends status messages as RENDER_STATUS. # Each data set usually gets its own renderer command resource name. messager RENDERER RENDER_STATUS # Surfaces: for this data set, the Flyer will load one surface: # the planet Earth. The 'sphere' command is # used for loading spheres, and the 'plane' command for loading # smaller regions. Note that the names used are the same as those # used in the renderer's earth.set, shown previously. # Name Terrain Image DEM Radius in pixels sphere Earth smallearth_sm.rgb smallearthdem_sm.riv 3666.932 # Tags: it is possible to attach text tags (e.g., place names) to a # surface at any desired lat/long location using the 'tag' command. # Controls: These commands define a variety of Renderer controls. # Note that a surface toggle and an opacity slider can be defined for # a surface defined in the renderer, even though it isn't loaded # into the Flyer. vertexag opacity Earth status 5. Run A RIVA ProgramWe now have data sets and configuration files for both the RIVA renderer and the Flexible Flyer and we are ready to run RIVA. RIVA has only been tested on the SGI's platform. The parellel rendering program, hfb_host and flit run on SGI Origin 2000 using MPI. Flexible Flyer, xshow, and receive_display run on SGI workstations, such as O2, Octane, Onyx, as well as Origin. Router can run on either the renderer's machine or on the GUI's machine.5.1 Run fly script to start the RIVA GUI programsBefore you run any RIVA program, make sure $(RIVAHOME)/bin is included in your search path. The RIVA 1.0 release includes two run scripts in $(RIVAHOME)/bin directory: render and fly.Fly script starts Router, if it did not exist already, Flexible Flyer (ff), xshow and receive_displayall at once. The sample fly script is shown as below: #!/bin/csh -f
echo fly $1
# NEXT, run the 2D map program, xshow, passing the same set file
as argument
# NEXT, Start the receiving program: receive_display
To run RIVA interactively using Earth dataset, first you need to start the Router and GUI programs on your SGI workstation: % fly earth_ff.set Note in the sample fly script, we start receive_display using
Router communication. You have to edit the fly script if you wish
to use socket connection instead. Router connection is much slower
than socket connection, but more flexible. If using socket
connection, you have to run fly script first, then render script.
If you use socket connection to receive rendered images, receive_display will display the following message when the socket is created successfully: % receive_display -s -bAfter you see the above message, you can go ahead starting the renderer. The display window will not be opened until the renderer is started and the socket connection is established. The default port number used by receive_display is 7000. It has to match with the port number defined for the output destination in flitrc. If the port number can not be bound for some reason, you can either wait for a while and try again, or change to a different port using switch -p. If you change to a different port number, you have to change the corresponding port number in flitrc. See Renderer Reference and receive_display man pages for the command line arguments. 5.2 Run render script to start the RIVA rendererRender is a script containing different scenerios to run hfb_host. A sample render script is shown below:#!/bin/cshYou need to edit render script and change defaultrouterhost to the hostname where Router is running. Alternatively, you can set an environment variable ROUTERHOST instead. If your SGI Origin 2000 is running a queuing system, such as PBS, you need to obtain the appropriate queue before running the render script. For example, to get an interactive queue of 16 nodes for 30 minutes using PBS: % qsub -I -V -lncpus=16 -lwalltime=00:30:00 After you get the queue, change directory to $(RIVAHOME)/work and do % render earth.fly 16 earth.fly is one of the scenarios defined in the sample render script. 16 is the number of processors the renderer, flit, will run on. Note the number of nodes has to be a power of 2. If it is not given, it is set to 32 by default in the render script. The above script actually calls hfb_host with the following arguments: hfb_host -c flit -p 16 -i earth.set
-D routerlow \
hfb_host spawns the parallel renderer, flit, on 16 processors. After started, flit loads in the input datasets defined in earth.set. If the input dataset is big, it will take a while to load the dataset, when the data is loaded, the following message will appear in your window: flit: ready to render It will render the earth datasets defined in earth.set by taking commands from the Router using resource name RENDERER. RENDERER should match with the resouce name used by the Flexible Flyer to send the command to the renderer. The resource name used by Flexible Flyer is defined in its configuration file, earth_ff.set. The renderer generates images of type "routerlow". Routerlow is a output device name defined in a flit resource file (flitrc) in the current directory: router routerlow 640 512 RenderTest RGB_REVERSE It is a RGB image of size 640x512 with image origin defined at the lower left corner of the image. The images will be sent to Router using resource name "RenderTest". The images will be displayed by receive_display program. You have to give the same resource name and frame size in the command line when you start receive_display. The renderer can be started as a batch program without the GUI interface as well. When it runs as a batch program, it takes input commands from a command file. A sample command file, earth.flit, is included in the release in $(RIVAHOME)/work directory. To run RIVA without GUI, do % render earth.test 16 earth.test is another the scenarios defined in the sample render script.
It will render the earth datasets defined in earth.set using the flight
path stored in $(RIVAHOME)/work/earth.flit and generate images of type
"diskmed". The output images will be stored in $RIVAHOME/output with prefix
"earth". Diskmed is a output device name defined in a flit
resource file (flitrc) in the current directory. It is a PPM
file of size 640x512 as defined in the sample flitrc file.
You can modify or add any new devices for your own need.
6. Running Flexible Flyer6.1 Starting OutFlexible Flyer can by used as a standalone program. It is often useful to run it alone when you design your flight path for a movie. After you have your first flight path done, you can bring up the parallel renderer to check the quality of your key frames or render a test movie to verify the flight path. Since the connection between ff and hfb_host is via Router, the two programs can be started or stopped independently without breaking the connection. To start ff alone, doff will fail if it cannot find a router. If this problem arises, give the following command before trying again.% ff earth_ff.set 'earth_ff.set' will make a Vertical Exagerration slide bar, an opacity bar for the Earth data, and Status Message window displayed at the control panel. A sample Flexible Flyer window is shown in Figure 1.% Router &
6.2 Viewing ModesThere are three different viewing modes for ff. They are in the pulldown menu under Viewers.The 'Examiner' view allows for rotation of the data set with the left mouse button and translation of the data set with the middle mouse button. The right mouse button reveals a menu of options. The Dolly wheel at the lower right hand corner zooms in and out. The Rotx and Roty wheels allow for rotation about the x(horizontal) and y(vertical) axes. The 'Fly' mode allows for lateral and vertical movement of the viewpoint. The left and middle mouse buttons counteract each other. To move to the right, press the left mouse button and move the cursor to the right. To slow, click on the middle mouse button. Clicking the left and middle mouse buttons simultaneously will stop all movement. The bar at the bottom of the viewfinder shows velocity. The blue bar indicates maximum velocity, the red bar shows current velocity. The more times one mouse button is clicked, the larger the blue bar will get. A bar to the right represents lateral forward motion. The Rotate wheel pans horizontally, and the Tilt wheel pans vertically. The Dolly wheel zooms.
The 'Walk' mode allows lateral movement without vertical changes. Hold down the left mouse button to move. The viewfinder will move where the cursor is dragged. The altitude and viewing angle can be adjusted independently with the wheels labeled Height and Tilt, respectively. The Height wheel actually translates the surface in the vertical direction, while the Tilt wheel pans in the vertical. The Rotate wheel pans left and right. The Dolly moves the viewpoint in a straight line perpendicular to the view window. 6.3 Viewing ButtonsAt the right side of the Viewing window, there are eight buttons that control the viewing parameters: This
button is a cursor. It doesn't do anything but point.
6.4 Control PanelThe ***Renderer Control Palette*** to the left of the viewing window displays various renderer control functions. These controls do not affect the flexible flyer, but send commands directly to the renderer. There are six built-in control functions in the Flexible Flyer as shown in Figure 4. User can choose the default control functions in ff's configuration file, or use the Controls menu to toggle on or off any of the functions.The six control functions are:
COMMAND: [Dataset] [option] For instance, "SHADE: earth ON" turns on shaded-relief function on the earth dataset, and "DEST: routerlow" changes the destination device to "routerlow". For a detailed list of commands and usage, see the Renderer Command Language reference. These commands do not affect the flexible flyer. 6.5 Keyframe EditorAfter familiarizing yourself with the flexible flyer, you are now ready to create a flight path. Under the Animation menu, select New to create a new animation file. The Open option will open an existing .anim file. When either New or Open is selected, the animation editor window will appear (Figure 5). The ff program will create a flight path with the key frames selected in the animator by interpolating on a spline. Upon selecting the desired viewpoint, click Append to add the key frame to the end of the list. Frame duration in seconds can be varied with the slide bar. Click a key frame in the scrollable window selects and hightlights the key frame. Double click a keyframe will make an information window popped up. The popup window displays the detail information of the selected keyframe. Click OK to close the information window. The Insert button adds the desired viewpoint immediately after the selected keyframe. The Delete button removes the selected keyframe. The Change button updates the selected keyframe. The Preview button allows you to preview the flight path from the beginning. Pause, Resume, and Stop buttons are the control buttons for the preview. Pressing the Pause button stops the preview. Resume can be clicked to start the preview where it was paused. Stop terminates the preview; pressing the Preview button will restart the preview from the beginning. You can also preview an arbitrary frame in the flight path by moving the Preview slide bar. The Frame Rate slide bar varies the frame rate per second. You can also preview the entire flight path by select preview menu in the Animation pull down menu. The multiplication of the Frame Duration and the Frame Rate determines the numbers of frames to be interpolated in between a pair of keyframes. It can be changed per keyframe base. If you have a time-varying dataset and you would like to start time animation at a selected keyframe, you can click Start Time Sequence button when a key frame is highlighted. When the flight path is generated, the time step will advance at every viewpoint after the selected key frame. If you would like to play the time steps twice slower, you can choose the play speed as 50%. Right now, only 100% and 50% play speed are supported. The time sequence flight path generation only supports one time-varying image overlay and/or one time-varying vertical displacement datasets. If no time-varying dataset is present in the current run, the Start Time Sequence button has no effect. When done, pull down the Animation menu and select Save As to save the animation to file. This saves the key frames and time intervals. The file extension for all animation files is .anim. To save the flight path for rendering, click on the Save Flight Path option. There must be at least 4 keyframes to create a flight path. All flight paths are saved with extension .flit. Flexible Flyer uses a cubic spline algorithm to interpolate the flight path with the set of keyframes. 6.6 Time Animation ControlThe Flexible Flyer provides a Time Animation control panel to view time-varying datasets. It will open when you select Time Animation under the animation menu. The time-varying dataset could be either a vertical displacement dataset or a horizontal displacement dataset. You can select either one or both of the datasets by clicking the checkbox next to the dataset. The vertical displacement will be added to the base elevation with a exaggeration selected using the vertical exaggeration slider. The horizontal displacement will be displayed as an overlay on top of the terrain image. The horizontal displacement dataset may contain multiple channels, say x component, y component, and magnitude. You can select any channel as an index to a color map using Select Channel pull down menu. You can also choose a color map by entering the name of the colormap. Note the colormap has to reside at the working directory where you start Flexible Flyer. You can enter a Frame Number in the text box and click Sumbit, or you can click one of the buttons at the bottom of the panel to control the animation. Once the Submit button or Play/Step button is clicked, the Flexible Flyer send a APPLY_DISP command to the renderer. Rewind button will rewind the time step to 1. Step button will step through the time sequence. Note that if you construct your time-varying dataset as a color overlay, you can view your data without using the Time Animation Control Panel. In the control panel, you can add a slider to choose the time step of a specific 3D dataset and use a opacity slider to control its opacity. In order to add a time slider, add a renderer control command displace in the configuration file for the Flexible Flyer.
6.6 Additional Rendering ControlThe drop down menu Renderer contains additional rendering commands. Redraw sends a REDRAW command to the renderer to rerender the previous frame. It is useful when you want to see the result after you change any rendering parameter without changing the viewing position. Terminate Renderer sends a BYE command to the renderer to terminate the renderer.Followed by Terminate Renderer in the Renderer menu are a list of image data sets. When rendering with multiple datasets, each dataset can be enabled or disabled. Checking or unchecking each dataset in this menu will result in a command "ENABLE dataset" or "DISABLE dataset" being sent to the renderer. Disabling dataset will speed up the rendering process. Note if there is only one dataset, this command has no effect. The last option in the renderer menu is called Mapper. Selecting Mapper will cause a popup window called "Band Mapper" to show up. RIVA can handle images with more than three channels, such as the LandSat TM dataset. The mapper allows you to map any of the input channel (also called "band" in LandSat) to one of the three colors, i.e., Red, Green, or Blue. To do that, you choose Copy in the Method box, and select one color out R, G, or B in the Color box on the left hand side, then you select a band number at the righhand side, then click Send. You have to repeat the process for each of the color bands. Other than copy mapper, RIVA supports four more color mapping methods, namely, Color Indexing,Ratio, Guass Stretch,and Auto Ratio. You can use one channel of the image as an index to a color map by selecting Index in the MethodBox. Next, you choose a channel from the indexmenu and type in the name of the color map and click Send. In addition, you can also map the ratio of two input channels into one color channel by selecting Ratio in the Method Box. This feature has not been tested recently, try it at your own risk. Lastly, the mapper can provide Guassian streatch to each of the color band. It remaps the histogram of a given color to a Guassian curve. User can specify the percentage of data that will be cut off at the high end and/or the low end while remapping. Again, this algorithm does not work for all the datasets. Try if with caution. Following is the Band Mapper window for guassian stretch. Each different mapping method is corresponding to a different commands, namely, MAPCOPY, MAPINDEX, MAPRATIO, MAPGUASS, and MAPAUTORATIO. All the render controls can also be issued using the command list in the Control Panel. See Renderer Command Language document for a complete list of commands. See AlsoRenderer Reference , Renderer Command Language , Flexible Flyer ReferenceRivaFile Format, xshow, receive_display back to documentation beginning of tutorial back to RIVA home | ||||
| ||||