Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ render_scen(3G) — PersonalVisualizer 2.11

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

create_scene(3G)

output_scene(3G)

set_cond_ind_mode(3G)

set_rad_ambient_mode(3G)

set_ray_aa_parms(3G)

set_ray_item_buffer(3G)

set_ray_output(3G)

set_ray_tree_parms(3G)

tmpfile(3S)

render_scene(3G)

NAME

render_scene − compute a global rendering of a given scene

SYNOPSIS

C Syntax:

void render_scene(fildes,scene_id,compute_type);
int fildes,scene_id,compute_type;

FORTRAN77 Syntax:

subroutine render_scene(fildes,scene_id,compute_type)
integer*4 fildes,scene_id,compute_type

Pascal Syntax:

procedure render_scene(fildes,scene_id,compute_type:integer);

DESCRIPTION

Input Parameters

fildes Integer file descriptor returned by gopen when an I/O path to a graphics device is opened. 

scene_id Scene identifier; as returned by create_scene. 

compute_type
If COMPUTE_RAY_TRACE, render the given scene with ray tracing. 

If COMPUTE_RAD_FIRST, initialize radiosity databases and perform the first iteration of the radiosity solution for the given scene.  The first iteration computes shading and shadowing due to one light source. 

If COMPUTE_RAD_FIRST ORed together with ALL_LIGHTS_ON, initialize radiosity databases and calculate shading due to all light sources at once, with no shadows. 

If COMPUTE_RAD_FIRST ORed together with RAD_SPECULAR, incorporate specular highlighting data into the radiosity calculations. 

If COMPUTE_RAD_STEP, refine the existing radiosity solution for scene_id. 

Discussion

render_scene traverses the display list segment network associated with the given scene_id to create a database of renderable surfaces, and then computes a global rendering of that database using the illumination model given by compute_type.  The resulting global rendering data becomes part of the scene, and may be output to the display with the output_scene command. 

To create the database of renderable surfaces, render_scene traverses the specified segment network and extracts any solid filled or textured surfaces (as determined by interior_style) for which shade_mode is TRUE or for which surf_light_model is DIFFUSE_LIGHT.  render_scene also extracts relevant surface attributes and texture map data, if defined, during the traversal.  Once the database of renderable surfaces is created, render_scene computes a global rendering of the type given by compute_type using the current SBRR control parameters. 

If a ray tracing is requested, the current state of the set_ray_* commands determine ray tree depth, anti-aliasing parameters, and whether or not the ray tracing is displayed while it is being computed.  The output of the ray tracing computation is an RGB bitmap which may be displayed with output_scene. 

If compute_type is set to COMPUTE_RAD_FIRST or COMPUTE_RAD_STEP, a progressive radiosity rendering is indicated.  To start a new radiosity rendering of scene_id, render_scene must be called with compute_type set to COMPUTE_RAD_FIRST.  This causes render_scene to traverse the model segment and to complete the first iteration of the radiosity solution.  The radiosity solution can then be refined by subsequent calls to render_scene with a compute_type of COMPUTE_RAD_STEP.  When compute_type is COMPUTE_RAD_STEP, no traversal occurs; the existing image for scene_id is merely refined.  The radiosity solution normally proceeds by calculating shading and shadowing effects for a single light source in each successive call to render_scene until all lights in the scene are accounted for.  Additional steps then calculate contributions from light reflecting off other surfaces in the model.  Because COMPUTE_RAD_STEP does no model traversal, changes to the model segment will not be taken into account by this compute type.  To incorporate changes in the model segment, the solution must be re-started by using a compute_type of COMPUTE_RAD_FIRST. 

If COMPUTE_RAD_FIRST is ORed with ALL_LIGHTS_ON, however, the illumination provided by all the light sources in the scene will be computed in the first step of the solution, but no shadows will be computed.  Subsequent steps will then compute the shadows for each light source in turn.  Further steps take into account reflected light as described above.  If output is to be viewed after early steps of the radiosity solution, the ALL_LIGHTS_ON ensures that the early steps of the solution provide images at least as good as those computed by standard Starbase rendering techniques. 

If COMPUTE_RAD_FIRST is ORed with RAD_SPECULAR, then the renderer will extract specular reflection data (as provided by the surface_coefficients and surface_model calls) from the model segment and incorporate this information into the solution.  Starbase can use this data to actually calculate the specular effects at output if the output device supports it. 

The output from any step of the radiosity solution is a list of Starbase polygons with RGB’s per vertex which may be output with output_scene. 

When the segment network is traversed to create the global environment database, several rules affect how attributes are bound to surface primitives:

1.  Needed Starbase attributes that are not explicitly set within the model segment are inherited from the Starbase state when render_scene is executed. 

2.  If global attributes for the model segment are defined more than once in the segment, render_scene uses only the most recent setting.  If, for instance, multiple viewpoints are specified, or if a light source is placed twice, render_scene takes the most recent view and/or light setting.  Similarly, if lights are turned on and off within the model, only the latest light_switch value is used. 

3.  The setting of set_cond_ind_mode determines whether and how segment pruning (sub-tree removal) and/or culling (sub-tree selection) occurs during model traversal to create the global rendering database.  Segment trees that are pruned or culled during traversal are not included in the database. 

4.  Primitives or segments that are marked invisible via the Starbase visibility filter at traversal time are not included in the global rendering database. 

5.  Starbase highlight attributes are ignored during the creation of the database.  This means that highlight attributes never replace normal attributes for global rendering. 

6.  Surface edge attributes are not included in the global rendering database. 

NOTES

The segment network traversal performed by render_scene will leave Starbase in the same state as a refresh_segment call, with the following exceptions:

1.  If compute_type is COMPUTE_RAY_TRACE, render_scene updates the current position as expected but does not modify the z-buffer or the display.  When called to do radiosity computations, render_scene updates the current position but never sends drawable primitives to the frame buffer, so the z-buffer and the display are never modified. 

2.  If set_ray_output for a given scene is TRUE (output to the screen during rendering), render_scene will always set the shade_mode to CMAP_FULL mode and initialize color maps prior to outputting the image.  Shade_mode is not reset to its previous state when render_scene exits. 

By default, the ray tracer writes its output bitmap to a file in the system’s current temporary files directory (as set by tmpfile).  When the output file is written to this directory, the rendering software automatically handles display and deletion of the bitmap, and the bitmap file itself remains invisible to the user.  If the user wants more control over the placement and use of the bitmap file, he or she can redirect it to another file by defining and exporting a global environment variable, USR_TMP_SBRR, prior to calling render_scene.  If USR_TMP_SBRR exists and is set to a valid filename (with either a full or relative path), the ray trace bitmap will be written to that file, and responsibility for display or deletion of the bitmap becomes the user’s.  If the file named by USR_TMP_SBRR already exists, it will be overwritten; if it cannot be opened, render_scene generates an error and exits. 

USR_TMP_SBRR can be useful for managing disk space (by re-routing the bitmap file, which can become large for complex models, onto an alternate disk).  It also allows the bitmap to be stored independently from the scene itself.  This allows you to delete the scene without deleting the bitmap. 

Note that the ray traced output bitmap is written in a compact, run-length encoded format that can only be read by render_scene. 

This command may not be stored in a segment. 

ERRORS

Invalid file descriptor. 
Invalid scene_id. 
Invalid compute_type. 
Not enough memory.
Segment network does not exist.

SEE ALSO

create_scene(3G), output_scene(3G), set_cond_ind_mode(3G), set_rad_ambient_mode(3G), set_ray_aa_parms(3G), set_ray_item_buffer(3G), set_ray_output(3G), set_ray_tree_parms(3G), tmpfile(3S),
Starbase Device Drivers Library Manual,
Starbase Radiosity and Ray Tracing Programmer’s Manual.

  —  July 12, 1991

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026